Hi there. Welcome to another tutorial on Arduino. So let us
get to work.
Open your IDE (if you did download one)
Then paste the following codes:
//Tutorial on arduino
//Written by Dekatron
//25-06-2016 17:10:01
//FEEL free to tweak anyhow you need to.
int Led1 = 5; //these
are the pin numbers we assign to the LEDs
int Led2 = 6; //it means we want our LEDs to have pin numbers
5,6,7 respectively
int Led3 = 7;
void setup() {
// put your setup
code here, to run once:
pinMode (Led1, OUTPUT); //This part of the code would run
just once.
pinMode (Led2, OUTPUT); //We used OUTPUT to set the mode of
our arduino because we want the pin to apply the voltage
pinMode (Led3, OUTPUT);
}
void loop() {
// put your main
code here, to run repeatedly:
//This part of the
code runs continuously
digitalWrite (Led1, HIGH); // we use this line of code to
switch on our LEDs
digitalWrite (Led2, HIGH);
digitalWrite (Led3, HIGH);
delay (1000); //this line will let the above code happen for
1 second. 1000 MEANS 1 SECOND
digitalWrite (Led1, LOW); //we used this to shut off the
LED1 and so on till LED3
delay (1000);
digitalWrite (Led2, LOW);
delay (1000);
digitalWrite (Led3, LOW);
}
I guess that is done now… so, let us get to the hardware
wiring:
Remember
that we said that in our code, we said that the LED1= 5, LED2 = 6, LED3=7.
Good. I hope you kept that in mind because I want you to go back to the Arduino
picture about….
Okay,so…you
saw that from the above, some ‘holes’ were named with numbers. Okay, you saw
the part where you have ‘0 1 2 3 4 ….’ Like that. The gist is that we want to
connect our LEDs according to the way we programmed it. You asked what happens
if we do not wire it the way the program says? Well, your computer wouldn’t get
blown or your Breadboard won’t explodes (actually, you use a 9V battery –max.
It’s relatively harmless because it is low voltage and it’s DC). What would
happen would be that the LEDs will not light up, and the project would all be
nothing. Okay, follow me.
So there,
you saw some erhmm…. Numbers. Some had some symbol next to them, some have
inscriptions like Rx Tx (Transmitter Reciever respectively). Now,
we attach the positive leg of our LED to the hole labeled ‘2’, ditto for other
LEDs.
Here: ![](file:///C:\Users\ZETAMU~1\AppData\Local\Temp\msohtml1\01\clip_image002.jpg)
![](file:///C:\Users\ZETAMU~1\AppData\Local\Temp\msohtml1\01\clip_image002.jpg)
Our code has been compiled
No comments:
Post a Comment