際際滷

際際滷Share a Scribd company logo
COIMBATORE  641 004
SESSION 1
PSG COLLEGE OF TECHNOLOGY
1
Selvaraj. K
Project Engineer
PSG-Robotics
OVERVIEW
 Microcontroller Defined
 Arduino Defined
 Arduino Advantages
 Arduino Applications
 Types of Arduino Boards
 Analog, Digital, Inputs and Outputs
MICROCONTROLLER
 Microcontroller Like as
Brain
 It make decision in the
Robots
 It collect the information
from the Sensors and control
the actuator by the command
MICROCONTROLLER
 Microcontroller It is a Decision maker
with help of ROM,RAM and
Arithmetic Logic Unit.
 Input port- Eye(Sensor)
 Output Port- Mouth(Actuators or
Speaker)
 All input and output ports are
controlled by the programming
MICROCONTROLLER
 Programmers work in the virtual world.
 Machinery works in the physical world.
 How does one connect the virtual world to the physical world?
 A microcontroller is basically a small-scale computer with
generalized (and programmable) inputs and outputs.
 The inputs and outputs can be manipulated by and can
manipulate the physical world
INTRODUCTION ABOUT ARDUINO
Based on a simple micro-controller board, and
A development environment (IDE) for writing software for the board
Open source electronics prototyping platform based on flexible ,Easy to use hardware
and software
Arduino can be used to develop interactive objects, taking inputs from a variety of
switches or sensors, and controlling a variety of lights, motors, and other physical
outputs. Arduino projects can be stand-alone, or they can be communicate with
software running on your computer (e.g. Flash, Processing, MaxMSP.) The boards can
be assembled by hand or purchased preassembled; the open-source IDE can be
downloaded for free.
The Arduino programming language is an implementation of Wiring, a similar physical
computing platform, which is based on the Processing multimedia programming
environment.
MAIN ADVANTAGES OF ARDUINO
 Arduino microcontrollers have become the de facto standard.
Make Magazine features many projects using Arduino
microcontrollers.
 Strives for the balance between ease of use and usefulness.
Programming languages seen as major obstacle.
Arduino C is a greatly simplified version of C++.
 Unit price around Rs.1400
APPLICATION AREAS
Light control
Motor control
Automation
Robotics
Networking
Custom protocols
Your imagination is the limit
TYPES OF ARDUINO BOARDS
 Many different versions
Number of input/output channels
Form factor
Processor
 Leonardo
 Due
 Micro
 LilyPad
 Esplora
 Uno
 Mega
LEONARDO
 Compared to the Uno, a slight upgrade
 Built in USB compatibility
DUE
 Much faster processor, many more pins
 Operates on 3.3 volts
 Similar to the Mega
MICRO
 When size matters: Micro, Nano, Mini
 Includes all functionality of the Leonardo
 Easily usable on a breadboard
LILYPAD
 LilyPad is popular for clothing-based projects.
 It is a Low weight and flexible
ESPLORA
 Game controller
 Includes joystick, four buttons, linear potentiometer (slider), microphone,
light sensor, temperature sensor, three-axis accelerometer.
 Not the standard set of IO pins.
MEGA
 Compared to the Uno, the Mega:
Many more communication pins
More memory
ARDUINO MEGA
 Physically larger than all the other boards
 Offers significantly more digital and analog pins.
 Uses a different processor allowing greater program size
Microcontroller: ATmega1280
Operating Voltage 5V
Input Voltage: 7-12V
Digital I/O Pins 54 (of which 14 provide PWM output)
ARDUINO MEGA
Analog Input Pins 16
Flash Memory 128 KB of which 4 KB used by boot loader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHZ
ARDUINO UNO
 The pins are in three groups:
Invented in 2010
14 digital pins
6 analog pins
power
ARDUINO UNO
 Microcontroller ATmega 328
 Operating Voltage 5V
 Input Voltage (recommended) 7-12V
 Input Voltage (limits) 6-20V
 Digital I/O Pins 14 (of which 6 provide PWM output)
 Analog Input Pins 6
 DC Current per I/O Pin 40 mA
 DC Current for 3.3V Pin 50 mA
 Flash Memory 32 KB (of which 0.5 KB used by boot loader)
 SRAM 2 KB (ATmega328)
 EEPROM 1 KB (ATmega328)
 Clock Speed 16 MHz
 Totally Arduino Uno have 14 Digital Input and Output
pins. They are numbered 0 to 13.
 Analog Input Pins are A0 to A5
ARDUINO COMPONENTS
UNDERSTANDING INPUT VS OUTPUT
 INPUT PIN
Inputs is a signal / information
going into the board.
 OUTPUT PIN
Output is any signal exiting
the board.
ANALOG VS DIGITAL
ANALOG
 Microcontrollers are digital devices  ON or OFF
DIGITAL
 An Analog signal is anything that can be a full range of values.
What are some examples? Think of like a ramp or a hill.
INPUT and OUTPUT
1. analogRead-Analog INPUT
2. analogWrite-Analog OUTPUT
3. digitalRead- digital INPUT
4. digitalWrite- digital OUTPUT
BASIC KNOWLEDGE REQUIRED
 Ohms LAW
 Current
 Voltage
 Resister
 Capacitor
 Inductor
 Voltage LAW
 Current Law
 Rheostat function
 Transformer
 Rectifier
 Regulator
 Inverter
 Amplifier
 Diode
 Transistor
 AC and DC Voltages
 Types of Motors
 Basic sensors
PULL UP RESISTER PULL DOWN RESISTER
ANALOG VS DIGITAL
To create an analog signal, the microcontroller uses a technique
called PWM.
Pins 3, 5, 6, 9, 10, 11 are capable of producing an Analog
Output
Pulse Width Modulation (PWM)
SESSION II
OVERVIEW
 Objectives
 Startup Arduino IDE
 Arduino Sketch Details
 Commands ,Operators, Variables
 Basic Repetitions
 Settings and Configurations
OBJECTIVES
 Provide a thorough introduction to the Arduino programming
environment.
 Develop a use of simple functions to interact with the LEDs, light
sensor, push button, and buzzer on the Protosnap Pro Mini.
STARTUPARDUINO IDE
 Double-click on either the Arduino Icon or wherever you installed
(saved) the Arduino program.
PLUG IT IN
THE ENVIRONMENT
PARTS OF THE SKETCH
COMMENTS
 Comments can be anywhere
 Comments created with // or /* and */
 Comments do not affect code
 You may not need comments, but think about the community.
OPERATORS
The equals sign
= is used to assign a value
== is used to compare values
And & Or
&& is and
|| is or
BASIC VARIABLE TYPES
Boolean
Integer
Double
Float
Character
String
DECLARING VARIABLES
Boolean: boolean variableName;
Integer: int variableName;
Character: char variableName;
String: stringName [ ];
ASSIGNING VARIABLES
 Boolean: variableName = true;
or variableName = false;
 Integer: variableName = 32767;
or variableName = -32768;
VARIABLE SCOPE
Where you declare your variables matters?
SETUP
void setup ( ) { }
The setup function comes before the loop function and is necessary
for all Arduino sketches
SETUP
void setup ( ) { }
The setup header will never change, everything else that
occurs in setup happens inside the curly brackets
SETUP
void setup ( ) {
pinMode (13, OUTPUT); }
Outputs are declare in setup, this is done by using the pinMode
function
This particular example declares digital pin # 13 as an output,
remember to use CAPS
SETUP
void setup ( ) { Serial.begin;}
Serial communication also begins in setup
This particular example declares Serial communication at a baud
rate of 9600. More on Serial later...
Setup, Internal Pullup Resistors
void setup ( ) {
digitalWrite (12, HIGH); }
 You can also create internal pullup resistors in setup, to do so digitalWrite
