Arduino Tutorial for Beginners – Setup And Loop Blocks + light LEDs right to left
#define myAnodeLed1 10 // Define pin to easily change | |
#define myAnodeLed2 9 | |
#define myAnodeLed3 8 | |
#define Led_On_Off 500 | |
void myFn() | |
{ | |
digitalWrite(myAnodeLed1,HIGH); // OUTPUT 5 Voltage at pin 10 | |
delay(Led_On_Off); // Delay 500ms (0.5s) as we set above | |
digitalWrite(myAnodeLed2,HIGH); // OUTPUT 5 Voltage at pin 9 | |
delay(Led_On_Off); | |
digitalWrite(myAnodeLed3,HIGH); // OUTPUT 5 Voltage at pin 0 | |
delay(Led_On_Off); | |
digitalWrite(myAnodeLed1,LOW); // OUTPUT 0 Voltage at pin 10 | |
delay(Led_On_Off); // Delay 500ms (0.5s) as we set above | |
digitalWrite(myAnodeLed2,LOW); // OUTPUT 0 Voltage at pin 9 | |
delay(Led_On_Off); | |
digitalWrite(myAnodeLed3,LOW); // OUTPUT 0 Voltage at pin 0 | |
delay(Led_On_Off); | |
} | |
void setup() | |
{ | |
// put your setup code here, to run once: | |
pinMode(myAnodeLed1,OUTPUT); // Setup pin 10 is OUTPUT | |
pinMode(myAnodeLed2,OUTPUT); // Setup pin 9 is OUTPUT | |
pinMode(myAnodeLed3,OUTPUT); // Setup pin 8 is OUTPUT | |
} | |
void loop)() | |
{ | |
// put your main code here, to run repeatedly: | |
myFn(); // Call myFn function to to run code | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment