Just like our first program in C language is Hello World.
Our first program in arduino is blinking a led.
What is led?
Leds are light emitting diode, which emits light when subjected to forward voltage of 2.0 Volts and it requires current of about 25 mA. Leds comes in different colours viz. red, green, blue, white, etc.
Always check for its forward voltage and current consumption.
How to check leds using multimeter?
Set the multimeter on diode mode, now connect red probe to anode and black probe to cathode of led.
|
Checking led using multimeter |
Now as arduino uno provides a logic of logic 1 (+5 volts) or logic 0 (0 volts). We have to connect external series resistor for led.
Some calculation:
According to ohm's law: V=IR
R=V/I
R=5000 mV/25 mA
R=200 ohms.
This is not a standard value.
We will use 220E resistor.
Code for blinking a led:
const int led=7;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(led, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Upload the above using arduino IDE. That's it
|
Fritzing sketch of arduino uno | | | |
|
|
|
|
|
|
Stay tuned for more updates !!!
Robotics companies in Delhi India