2. Setup
Arduino programming is like C.
It has t wo basic functions.
First is setup - this has all commands
that are executed only once.
void setup (void)
{
;
}
3. Loop
Second function is loop - This has
commands executed in a continius loop.
void loop (void)
{
;
}
4. Predefined Commands
There are few predefined commands
First command is pinMode. This sets the
function of pin as input or output.
Usually this is done in setup function
void setup (void)
{
pinMode (13,OUTPUT);
}
5. Predefined Commands
Another is digitalWrite.
This write HIGH or LOW on pins defined as
OUTPUT.
This can be executed in setup or loop
function
void loop (void)
{
digitalWrite (13,HIGH);
}
6. Predefined Command
Another command is delay.
This provide delay in msecs.
void loop (void)
{
digitalWrite (13,HIGH);
delay(500);
digitalWrite (13,LOW);
delay(500);
}
7. First Program
#define LED 13
void setup (void)
{
pinMode (LED,OUTPUT);
}
void loop (void)
{
digitalWrite (LED,HIGH);
delay(200);
digitalWrite (LED,LOW);
delay(200);
}
8. Verify-Upload
Click on VERIFY (Sketch | Verify)
Click on UPLOAD (File | Upload)
Wait - it will start running, LED will
start blinking after few seconds.
Change the delay, verify and upload
again. See the difference on blinking
time and speed.
9. Next Level Program
Modify the program so that with single
LED you create morse code of SOS.
Send me an email giving your
experience, total time spent and
problems faced in the process.
This is first part of training. You will be
getting next level of training soon.
10. Contact Me
Have more ideas, queries, suggestions?
Contact me at -
Vinay Chaddha
email : vinay@joy-n-freedom.com
SMS : 9811074026