I started leaning Arduino these days and I am totally into it! The hardware stuffs have so much fun! I want to share what I learned a little bit about Arduino which is about how to blink a LED light on Arduino. So here is the easiest project that you can do.
◯What you need
- Arduino Uno
2. USB cable (Type A to B)
◯What you code
In my tutorial, I will try to blink for each two second.
1 2 3 4 5 6 7 8 9 10 11 12 |
#define LED_PIN 13 void setup() { pinMode (LED_PIN, OUTPUT); } void loop() { digitalWrite (LED_PIN, HIGH); delay (2000); digitalWrite (LED_PIN, LOW); delay (2000); } |
◯Explanation of each line of code
・#define LED_PIN 13
// This is able to define LED_PIN 13 as a constant value. (By you just change the code you define when you want to change, you can replace all the programming you code. Which means you do not have to change every single line of code.)
・void setup() {
pinMode (LED_PIN, OUTPUT);
}
// It initializes the digital pin which is 13 from #define LED_PIN 13.
・void loop()
// The loop function is the function that runs repeatedly.
・digitalWrite (LED_PIN, HIGH);
// This turns on the LED light.
・delay (2000);
// Milliseconds. In this case, 2000 means 2 seconds.
・digitalWrite (LED_PIN, LOW);
// This turns off the LED light.