The on-board LED is blinking in this example, which demonstrates the simplest thing you can do with an Arduino to observe physical output.
Components Required
- Arduino board
- LED (optional)
- 220 ohm resistor
- Breadboard
- Computer: PC/Laptop
- Arduino IDE installed on computer
Circuit
This illustration makes use of the built-in LED found on most Arduino boards. The number of the digital pin that this LED is attached to can change from one type of circuit board to another. We have a constant that is mentioned in each board descriptor file to make your life simpler. The built-in LED may be readily controlled thanks to the constant LED. The constant's relationship to the digital pin is seen here.
- D13 - 101
- D13 - Due
- D1 - Gemma
- D13 - Intel Edison
- D13 - Intel Galileo Gen2
- D13 - Leonardo and Micro
- D13 - LilyPad
- D13 - LilyPad USB
- D13 - MEGA2560
- D13 - Mini
- D6 - MKR1000
- D13 - Nano
- D13 - Pro
- D13 - Pro Mini
- D13 - UNO
- D13 - Yún
- D13 - Zero
You must assemble this circuit and link one end of the resistor to the digital pin that corresponds to the LED BUILTIN constant if you want to light an external LED with this code. Connect the resistor's other end to the LED's long positive leg (also known as the anode). Connect the cathode, or short negative leg, of the LED to the ground (GND). The LED BUILTIN value on the UNO board that is depicted in the diagram below is D13.
Blinking LED - Arduino Circuit |
The resistor value connected in series with the LED may be different from 220 ohm; the LED will still light up with values as high as 1K ohm.
Arduino Code
Once the circuit is complete, connect your Arduino board to your computer, launch the Arduino Software (IDE), and enter the following code.
/*
For detail information visit: www.techknowlab.com
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Comments
Post a Comment