the pin HIGH
 This takes the place of the pullup resistors currently on your circuit 7
buttons
Setup, Interrupts
void setup ( )
{
attachInterrupt (interrupt, function, mode) }
You can designate an interrupt function to Arduino pins # 2 and 3
volatile unsigned int L=1;
volatile double Le,Re;
void setup()
{
attachInterrupt(0, countpulsesL, FALLING);
Serial.begin(9600);}
void loop() {
Serial.println(L);
delay(1000);}
void countpulsesL() {L++;}
Setup, Interrupts
void setup ( )
{
attachInterrupt (interrupt, function, mode)
}
Interrupt: the number of the interrupt, 0 or 1, corresponding
to Arduino pins # 2 and 3 respectively
Function: the function to call when the interrupt occurs
Mode: defines when the interrupt should be triggered
Setup, Interrupts
void setup ( )
{
attachInterrupt (interrupt, function, mode)
}
LOW whenever pin state is low
CHANGE whenever pin changes value
RISING whenever pin goes from low to high
FALLING whenever pin goes from low to high
Dont forget to CAPITALIZE
Example program
volatile unsigned int L=1;
volatile double Le,Re;
void setup()
{
attachInterrupt(0, countpulsesL, FALLING);
Serial.begin(9600);}
void loop() {
Serial.println(L);
delay(1000);}
void countpulsesL()
{
L++;}
If Statements
if ( this is true ) { do this; }
If
If ( this is true )
{
do this; }
Conditional
If ( this is true ) { do this; }
Action
if ( this is true ) { do this; }
Else
else { do this; }
BASIC REPETITION
 loop
 For
 while
BASIC REPETITION
void loop ( ) { }
Basic Repetition
void loop ( ) { }
BASIC REPETITION
void loop ( ) { }
BASIC REPETITION
for (int count = 0; count<10; count++)
{//for action code goes here
//this could be anything}
BASIC REPETITION
for (int count = 0; count<10; count++)
{
//for action code goes here
}
BASIC REPETITION
for (int count = 0; count<10; count++)
{
//for action code goes here
}
BASIC REPETITION
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
BASIC REPETITION
for (int count = 0; count<10; count++)
{
//for action code goes here
}
Basic Repetition
for (int count = 0; count<10; count++)
{
//for action code goes here
}
BASIC REPETITION
while ( count<10 )
{
//while action code goes here
//should include a way to change count
//variable so the computer is not stuck
//inside the while loop forever
}
BASIC REPETITION
while ( count<10 )
{
//looks basically like a for loop
//except the variable is declared before
//and incremented inside the while
//loop
}
ARDUINO DATA COMMUNICATION SETUP
68
CONFIGURING ARDUINO
1. Setup Board
(Arduino UNO/ ATmega328)
2. Setup COM Port
PC  Highest COM #
Settings: Tools  Board
Settings: Tools  Serial Port
Input
Status Bar
Program
Notification
Area
5.- Verify/Compile
6.- Once it compiles, you must see the following
messages in the Status bar and the Program
notification Area
7. Upload it
8. Once it upload, you must see the following
messages in the Status bar and the Program
notification Area
Error
avrdude: stk500_getsync(): not in sync: resp=0x00
can't open device "COM10": The system cannot find the file
specified
ARDUINO PROGRAMMING CHALLENGES
Session III &IV
CHALLENGES
Introduction to use Electronic components
LED Control by Arduino
Multiple LEDs Control by looping
Operators conditions test
Analog sensor test
Analog Sensor Value based LED control
LIST OF COMPONENTS
Arduino board USB cable
L293 driver board Battery
LIST OF COMPONENTS
Dc motor Line array sensor
Potentiometer
Ultrasonic sensor adapter
LIST OF COMPONENTS
Connecting wires Ultrasonic sensor
LEDs
Resisters
Reset button/switch
ARDUINO PROGRAMMING INSTRUCTIONS
pinMode(pin, mode)
Designates the specified pin for input or output
digitalWrite(pin, value)
Sends a voltage level to the designated pin
digitalRead(pin)
Reads the current voltage level from the
designated pin
analog versions of above
analogRead's range is 0 to 1023
serial commands
print, println, write
ARDUINO USING SOLDERLESSBREADBOARD
Solderless Board is useful to build proto types.
Time consuming process of soldering parts together to make
connections
Most important thing in using a solder less breadboard in
understanding its connections
wiring underneath the white cover to be able to connect
parts in a way that complete and flawless lines are provided for
electricity flow
82
Instruction to Components handling
1. Doing circuit connection  Dont power up Controller
board
2. Dont use metal surface and maintain at free surface
3. Circuit check before power up
4. Dont make short circuit
5. After completion of Experiments- all components put in
to box and cross check the list
LED PROGRAMMING FOR BLINKING
FUNCTIONS
Turn LED
ON
Wait
Turn LED
OFF
Wait Repeat
CIRCUIT CONNECTION
DIGITAL OUTPUT-LED
86
Digital pin 10 connected
with Resister.
Long leg connected with
resister end.
short Leg connected with
Ground.
Ground Pin
Digital Pin
LED FUNCTION INSTRUCTIONS
Connect the positive (+) lead of a power source to
the long leg of an LED.
Connect other leg of the LED to a resistor.
High resistance means a darker light.
Low resistance means brighter light.
No resistance means to the negative lead of the
power source. a burned out LED.
Connect other leg of the resistor
LED FUNCTION
Turn LED
ON
Wait
Turn LED
OFF
Wait
Rinse &
Repeat
ARDUINO-DIGITAL OUTPUT-LED
89
BOARD SELECTION
COM PORT SELECTION
COMPILING AND UPLOADING CODE
CHALLENGES IN LED CONTROL
 Challenge 1A:
Blink LED Every one second
 Challenge 1B:
Multiple LEDs Blink once at a time
 Challenge 1C:
Multiple LEDs- Knight Riders Style
 Challenge 1D:
Color Brightness control using PWM function
 Challenge 1E:
Color Brightness control using potentiometer
 Challenge 1F:
Arduino-Analog Output LED Dimming Using for Loop
Structure
1B. MULTIPLE LEDS CONNECTION
 LED1: Arduino pin2
 LED2: Arduino pin3
 LED3: Arduino pin4
 All LEDs Gnd- Connected with
Arduino Ground
MULTIPLE LEDs CONNECTION
1B. MULTIPLE LED BLINKING AT A TIME
1C. LEDS KNIGHT RIDERS STYLE
1D.BRIGHTNESS CONTROL USING analogWrite()
1E.Color Brightness control using
potentiometer
1F. LED DIMMING USING FOR LOOP STRUCTURE
100
Arduino board program for Mobile robotss
IF CONDITION
IF CONDITION LOGIC
Push button working principle
LED CONTROLLED BY PUSH BUTTON
 Switch output connected with Arduino pin2
 Led pin connected with Arduino pin 6
PUSH BUTTON FUNCTION
SWITCH IN OPEN SWITCH IN CLOSED
If switch ON- circuit is closed, current will flow in the circuit
path. So input voltage is 5V.
Else switch OFF- circuit is open, no current flow in this path, so
input current 0V.
PROGRAM FOR PUSH BUTTON CONTROL
2. CHALLENGES
CHALLENGE 2A:
LED ON When press any One push button at a time
CHALLENGE 2B:
LED ON when press all push button at a time
CHALLENGE 2C:
LED ON when press at least 2 push button at a time
in 4 push buttons using application
CHALLENGE 2D:
LED ON when press at least 3 push button at a time
in 4 push buttons using application
2. MULTIPLE SWICH FUNCTION
3. SERIAL MONITOR
CONFIGURE BAUD RATE
 Serial. begin (baud rate)
 Some Examples Baud rate
4800,9600,14400,19200,28800,
38400,5760 and 115200 etc
 AnalogRead Value is 0 to 1023
WATCHING OUTPUT AT SERIAL
MONITOR
 Serial.println();
SERIAL MONITOR TEST PROGRAM
OPEN UP SERIAL MONITOR
JOYSTICK DEVELOPMENT
LEFT UP DOWN RIGHT
Display:
RIGHT
LEFT
UP
DOWN
Program:
#include <SoftwareSerial.h>
char a=2,b=3,c=4,d=5;
void setup(void)
{
pinMode(a, INPUT);
digitalWrite(a, HIGH);
pinMode(b, INPUT);
digitalWrite(b, HIGH);
pinMode(c, INPUT);
digitalWrite(c, HIGH);
pinMode(d, INPUT);
digitalWrite(d, HIGH);
Serial.begin(9600);
}
void loop(void)
{
if (digitalRead(a)==LOW)
{
Serial.println("LEFT");
delay(20);
}
else if
(digitalRead(b)==LOW)
{
Serial.println("RIGHT");
delay(20);
}
else if
(digitalRead(c)==LOW)
{
Serial.println("UP");
delay(20); }
else if
(digitalRead(d)==LOW)
{
Serial.println("DOWN");
delay(20); }
else
{
Serial.println("");
delay(20); }
}
LED BRIGHTNESS CONTROLLED FROM
POTENTIOMETER
PROGRAM FOR LED BRIGHTNESS CONTROL
LED BRIGHT:
int pot = A0; // pin that the sensor is attached to pot
int LED=9;
void setup()
{
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int analogValue = analogRead(pot)/4;
analogWrite(LED, analogValue);
Serial.println(analogValue);
delay(100);
}
LED ON/OFF CONTROLLED WITH RESPECT TO
COMPARISON OF THRESHOLD
Led on/off controlled with respect to comparison
of threshold and analog value from potentiometer
PROGRAM
5.Potentiometr Voltage -Voltage Display
Analog Read value is 0-1023
Divisions (0-5V)
1 Division= 5/ 1023 V= 0.00488 V
Formula:
int POT= analogRead(A0);
int Voltage = POT X 0.0049
HOME MADE AUTOMATION
 If push button is pressed at once- Automatically
electrical fans and lights will ON
If again press the same push button
Automatically electrical fans and lights will OFF
Experiments: LED will ON/ OFF based on this condition
Relay Board
Relay Application
CIRCUIT
int inPin = 2; // the number of the input pin
int outPin = 6; // the number of the output pin
int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers
void setup()
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
}
void loop()
{
reading = digitalRead(inPin);
if (reading == HIGH && previous == LOW && millis() - time > debounce)
{
if (state == HIGH)
state = LOW;
else
state = HIGH;
time = millis();
}
digitalWrite(outPin, state);
previous = reading;
}
Interrupt Counting:
volatile unsigned int L=1;
volatile double Le,Re;
void setup()
{
attachInterrupt(0, countpulsesL, FALLING);
Serial.begin(9600);
}
void loop()
{
Serial.println(L);
delay(1000);
}
void countpulsesL()
{
L++;
}
MOTOR CONTROL AND SENSORS INTERFACING
SESSION V & VI
OVERVIEW
Introduction about Sensors
Introduction about Motors
Motor control
Ultrasonic Sensor Testing
IR array sensor Testing
Motor speed control based on Sensors value
INTRODUCTION ABOUT SENSORS
 Sensor
 Types of sensors
IR sensor
Sound sensor
Temperature
sensor
 How to use it?
 Where to use it?
WHAT IS A SENSOR.?
A sensor is a device that measures a physical quantity and
converts it into a signal which can be read by an observer or
by an instrument
 Sensors are used in everyday objects such as touch-sensitive
elevator buttons (tactile sensor) and lamps which dim or
brighten by touching the base
 Applications include cars, machines, aerospace, medicine,
manufacturing and robotics
IR SENSOR
WORKING
 IR sensor works on the principle of emitting IR
rays and receiving the reflected ray by a receiver
(Photo Diode)
 IR source (LED) is used in forward bias
 IR Receiver (Photodiode) is used in bias
IR SENSOR CIRCUIT
VOLTAGE COMPARATOR
 A Comparator is a device which compares two voltages or
currents and switches its output to indicate which is larger.
 Comparator is an Op-amp.
PIN DIAGRAM LM 358
LIGHT SENSOR
CIRCUIT
TEMPERATURE SENSOR
TIMER 555 IC
The 555 Timer IC is an integrated circuit (chip)
implementing a variety of timer and multivibrator
applications.
PIN DIAGRAM
Solar Cell
Digital Infrared Ranging
Compass
Touch Switch
Pressure Switch
Limit Switch
Magnetic Reed Switch
Magnetic Sensor
Miniature Polaroid Sensor
Polaroid Sensor Board
Piezo Ultrasonic Transducers
Pyroelectric Detector
Thyristor
Gas Sensor
Gieger-Muller
Radiation Sensor
Piezo Bend Sensor
Resistive Bend Sensors
Mechanical Tilt Sensors
Pendulum Resistive
Tilt Sensors
CDS Cell
Resistive Light Sensor
Hall Effect
Magnetic Field
Sensors
Compass
IRDA Transceiver
IR Amplifier Sensor
IR Modulator
Receiver
Lite-On IR
Remote Receiver
Radio Shack
Remote Receiver
IR Sensor w/lens
Gyro
Accelerometer
IR Reflection
Sensor
IR Pin
Diode
UV Detector
Metal Detector
A motor is any of a class of rotary electrical motors that
converts electrical energy into mechanical energy. The most
common types rely on the forces produced by magnetic fields.
INTRODUCTION ABOUT MOTOR
16/11/2021 PSG College of Technology
TYPES OF MOTORS
 AC motors
 DC motors
 DC geared motors
 Stepper motors
 Servo motors
16/11/2021 PSG College of Technology
AC MOTOR
 These are the motors which convert
alternating signal into rotational motion.
 Examples are the motor in water pumps,
table fan, ceiling fan.
16/11/2021 PSG College of Technology
DC MOTOR
 These are the motors which convert DC
signals into rotational motion
 In robotics applications they are preferred over
AC motors as the motor and the complete
circuit require same kind of supply i.e DC
supply
16/11/2021 PSG College of Technology
DC GEARED MOTORS
 These are the DC geared motors having external gear
arrangement attached with motor.
 These are the motors that are most commonly used in
robotics as they are having considerable torque.
16/11/2021 PSG College of Technology
16/11/2021 PSG College of Technology
STEPPER MOTOR
A type of motor which
takes DC pulse input and
gives rotating motion in
steps.
They are of two types :
Unipolar : which moves
in one direction only.
Bipolar : which moves in
both directions
Arduino board program for Mobile robotss
16/11/2021 PSG College of Technology
16/11/2021 PSG College of Technology
 Servo motors are the most powerful motors for
