0% found this document useful (0 votes)
2 views

ArduinoProgramming Harshit Pandey

The document outlines a workshop on Arduino programming presented by Harshit Pandey, covering key programming concepts such as syntax, variables, loops, conditional statements, and functions. It emphasizes the importance of programming in robotics to enable machines to execute tasks based on conditions. Additionally, it provides examples of Arduino-specific functions and how to control digital and analog pins for programming applications.

Uploaded by

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

ArduinoProgramming Harshit Pandey

The document outlines a workshop on Arduino programming presented by Harshit Pandey, covering key programming concepts such as syntax, variables, loops, conditional statements, and functions. It emphasizes the importance of programming in robotics to enable machines to execute tasks based on conditions. Additionally, it provides examples of Arduino-specific functions and how to control digital and analog pins for programming applications.

Uploaded by

ananyabht168
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

The Robotics Club

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

The way of writing a the rules that control the


programming language structure of the symbols,
punctuation, and words of a
programming language.
Variables and
datatypes
To name and define an entity

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

Execute a piece of code a=1;


again and again. while(a<=10){
print(3*a);
a++;
}
Conditional Statements
to perform different task based on different
if (this){
conditions. do something

}
Conditional statements are used to instruct else{
the computer on the decision to make when do something else

given some conditions. }


FUNCTIONS

void table( int x )


{ block of code
a=1; table(4);
while(a<=10){ table(45);
print(x*a) table(343);
a++
given a name
}
}

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

CAN HAVE highOR low VALUES


(1) (0)

ANALOG INPUT PINS WITH ~ (PWM)


CAN BE USED TO GET
INPUT FROM SENSORS
CAN HAVE Analog VALUES
(0-255)
HOW A PROGRAM IS LAID OUT

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 Monitor is used to


display text in the arduino
console Serial.begin(9600);

Serial.print(“hello”)
;
Serial.println(“hi);

You might also like