Basic 𝐑𝐨𝐛𝐨𝐭𝐢𝐜𝐬
– Robotics Engineering Certification
Let’s Start the Robotics Journey
Class 01-
Introduction to Arduino
& Programming
Arduino-Introduction
Arduino Nano Arduino UNO Arduino Mega
Arduino-Introduction
INPUT PROCESS OUTPUT
How does Arduino take INPUT?
Digital INPUT Pin
Analog INPUT Pin
How does Arduino PROCESS a data?
★ Arduino has its own language similar to C++
How does Arduino give an OUTPUT?
Digital OUTPUT Pin
Others Pin of Arduino - PWM Pin
★ Digital Output Pin but acts like an Analog
Output pin
PWM Pin
Pulse Width Modulation
Others Pin of Arduino - Tx/Rx Pin
★ Transmit or Receive data
Transmitter Receiver Pin
Others Pin of Arduino - Power Pin
5v , 3.3v Supply
Ground
How to POWER UP an Arduino?
By Laptop By Battery
Recap
★ Arduino is a microcontroller unit
★ Arduino has its own language to program
★ It has several types of pins like digital i/o,
analog pin, pwm pin, power pin, tx/rx pin.
★ Every pins has its own purpose
Arduino
Programming
Arduino Programming Basics
Arduino Programming Language:
● Based on C/C++ programming language.
Structure of an Arduino Sketch:
● Two primary functions: setup() and loop().
● setup(): Runs once, used for initialization.
● loop(): Runs continuously after setup(), contains the main logic.
Arduino Programming Basics
setup() Function:
● Called once at the start of the program.
● Used to configure settings (e.g., pin modes, serial communication).
loop() Function:
● Executes repeatedly, contains core program logic.
Using the Print Function
Serial Communication Basics:
● Serial.begin(9600); – starts communication at 9600 baud.
Serial.print() and Serial.println():
● Serial.print("Text"); – prints text or variables.
● Serial.println(variable); – prints and moves to a new line.
Variables in Arduino Programming
What is a Variable?
● A variable is a placeholder for storing data (numbers, characters, etc.).
Naming Rules:
● Must start with a letter, no spaces, case-sensitive.
Example of Variable Declaration:
● int ledPin = 13; (declaring an integer variable for an LED pin).
Variable Declaration and Initialization
Declaring a Variable:
● Syntax: dataType variableName;
● Example: int score;
Initializing a Variable:
● Syntax: dataType variableName = value;
● Example: int score = 0;
Difference Between Declaration and Initialization:
● Declaration creates space in memory, initialization assigns a value.
Operators in Arduino Programming
Arithmetic Operators:
● +, -, *, /, % (modulo)
Assignment Operators:
● =, +=, -=, *=, /=
Relational Operators:
● ==, !=, >, <, >=, <=
Logical Operators:
● && (AND), || (OR), ! (NOT)
Programming Problems:
● Sum and Average of Two Numbers
● Calculate Voltage using Ohm’s Law
● Calculate the Area of a Circle
Programming Problems:
● Swapping two Variable
Given: a=10 b=15
Output: a=15 b=10
a b a b
10 15 15 10
Given: a=10 b=15 Output: a=15 b=10
Programming Problems:
a b
10 15
Programming Problems:
a b temp
10 15 __
Programming Problems:
a b temp
10 15 __
Programming Problems:
a b temp
__ 15 10
Programming Problems:
a b temp
__ 15 10
Programming Problems:
a b temp
15 __ 10
Programming Problems:
a b temp
15 __ 10
Programming Problems:
a b temp
15 10 __
Programming Problems:
a b
15 10
QnA
Class Task
● Simple Calculator (Addition, Subtraction, Multiplication, Division)
● Simple Interest Calculation
Home Task
● Calculate Body Mass Index (BMI)
● Calculate Simple Average of Three Numbers
● Fahrenheit to Celsius Conversion
● Calculate the Perimeter of a Rectangle
● Minutes to Seconds Conversion