robotic applications.
 They comes in both variants , AC and DC.
 They can change the direction with same
supply.
16/11/2021 PSG College of Technology
 A servomechanism, or servo is an automatic device that
uses error-sensing feedback to correct the performance of
a mechanism
 The term correctly applies only to systems where the
feedback or error-correction signals help control
mechanical position or other parameters
 For both way motion ( clockwise and anticlockwise ) of one DC motor, an
H-Bridge can be employed.
 For both way motion of two DC motors
dual H-Bridge IC L293D can be employed.
16/11/2021 PSG College of Technology
S1-S4 ON, S2-S3 OFF (for one direction).
S2-s3 on and s1-s4 off (for other
direction).
ONLY POSSIBLE SWITCHES SETTING FOR ROTATION
16/11/2021 PSG College of Technology
16/11/2021 PSG College of Technology
MOTOR DRIVER CONCEPT
L293D DRIVER BOARD
L293D DRIVER IC
MOTOR CONTROL
MOTOR SPEED CONTROL
DC MOTOR SPEED CONTROL BY USING
POTENTIOMETER
TASK EXPLANATION:
1. Speed Control by Potentiometer
2. Direction change when potentiometer value move less than
500
MOTOR CIRCUIT CONNECTION
PROGRAMMING FOR SPEED CONTROL
PROGRAM FOR DIRECTION CONTROL
LINE ARRAY SENSOR CONNECTION
5V- Arduino 5V
GND  Arduino Gnd
S1- Arduino A3
S2- Arduino A2
S3- Arduino A1
ARRAY SENSOR VALUE
ULTRASONIC SENSOR
Measurement Principle of Ultrasonic Sensor
Ultrasonic sensors transmit ultrasonic waves from its
sensor head and again receives the ultrasonic waves
reflected from an object. By measuring the length of time
from the transmission to reception of the sonic wave, it
detects the position of the object.
CONNECTION DETAILS
Vcc- Arduino 5V
Trig-Arduino 12
Echo- Arduino 13
GND- Ardunio Gnd
OBSTACLE DISTANCE PROGRAM
RC Servo Motor
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup()
{ myservo.attach(9);}
void loop()
{
for(pos = 0; pos <= 180; pos += 1)
{
myservo.write(pos);
delay(15);}
for(pos = 180; pos>=0; pos-=1)
{
myservo.write(pos);
delay(15);
}
}
Servo Motor Loop Function
Potentiometer Control Servo Position
#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
void setup()
{ myservo.attach(9); }
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
delay(15); }
LCD DISPLAY
Arduino board program for Mobile robotss
LCD PROGRAM
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
lcd.print(" I AM NOT A ROBOT");
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
}
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
lcd.print(ROBOTICS");
}
void loop()
{
lcd.noDisplay();
delay(500);
lcd.display();
delay(500);
}
I2C Communication
Program
#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
}
void loop() {
Wire.requestFrom(8, 6);
while (Wire.available()) {
char c = Wire.read();
Serial.print(c);
}
delay(500);
}
#include <Wire.h>
void setup()
{
Wire.begin(8);
Wire.onRequest(requestEvent);
}
void loop()
{
delay(100);
}
void requestEvent()
{
Wire.write("hello ");
}
Receiver Sender
Master Sender
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop() {
Wire.beginTransmission(8); // transmit to device #8
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}
Slave Receiver
#include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() {
delay(100);
}
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); }
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
Arduino board program for Mobile robotss
MOBILE ROBOT DESIGN
SESSION VI
OBSTACLE AVOIDING ROBOT DESIGN
REQUIRING COMPONENTS
 Arduino board
 Motors
 Wheels
 L293d Driver Board
 Battery
 Connecting wires
 Screws
 Screw driver
 Ultrasonic sensor
 Robot chassis
 Robot assemble instruction file
 Arduino IDE
CONCEPT
 Every second check the obstacle and take decision
 If robot meet obstacle in its path when it turn right
or left.
Arduino board program for Mobile robotss
LINE FOLLOWER ROBOT DESIGN
REQUIRING COMPONENTS
Arduino board
Motors
Wheels
L293d Driver Board
Battery
Connecting wires
Screws
Screw driver
Line array sensor
Robot chassis
Robot assemble instruction file
Arduino IDE
Arduino board program for Mobile robotss
Arduino board program for Mobile robotss
CHECK YOUR COMPONENTS BOX
Arduino board USB cable
L293 driver board Battery
LIST OF COMPONENTS
Dc motor Line array sensor
Potentiometer
Ultrasonic sensor adapter
CHECK YOUR COMPONENTS
Arduino board USB cable
L293 driver board Battery
CHECK YOUR COMPONENTS
Connecting wires Ultrasonic sensor
LEDs
Resisters
Reset button/switch
AND FUNCTION (&&)
INPUT 1 INPUT 2 OUTPUT
0 0 0
0 1 0
1 0 0
1 1 1
INPUT 1 INPUT 2 OUTPUT
0 0 0
0 1 1
1 0 1
1 1 1
OR FUNCTION (||)

More Related Content

Similar to Arduino board program for Mobile robotss (20)

Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
Jeni Shah
Arduino . .
Arduino             .                             .Arduino             .                             .
Arduino . .
dryazhinians
Arduino 悋惘惆
Arduino 悋惘惆Arduino 悋惘惆
Arduino 悋惘惆
salih mahmod
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
Rahat Sood
Arduino 際際滷s With Neopixels
Arduino 際際滷s With NeopixelsArduino 際際滷s With Neopixels
Arduino 際際滷s With Neopixels
sdcharle
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
2009 11-17-arduino-basics
2009 11-17-arduino-basics2009 11-17-arduino-basics
2009 11-17-arduino-basics
Jhonny Wladimir Pe単aloza Cabello
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
Introduction to Arduino - Basics programming
Introduction to Arduino - Basics programmingIntroduction to Arduino - Basics programming
Introduction to Arduino - Basics programming
KishoreKumarKAsstPro
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
arduino.ppt
arduino.pptarduino.ppt
arduino.ppt
sunilkumar652338
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
Arduino Workshop 際際滷s
Arduino Workshop 際際滷sArduino Workshop 際際滷s
Arduino Workshop 際際滷s
mkarlin14
Arduino: Arduino starter kit
Arduino: Arduino starter kitArduino: Arduino starter kit
Arduino: Arduino starter kit
SANTIAGO PABLO ALBERTO
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
Syed Mustafa
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
Qtechknow
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
Ravikumar Tiwari
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
Jeni Shah
Arduino 悋惘惆
Arduino 悋惘惆Arduino 悋惘惆
Arduino 悋惘惆
salih mahmod
Basics of arduino uno
Basics of arduino unoBasics of arduino uno
Basics of arduino uno
Rahat Sood
Arduino 際際滷s With Neopixels
Arduino 際際滷s With NeopixelsArduino 際際滷s With Neopixels
Arduino 際際滷s With Neopixels
sdcharle
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt01 Intro to the Arduino and it's basics.ppt
01 Intro to the Arduino and it's basics.ppt
pindi2197
Introduction to Arduino - Basics programming
Introduction to Arduino - Basics programmingIntroduction to Arduino - Basics programming
Introduction to Arduino - Basics programming
KishoreKumarKAsstPro
teststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptxteststststststLecture_3_2022_Arduino.pptx
teststststststLecture_3_2022_Arduino.pptx
ethannguyen1618
Arduino slides
Arduino slidesArduino slides
Arduino slides
sdcharle
Arduino Workshop 際際滷s
Arduino Workshop 際際滷sArduino Workshop 際際滷s
Arduino Workshop 際際滷s
mkarlin14
Syed IoT - module 5
Syed  IoT - module 5Syed  IoT - module 5
Syed IoT - module 5
Syed Mustafa
Intro to Arduino
Intro to ArduinoIntro to Arduino
Intro to Arduino
Qtechknow
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
Tony Olsson.
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
Sarwan Singh

Recently uploaded (20)

SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
yadavchandan322
Shallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdfShallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdf
DUSABEMARIYA
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptxUHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
ariomthermal2031
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario
Distillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptxDistillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptx
mrcr123
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Machine Elements in Mechanical Design.pdf
Machine Elements in Mechanical Design.pdfMachine Elements in Mechanical Design.pdf
Machine Elements in Mechanical Design.pdf
SLatorreAndrs
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptxUHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
ariomthermal2031
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal buildingAirport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Priyanka Dange
CNC Technology Unit-1 for IV Year 24-25 MECH
CNC Technology Unit-1 for IV Year 24-25 MECHCNC Technology Unit-1 for IV Year 24-25 MECH
CNC Technology Unit-1 for IV Year 24-25 MECH
C Sai Kiran
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Ignacio J. J. Palma Carazo
GDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptxGDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptx
Aditi330605
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf02.BigDataAnalytics curso de Legsi (1).pdf
02.BigDataAnalytics curso de Legsi (1).pdf
ruioliveira1921
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
PROJECT REPORT ON PASTA MACHINE - KP AUTOMATIONS - PASTA MAKING MACHINE PROJE...
yadavchandan322
Shallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdfShallow base metal exploration in northern New Brunswick.pdf
Shallow base metal exploration in northern New Brunswick.pdf
DUSABEMARIYA
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptxUHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
ariomthermal2031
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario
Distillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptxDistillation Types & It's Applications 1-Mar-2025.pptx
Distillation Types & It's Applications 1-Mar-2025.pptx
mrcr123
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Machine Elements in Mechanical Design.pdf
Machine Elements in Mechanical Design.pdfMachine Elements in Mechanical Design.pdf
Machine Elements in Mechanical Design.pdf
SLatorreAndrs
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By FlukeNFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
NFPA 70B & 70E Changes and Additions Webinar Presented By Fluke
Transcat
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptxUHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
UHV unit-2UNIT - II HARMONY IN THE HUMAN BEING.pptx
ariomthermal2031
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal buildingAirport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Airport Components Part2 ppt.pptx-Apron,Hangers,Terminal building
Priyanka Dange
CNC Technology Unit-1 for IV Year 24-25 MECH
CNC Technology Unit-1 for IV Year 24-25 MECHCNC Technology Unit-1 for IV Year 24-25 MECH
CNC Technology Unit-1 for IV Year 24-25 MECH
C Sai Kiran
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Analysis of Daylighting in Interior Spaces using the Daylight Factor - A Manu...
Ignacio J. J. Palma Carazo
GDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptxGDGoC Artificial Intelligence Workshop.pptx
GDGoC Artificial Intelligence Workshop.pptx
Aditi330605
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptxUHV UNIT-I INTRODUCTION TO VALUE EDUCATION  .pptx
UHV UNIT-I INTRODUCTION TO VALUE EDUCATION .pptx
ariomthermal2031

