Skip to content

Instantly share code, notes, and snippets.

@agtbaskara
Created December 18, 2018 14:22
Show Gist options
  • Save agtbaskara/7b0fafad64f02873caa8c4666b457a9a to your computer and use it in GitHub Desktop.
Save agtbaskara/7b0fafad64f02873caa8c4666b457a9a to your computer and use it in GitHub Desktop.
UTS Mekatronika Cavell
void setup()
{
pinMode(1, OUTPUT); // Set Pin 1 sebgai output LED 1
pinMode(2, OUTPUT); // Set Pin 2 sebgai output LED 1
pinMode(3, OUTPUT); // Set Pin 3 sebgai output LED 1
pinMode(4, OUTPUT); // Set Pin 4 sebgai output LED 1
pinMode(5, OUTPUT); // Set Pin 5 sebgai output LED 1
}
void loop()
{
digitalWrite(1, HIGH); // turn the LED 1 on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(1, LOW); // turn the LED 1 off by making the voltage LOW
delay(1000); // wait for 1 second
digitalWrite(2, HIGH); // turn the LED 2 on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(2, LOW); // turn the LED 2 off by making the voltage LOW
delay(1000); // wait for 1 second
digitalWrite(3, HIGH); // turn the LED 3 on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(3, LOW); // turn the LED 3 off by making the voltage LOW
delay(1000); // wait for 1 second
digitalWrite(4, HIGH); // turn the LED 4 on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(4, LOW); // turn the LED 4 off by making the voltage LOW
delay(1000); // wait for 1 second
digitalWrite(5, HIGH); // turn the LED 5 on (HIGH is the voltage level)
delay(1000); // wait for 1 second
digitalWrite(5, LOW); // turn the LED 5 off by making the voltage LOW
delay(1000); // wait for 1 second
}
void setup()
{
pinMode(1, OUTPUT); // Set Pin 1 sebgai output LED 1
}
void loop()
{
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for 2 second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for 2 second
}
int StartButton = 1; // Start Button connected to digital pin 1
int LimitSwitchBawah = 2; // Limit Switch Bawah connected to digital pin 2
int LimitSwitchAtas = 3; // Limit Switch Atas connected to digital pin 3
int SolenoidA = 4; // Solenoid A connected to digital pin 4
int SolenoidB = 5; // Solenoid B connected to digital pin 5
void setup()
{
pinMode(StartButton, INPUT); // sets the digital pin 1 as input
pinMode(LimitSwitchBawah, INPUT); // sets the digital pin 2 as input
pinMode(LimitSwitchAtas, INPUT); // sets the digital pin 3 as input
pinMode(SolenoidA, OUTPUT); // sets the digital pin 4 as output
pinMode(SolenoidB, OUTPUT); // sets the digital pin 5 as output
}
void loop()
{
if(digitalRead(StartButton) == 1) // read StartButton status
{
digitalWrite(SolenoidA, 1); // turn on SolenoidA
}
if(digitalRead(LimitSwitchBawah) == 1) // read LimitSwitchBawah status
{
digitalWrite(SolenoidA, 0); // turn off SolenoidA
digitalWrite(SolenoidB, 1); // turn on SolenoidB
}
if(digitalRead(LimitSwitchAtas) == 1) // read LimitSwitchAtas status
{
digitalWrite(SolenoidB, 0); // turn off SolenoidB
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment