0% found this document useful (0 votes)
2 views13 pages

Program Structure & Rules

Uploaded by

utkarshjat1510
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

Program Structure & Rules

Uploaded by

utkarshjat1510
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

I : integrated

D : devlopment
E : environment
[Link]
[Link]
PROGRAM
STRUCTURE
& RULES
RULES:
1. Every Arduino Program has
void setup() and void loop()
2. Program runs in linear fashion
3. Remember the { } Curly brackets
4. Program is Case sensitive
5. Use // to add comments in Program
6. Put ; after every statement
void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}
NOTES:
1. Variables are used to store information to be
referenced & manipulated in a computer program.
2. Three things are required to declare a variable
> Data type
> Variable name
> Value
3. Global variables can be accessed (used) on any
function in the program
4. Local variables are declared inside a function, and can
be used only inside that function
syntax
//data_type variable_name = value
int val = 10; I
WRITING OUR FIRST
PROGRAM
SOME BASIC FUNCTIONS FOR
CONTROLLING THE ARDUINO BOARD.
1. pinMode()
Configures the specified pin to behave
either as an input or an output.
■ Syntax
pinMode(pin no, mode);
pin: Arduino pin
mode: INPUT/OUTPUT
▪Ex: pinMode(13, OUTPUT);
2. digitalWrite()
Write a HIGH or a LOW to a digital pin.
■ Syntax:
digitalWrite(pin, value); E
pin: Arduino pin
value: HIGH/LOW
▪Ex: digitalWrite(13, HIGH);
3. delay()
Pauses the program for the amount of time (in
milliseconds) specified as parameter.
■ Syntax :
delay(ms);
ms: the number of milliseconds to pause
▪Ex: delay(1000);
##Program to run led repeatedly##
void setup() {
// put your setup code here, to run once:
pinMode (13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}

You might also like