Arduino board program for Mobile robotss

  • 1. COIMBATORE 641 004 SESSION 1 PSG COLLEGE OF TECHNOLOGY 1 Selvaraj. K Project Engineer PSG-Robotics
  • 2. OVERVIEW Microcontroller Defined Arduino Defined Arduino Advantages Arduino Applications Types of Arduino Boards Analog, Digital, Inputs and Outputs
  • 3. MICROCONTROLLER Microcontroller Like as Brain It make decision in the Robots It collect the information from the Sensors and control the actuator by the command
  • 4. MICROCONTROLLER Microcontroller It is a Decision maker with help of ROM,RAM and Arithmetic Logic Unit. Input port- Eye(Sensor) Output Port- Mouth(Actuators or Speaker) All input and output ports are controlled by the programming
  • 5. MICROCONTROLLER Programmers work in the virtual world. Machinery works in the physical world. How does one connect the virtual world to the physical world? A microcontroller is basically a small-scale computer with generalized (and programmable) inputs and outputs. The inputs and outputs can be manipulated by and can manipulate the physical world
  • 6. INTRODUCTION ABOUT ARDUINO Based on a simple micro-controller board, and A development environment (IDE) for writing software for the board Open source electronics prototyping platform based on flexible ,Easy to use hardware and software Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be stand-alone, or they can be communicate with software running on your computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled; the open-source IDE can be downloaded for free. The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment.
  • 7. MAIN ADVANTAGES OF ARDUINO Arduino microcontrollers have become the de facto standard. Make Magazine features many projects using Arduino microcontrollers. Strives for the balance between ease of use and usefulness. Programming languages seen as major obstacle. Arduino C is a greatly simplified version of C++. Unit price around Rs.1400
  • 8. APPLICATION AREAS Light control Motor control Automation Robotics Networking Custom protocols Your imagination is the limit
  • 9. TYPES OF ARDUINO BOARDS Many different versions Number of input/output channels Form factor Processor Leonardo Due Micro LilyPad Esplora Uno Mega
  • 10. LEONARDO Compared to the Uno, a slight upgrade Built in USB compatibility
  • 11. DUE Much faster processor, many more pins Operates on 3.3 volts Similar to the Mega
  • 12. MICRO When size matters: Micro, Nano, Mini Includes all functionality of the Leonardo Easily usable on a breadboard
  • 13. LILYPAD LilyPad is popular for clothing-based projects. It is a Low weight and flexible
  • 14. ESPLORA Game controller Includes joystick, four buttons, linear potentiometer (slider), microphone, light sensor, temperature sensor, three-axis accelerometer. Not the standard set of IO pins.
  • 15. MEGA Compared to the Uno, the Mega: Many more communication pins More memory
  • 16. ARDUINO MEGA Physically larger than all the other boards Offers significantly more digital and analog pins. Uses a different processor allowing greater program size Microcontroller: ATmega1280 Operating Voltage 5V Input Voltage: 7-12V Digital I/O Pins 54 (of which 14 provide PWM output)
  • 17. ARDUINO MEGA Analog Input Pins 16 Flash Memory 128 KB of which 4 KB used by boot loader SRAM 8 KB EEPROM 4 KB Clock Speed 16 MHZ
  • 18. ARDUINO UNO The pins are in three groups: Invented in 2010 14 digital pins 6 analog pins power
  • 19. ARDUINO UNO Microcontroller ATmega 328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V Digital I/O Pins 14 (of which 6 provide PWM output) Analog Input Pins 6 DC Current per I/O Pin 40 mA DC Current for 3.3V Pin 50 mA Flash Memory 32 KB (of which 0.5 KB used by boot loader) SRAM 2 KB (ATmega328) EEPROM 1 KB (ATmega328) Clock Speed 16 MHz
  • 20. Totally Arduino Uno have 14 Digital Input and Output pins. They are numbered 0 to 13. Analog Input Pins are A0 to A5
  • 22. UNDERSTANDING INPUT VS OUTPUT INPUT PIN Inputs is a signal / information going into the board. OUTPUT PIN Output is any signal exiting the board.
  • 23. ANALOG VS DIGITAL ANALOG Microcontrollers are digital devices ON or OFF DIGITAL An Analog signal is anything that can be a full range of values. What are some examples? Think of like a ramp or a hill.
  • 24. INPUT and OUTPUT 1. analogRead-Analog INPUT 2. analogWrite-Analog OUTPUT 3. digitalRead- digital INPUT 4. digitalWrite- digital OUTPUT
  • 25. BASIC KNOWLEDGE REQUIRED Ohms LAW Current Voltage Resister Capacitor Inductor Voltage LAW Current Law Rheostat function Transformer Rectifier Regulator Inverter Amplifier Diode Transistor AC and DC Voltages Types of Motors Basic sensors
  • 26. PULL UP RESISTER PULL DOWN RESISTER
  • 27. ANALOG VS DIGITAL To create an analog signal, the microcontroller uses a technique called PWM. Pins 3, 5, 6, 9, 10, 11 are capable of producing an Analog Output Pulse Width Modulation (PWM)
  • 29. OVERVIEW Objectives Startup Arduino IDE Arduino Sketch Details Commands ,Operators, Variables Basic Repetitions Settings and Configurations
  • 30. OBJECTIVES Provide a thorough introduction to the Arduino programming environment. Develop a use of simple functions to interact with the LEDs, light sensor, push button, and buzzer on the Protosnap Pro Mini.
  • 31. STARTUPARDUINO IDE Double-click on either the Arduino Icon or wherever you installed (saved) the Arduino program.
  • 34. PARTS OF THE SKETCH
  • 35. COMMENTS Comments can be anywhere Comments created with // or /* and */ Comments do not affect code You may not need comments, but think about the community.
  • 36. OPERATORS The equals sign = is used to assign a value == is used to compare values And & Or && is and || is or
  • 38. DECLARING VARIABLES Boolean: boolean variableName; Integer: int variableName; Character: char variableName; String: stringName [ ];
  • 39. ASSIGNING VARIABLES Boolean: variableName = true; or variableName = false; Integer: variableName = 32767; or variableName = -32768;
  • 40. VARIABLE SCOPE Where you declare your variables matters?
  • 41. SETUP void setup ( ) { } The setup function comes before the loop function and is necessary for all Arduino sketches
  • 42. SETUP void setup ( ) { } The setup header will never change, everything else that occurs in setup happens inside the curly brackets
  • 43. SETUP void setup ( ) { pinMode (13, OUTPUT); } Outputs are declare in setup, this is done by using the pinMode function This particular example declares digital pin # 13 as an output, remember to use CAPS
  • 44. SETUP void setup ( ) { Serial.begin;} Serial communication also begins in setup This particular example declares Serial communication at a baud rate of 9600. More on Serial later...
  • 45. Setup, Internal Pullup Resistors void setup ( ) { digitalWrite (12, HIGH); } You can also create internal pullup resistors in setup, to do so digitalWrite the pin HIGH This takes the place of the pullup resistors currently on your circuit 7 buttons
  • 46. Setup, Interrupts void setup ( ) { attachInterrupt (interrupt, function, mode) } You can designate an interrupt function to Arduino pins # 2 and 3 volatile unsigned int L=1; volatile double Le,Re; void setup() { attachInterrupt(0, countpulsesL, FALLING); Serial.begin(9600);} void loop() { Serial.println(L); delay(1000);} void countpulsesL() {L++;}
  • 47. Setup, Interrupts void setup ( ) { attachInterrupt (interrupt, function, mode) } Interrupt: the number of the interrupt, 0 or 1, corresponding to Arduino pins # 2 and 3 respectively Function: the function to call when the interrupt occurs Mode: defines when the interrupt should be triggered
  • 48. Setup, Interrupts void setup ( ) { attachInterrupt (interrupt, function, mode) } LOW whenever pin state is low CHANGE whenever pin changes value RISING whenever pin goes from low to high FALLING whenever pin goes from low to high Dont forget to CAPITALIZE
  • 49. Example program volatile unsigned int L=1; volatile double Le,Re; void setup() { attachInterrupt(0, countpulsesL, FALLING); Serial.begin(9600);} void loop() { Serial.println(L); delay(1000);} void countpulsesL() { L++;}
  • 50. If Statements if ( this is true ) { do this; }
  • 51. If If ( this is true ) { do this; }
  • 52. Conditional If ( this is true ) { do this; }
  • 53. Action if ( this is true ) { do this; }
  • 54. Else else { do this; }
  • 59. BASIC REPETITION for (int count = 0; count<10; count++) {//for action code goes here //this could be anything}
  • 60. BASIC REPETITION for (int count = 0; count<10; count++) { //for action code goes here }
  • 61. BASIC REPETITION for (int count = 0; count<10; count++) { //for action code goes here }
  • 62. BASIC REPETITION for (int count = 0; count<10; count++) { //for action code goes here }
  • 63. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 64. BASIC REPETITION for (int count = 0; count<10; count++) { //for action code goes here }
  • 65. Basic Repetition for (int count = 0; count<10; count++) { //for action code goes here }
  • 66. BASIC REPETITION while ( count<10 ) { //while action code goes here //should include a way to change count //variable so the computer is not stuck //inside the while loop forever }
  • 67. BASIC REPETITION while ( count<10 ) { //looks basically like a for loop //except the variable is declared before //and incremented inside the while //loop }
  • 69. CONFIGURING ARDUINO 1. Setup Board (Arduino UNO/ ATmega328) 2. Setup COM Port PC Highest COM #
  • 71. Settings: Tools Serial Port
  • 73. 5.- Verify/Compile 6.- Once it compiles, you must see the following messages in the Status bar and the Program notification Area
  • 74. 7. Upload it 8. Once it upload, you must see the following messages in the Status bar and the Program notification Area
  • 75. Error avrdude: stk500_getsync(): not in sync: resp=0x00 can't open device "COM10": The system cannot find the file specified
  • 77. CHALLENGES Introduction to use Electronic components LED Control by Arduino Multiple LEDs Control by looping Operators conditions test Analog sensor test Analog Sensor Value based LED control
  • 78. LIST OF COMPONENTS Arduino board USB cable L293 driver board Battery
  • 79. LIST OF COMPONENTS Dc motor Line array sensor Potentiometer Ultrasonic sensor adapter
  • 80. LIST OF COMPONENTS Connecting wires Ultrasonic sensor LEDs Resisters Reset button/switch
  • 81. ARDUINO PROGRAMMING INSTRUCTIONS pinMode(pin, mode) Designates the specified pin for input or output digitalWrite(pin, value) Sends a voltage level to the designated pin digitalRead(pin) Reads the current voltage level from the designated pin analog versions of above analogRead's range is 0 to 1023 serial commands print, println, write
  • 82. ARDUINO USING SOLDERLESSBREADBOARD Solderless Board is useful to build proto types. Time consuming process of soldering parts together to make connections Most important thing in using a solder less breadboard in understanding its connections wiring underneath the white cover to be able to connect parts in a way that complete and flawless lines are provided for electricity flow 82
  • 83. Instruction to Components handling 1. Doing circuit connection Dont power up Controller board 2. Dont use metal surface and maintain at free surface 3. Circuit check before power up 4. Dont make short circuit 5. After completion of Experiments- all components put in to box and cross check the list
  • 84. LED PROGRAMMING FOR BLINKING FUNCTIONS Turn LED ON Wait Turn LED OFF Wait Repeat
  • 86. DIGITAL OUTPUT-LED 86 Digital pin 10 connected with Resister. Long leg connected with resister end. short Leg connected with Ground. Ground Pin Digital Pin
  • 87. LED FUNCTION INSTRUCTIONS Connect the positive (+) lead of a power source to the long leg of an LED. Connect other leg of the LED to a resistor. High resistance means a darker light. Low resistance means brighter light. No resistance means to the negative lead of the power source. a burned out LED. Connect other leg of the resistor
  • 88. LED FUNCTION Turn LED ON Wait Turn LED OFF Wait Rinse & Repeat
  • 93. CHALLENGES IN LED CONTROL Challenge 1A: Blink LED Every one second Challenge 1B: Multiple LEDs Blink once at a time Challenge 1C: Multiple LEDs- Knight Riders Style Challenge 1D: Color Brightness control using PWM function Challenge 1E: Color Brightness control using potentiometer Challenge 1F: Arduino-Analog Output LED Dimming Using for Loop Structure
  • 94. 1B. MULTIPLE LEDS CONNECTION LED1: Arduino pin2 LED2: Arduino pin3 LED3: Arduino pin4 All LEDs Gnd- Connected with Arduino Ground
  • 96. 1B. MULTIPLE LED BLINKING AT A TIME
  • 97. 1C. LEDS KNIGHT RIDERS STYLE
  • 99. 1E.Color Brightness control using potentiometer
  • 100. 1F. LED DIMMING USING FOR LOOP STRUCTURE 100
  • 104. Push button working principle
  • 105. LED CONTROLLED BY PUSH BUTTON Switch output connected with Arduino pin2 Led pin connected with Arduino pin 6
  • 106. PUSH BUTTON FUNCTION SWITCH IN OPEN SWITCH IN CLOSED If switch ON- circuit is closed, current will flow in the circuit path. So input voltage is 5V. Else switch OFF- circuit is open, no current flow in this path, so input current 0V.
  • 107. PROGRAM FOR PUSH BUTTON CONTROL
  • 108. 2. CHALLENGES CHALLENGE 2A: LED ON When press any One push button at a time CHALLENGE 2B: LED ON when press all push button at a time CHALLENGE 2C: LED ON when press at least 2 push button at a time in 4 push buttons using application CHALLENGE 2D: LED ON when press at least 3 push button at a time in 4 push buttons using application
  • 109. 2. MULTIPLE SWICH FUNCTION
  • 110. 3. SERIAL MONITOR CONFIGURE BAUD RATE Serial. begin (baud rate) Some Examples Baud rate 4800,9600,14400,19200,28800, 38400,5760 and 115200 etc AnalogRead Value is 0 to 1023 WATCHING OUTPUT AT SERIAL MONITOR Serial.println();
  • 112. OPEN UP SERIAL MONITOR
  • 113. JOYSTICK DEVELOPMENT LEFT UP DOWN RIGHT Display: RIGHT LEFT UP DOWN
  • 114. Program: #include <SoftwareSerial.h> char a=2,b=3,c=4,d=5; void setup(void) { pinMode(a, INPUT); digitalWrite(a, HIGH); pinMode(b, INPUT); digitalWrite(b, HIGH); pinMode(c, INPUT); digitalWrite(c, HIGH); pinMode(d, INPUT); digitalWrite(d, HIGH); Serial.begin(9600); }
  • 115. void loop(void) { if (digitalRead(a)==LOW) { Serial.println("LEFT"); delay(20); } else if (digitalRead(b)==LOW) { Serial.println("RIGHT"); delay(20); } else if (digitalRead(c)==LOW) { Serial.println("UP"); delay(20); } else if (digitalRead(d)==LOW) { Serial.println("DOWN"); delay(20); } else { Serial.println(""); delay(20); } }
  • 116. LED BRIGHTNESS CONTROLLED FROM POTENTIOMETER
  • 117. PROGRAM FOR LED BRIGHTNESS CONTROL LED BRIGHT: int pot = A0; // pin that the sensor is attached to pot int LED=9; void setup() { pinMode(LED, OUTPUT); Serial.begin(9600); } void loop() { int analogValue = analogRead(pot)/4; analogWrite(LED, analogValue); Serial.println(analogValue); delay(100); }
  • 118. LED ON/OFF CONTROLLED WITH RESPECT TO COMPARISON OF THRESHOLD Led on/off controlled with respect to comparison of threshold and analog value from potentiometer
  • 120. 5.Potentiometr Voltage -Voltage Display Analog Read value is 0-1023 Divisions (0-5V) 1 Division= 5/ 1023 V= 0.00488 V Formula: int POT= analogRead(A0); int Voltage = POT X 0.0049
  • 121. HOME MADE AUTOMATION If push button is pressed at once- Automatically electrical fans and lights will ON If again press the same push button Automatically electrical fans and lights will OFF Experiments: LED will ON/ OFF based on this condition
  • 125. int inPin = 2; // the number of the input pin int outPin = 6; // the number of the output pin int state = HIGH; // the current state of the output pin int reading; // the current reading from the input pin int previous = LOW; // the previous reading from the input pin long time = 0; // the last time the output pin was toggled long debounce = 200; // the debounce time, increase if the output flickers void setup() { pinMode(inPin, INPUT); pinMode(outPin, OUTPUT); } void loop() { reading = digitalRead(inPin); if (reading == HIGH && previous == LOW && millis() - time > debounce) { if (state == HIGH) state = LOW; else state = HIGH; time = millis(); } digitalWrite(outPin, state); previous = reading; }
  • 126. Interrupt Counting: volatile unsigned int L=1; volatile double Le,Re; void setup() { attachInterrupt(0, countpulsesL, FALLING); Serial.begin(9600); } void loop() { Serial.println(L); delay(1000); } void countpulsesL() { L++; }
  • 127. MOTOR CONTROL AND SENSORS INTERFACING SESSION V & VI
  • 128. OVERVIEW Introduction about Sensors Introduction about Motors Motor control Ultrasonic Sensor Testing IR array sensor Testing Motor speed control based on Sensors value
  • 129. INTRODUCTION ABOUT SENSORS Sensor Types of sensors IR sensor Sound sensor Temperature sensor How to use it? Where to use it?
  • 130. WHAT IS A SENSOR.? A sensor is a device that measures a physical quantity and converts it into a signal which can be read by an observer or by an instrument Sensors are used in everyday objects such as touch-sensitive elevator buttons (tactile sensor) and lamps which dim or brighten by touching the base Applications include cars, machines, aerospace, medicine, manufacturing and robotics
  • 132. WORKING IR sensor works on the principle of emitting IR rays and receiving the reflected ray by a receiver (Photo Diode) IR source (LED) is used in forward bias IR Receiver (Photodiode) is used in bias
  • 134. VOLTAGE COMPARATOR A Comparator is a device which compares two voltages or currents and switches its output to indicate which is larger. Comparator is an Op-amp. PIN DIAGRAM LM 358
  • 137. TIMER 555 IC The 555 Timer IC is an integrated circuit (chip) implementing a variety of timer and multivibrator applications. PIN DIAGRAM
  • 138. Solar Cell Digital Infrared Ranging Compass Touch Switch Pressure Switch Limit Switch Magnetic Reed Switch Magnetic Sensor Miniature Polaroid Sensor Polaroid Sensor Board Piezo Ultrasonic Transducers Pyroelectric Detector Thyristor Gas Sensor Gieger-Muller Radiation Sensor Piezo Bend Sensor Resistive Bend Sensors Mechanical Tilt Sensors Pendulum Resistive Tilt Sensors CDS Cell Resistive Light Sensor Hall Effect Magnetic Field Sensors Compass IRDA Transceiver IR Amplifier Sensor IR Modulator Receiver Lite-On IR Remote Receiver Radio Shack Remote Receiver IR Sensor w/lens Gyro Accelerometer IR Reflection Sensor IR Pin Diode UV Detector Metal Detector
  • 139. A motor is any of a class of rotary electrical motors that converts electrical energy into mechanical energy. The most common types rely on the forces produced by magnetic fields. INTRODUCTION ABOUT MOTOR
  • 140. 16/11/2021 PSG College of Technology TYPES OF MOTORS AC motors DC motors DC geared motors Stepper motors Servo motors
  • 141. 16/11/2021 PSG College of Technology AC MOTOR These are the motors which convert alternating signal into rotational motion. Examples are the motor in water pumps, table fan, ceiling fan.
  • 142. 16/11/2021 PSG College of Technology DC MOTOR These are the motors which convert DC signals into rotational motion In robotics applications they are preferred over AC motors as the motor and the complete circuit require same kind of supply i.e DC supply
  • 143. 16/11/2021 PSG College of Technology DC GEARED MOTORS These are the DC geared motors having external gear arrangement attached with motor. These are the motors that are most commonly used in robotics as they are having considerable torque.
  • 144. 16/11/2021 PSG College of Technology
  • 145. 16/11/2021 PSG College of Technology STEPPER MOTOR A type of motor which takes DC pulse input and gives rotating motion in steps. They are of two types : Unipolar : which moves in one direction only. Bipolar : which moves in both directions
  • 147. 16/11/2021 PSG College of Technology
  • 148. 16/11/2021 PSG College of Technology Servo motors are the most powerful motors for robotic applications. They comes in both variants , AC and DC. They can change the direction with same supply.
  • 149. 16/11/2021 PSG College of Technology A servomechanism, or servo is an automatic device that uses error-sensing feedback to correct the performance of a mechanism The term correctly applies only to systems where the feedback or error-correction signals help control mechanical position or other parameters
  • 150. For both way motion ( clockwise and anticlockwise ) of one DC motor, an H-Bridge can be employed. For both way motion of two DC motors dual H-Bridge IC L293D can be employed. 16/11/2021 PSG College of Technology S1-S4 ON, S2-S3 OFF (for one direction). S2-s3 on and s1-s4 off (for other direction). ONLY POSSIBLE SWITCHES SETTING FOR ROTATION
  • 151. 16/11/2021 PSG College of Technology
  • 152. 16/11/2021 PSG College of Technology
  • 158. DC MOTOR SPEED CONTROL BY USING POTENTIOMETER TASK EXPLANATION: 1. Speed Control by Potentiometer 2. Direction change when potentiometer value move less than 500
  • 162. LINE ARRAY SENSOR CONNECTION 5V- Arduino 5V GND Arduino Gnd S1- Arduino A3 S2- Arduino A2 S3- Arduino A1
  • 164. ULTRASONIC SENSOR Measurement Principle of Ultrasonic Sensor Ultrasonic sensors transmit ultrasonic waves from its sensor head and again receives the ultrasonic waves reflected from an object. By measuring the length of time from the transmission to reception of the sonic wave, it detects the position of the object.
  • 165. CONNECTION DETAILS Vcc- Arduino 5V Trig-Arduino 12 Echo- Arduino 13 GND- Ardunio Gnd
  • 168. #include <Servo.h> Servo myservo; int pos = 0; void setup() { myservo.attach(9);} void loop() { for(pos = 0; pos <= 180; pos += 1) { myservo.write(pos); delay(15);} for(pos = 180; pos>=0; pos-=1) { myservo.write(pos); delay(15); } } Servo Motor Loop Function
  • 169. Potentiometer Control Servo Position #include <Servo.h> Servo myservo; int potpin = 0; int val; void setup() { myservo.attach(9); } void loop() { val = analogRead(potpin); val = map(val, 0, 1023, 0, 180); myservo.write(val); delay(15); }
  • 172. LCD PROGRAM #include <LiquidCrystal.h> LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { lcd.begin(16, 2); lcd.print(" I AM NOT A ROBOT"); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
  • 173. #include <LiquidCrystal.h> LiquidCrystal lcd(8, 9, 4, 5, 6, 7); void setup() { lcd.begin(16, 2); lcd.print(ROBOTICS"); } void loop() { lcd.noDisplay(); delay(500); lcd.display(); delay(500); }
  • 175. Program #include <Wire.h> void setup() { Wire.begin(); Serial.begin(9600); } void loop() { Wire.requestFrom(8, 6); while (Wire.available()) { char c = Wire.read(); Serial.print(c); } delay(500); } #include <Wire.h> void setup() { Wire.begin(8); Wire.onRequest(requestEvent); } void loop() { delay(100); } void requestEvent() { Wire.write("hello "); } Receiver Sender
  • 176. Master Sender #include <Wire.h> void setup() { Wire.begin(); // join i2c bus (address optional for master) } byte x = 0; void loop() { Wire.beginTransmission(8); // transmit to device #8 Wire.write("x is "); // sends five bytes Wire.write(x); // sends one byte Wire.endTransmission(); // stop transmitting x++; delay(500); }
  • 177. Slave Receiver #include <Wire.h> void setup() { Wire.begin(8); // join i2c bus with address #8 Wire.onReceive(receiveEvent); // register event Serial.begin(9600); // start serial for output } void loop() { delay(100); } void receiveEvent(int howMany) { while (1 < Wire.available()) { // loop through all but the last char c = Wire.read(); // receive byte as a character Serial.print(c); } int x = Wire.read(); // receive byte as an integer Serial.println(x); // print the integer }
  • 180. OBSTACLE AVOIDING ROBOT DESIGN REQUIRING COMPONENTS Arduino board Motors Wheels L293d Driver Board Battery Connecting wires Screws Screw driver Ultrasonic sensor Robot chassis Robot assemble instruction file Arduino IDE
  • 181. CONCEPT Every second check the obstacle and take decision If robot meet obstacle in its path when it turn right or left.
  • 184. REQUIRING COMPONENTS Arduino board Motors Wheels L293d Driver Board Battery Connecting wires Screws Screw driver Line array sensor Robot chassis Robot assemble instruction file Arduino IDE
  • 187. CHECK YOUR COMPONENTS BOX Arduino board USB cable L293 driver board Battery
  • 188. LIST OF COMPONENTS Dc motor Line array sensor Potentiometer Ultrasonic sensor adapter
  • 189. CHECK YOUR COMPONENTS Arduino board USB cable L293 driver board Battery
  • 190. CHECK YOUR COMPONENTS Connecting wires Ultrasonic sensor LEDs Resisters Reset button/switch
  • 191. AND FUNCTION (&&) INPUT 1 INPUT 2 OUTPUT 0 0 0 0 1 0 1 0 0 1 1 1 INPUT 1 INPUT 2 OUTPUT 0 0 0 0 1 1 1 0 1 1 1 1 OR FUNCTION (||)