Arduino lab 1_0

12
Arduino Lab 1.0 Lab 1.0 - LED Blinking

description

First Arduino Lab. How to blink an LED

Transcript of Arduino lab 1_0

Page 1: Arduino lab 1_0

Arduino Lab 1.0Lab 1.0 - LED Blinking

Page 2: Arduino lab 1_0

Material RequiredArduino Board + RS232 Cable + Power Supply

Or

Arduino Mega + USB Cable

Installed Arduino IDE on your computer

Working RS232 or USB port in your computer

Page 3: Arduino lab 1_0

SetupArduino programming is like C.

It has two basic functions.

First is setup - this has all commands that are executed only once.

void setup (void){

;}

Page 4: Arduino lab 1_0

Loop

Second function is loop - This has commands executed in a continius loop.

void loop (void)

{;

}

Page 5: Arduino lab 1_0

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);}

Page 6: Arduino lab 1_0

Predefined CommandsAnother 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);}

Page 7: Arduino lab 1_0

Predefined CommandAnother command is delay.

This provide delay in msecs.

void loop (void){digitalWrite (13,HIGH);delay(500);digitalWrite (13,LOW);delay(500);

}

Page 8: Arduino lab 1_0

First Program#define LED 13void setup (void){

pinMode (LED,OUTPUT);}void loop (void){

digitalWrite (LED,HIGH);delay(200);digitalWrite (LED,LOW);delay(200);

}

Page 9: Arduino lab 1_0

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.

Page 10: Arduino lab 1_0

Next Level ProgramModify 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.

Page 11: Arduino lab 1_0

Contact MeHave more ideas, queries, suggestions?

Contact me at -

Vinay Chaddha

email : [email protected]

SMS : 9811074026

know more about me at visualcv.com/gvc3065