ArduinoProgramming Harshit Pandey
ArduinoProgramming Harshit Pandey
Pantnagar
THE
INBOTICS
WOKSHOP
2023
The Robotics Club
Pantnagar
SESSION 3
ARDUINO
PROGRAMMING
presented by- Harshit Pandey
RECAP
• SYNTAX
• VARIABLES
• CONDITIONAL STATEMENTS
• LOOPS
• FUNCTIONS
SYNTAX.
DEFINITION EXPLAINED
int a = 10;
Variables are the names you give to
computer memory locations which are used
to store values in a computer program. And
char x =
datatype is the type of the data.
3.12;
LOOPS
DEFINITION EXAMPLE
}
Conditional statements are used to instruct else{
the computer on the decision to make when do something else
A function is a set of statements that when called perform some specific task. It
is the basic building block of a program that provides modularity and code
reusability.
The Robotics Club
Pantnagar
WHY
PROGRAMMING?
The Robotics Club
Pantnagar
WHY PROGRAMMING?
TO MAKE MACHINES
EXECUTE BASED ON
CONDITIONS
Robotics combines the use of electronics, mechanics, and
coding software to program robots to do particular jobs.
Robots can easily perform those tasks that humans are not
able to perform, with the help of sensors and other
equipments.
ARDUINO
PROGRAMMING
WHAT IS PROGRAMMED?
THIS IS
DIGITAL PINS
WE CAN CONTROL VOLTAGE
ON THESE PINS
what
pins? SETUP
----------
WHAT LOOP
TO DO?
Pseudocode - Light up a led
Setup{
6th pin is output
7th pin is output
}
loop{
6th pin -> HIGH
7th pin -> LOW
}
Code - Light up a led
void setup(){
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop(){
digitalWrite(7,HIGH);
digitalWrite(8,LOW);
}
ARDUINO SPECIFIC FUNCTIONS
pinMode
pinMode(pin,
mode)
pinMode(7,input)
digitalWrite
digitalWrite(pin,
value)
digitalWrite(6,HIGH)
;
ARDUINO SPECIFIC FUNCTIONS
digitalRead
digitalRead(pin
)
digitalRead(7)
delay
delay(milliseconds
)
delay(1000)
ARDUINO SPECIFIC FUNCTIONS
analogRead
analogRead(pin
)
analogRead(7)
analogWrite
analogwrite(pin,value)
analogRead(7,200)
Variables int led1 = 7;
int led2 =
11;
Setup{
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}
loop{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);digi
}
Serial Monitor 9600 bits/sec is the default rate for
arduino
Serial.print(“hello”)
;
Serial.println(“hi);