Arduino Presentation
Arduino Presentation
SUMIT
HARIPRASAD
SHIVARAM K K
KEERTI M
AIM:
This Workshop aims to provide :
2.TinkerCad simulation
3.BATTERY
4.TWO DC MOTORS
5.JUMPER CABLES
7.WHEELS
8.SWITCH
L298N/293D - Motor Driver
● The L298N is a dual H-Bridge motor driver.
Case 1:
When all switches are open then no current goes to
the Motor terminals. So, in this condition, the motor is
stopped (not working).
Case 2:
When the switch S1 and S4 are closed. In this condition
motor start rotating in a particular direction (clockwise).
Case 3:
● microcontroller board that can be programmed to interact with the physical world
through various sensors
Arduino Types
LilyPad Arduino
The LilyPad Arduino is considered as other Arduino
board type that is designed for integrating with
wearable projects and e-textile projects. This board
comes in round shape that helps to decrease the
snagging and can be easily connected to other devices.
This board uses the Atmega328 microcontroller and
Arduino bootloader in it. This board uses very less
external component in it that makes the design easy
and compatible.
Arduino Types
Arduino Mega
This boards is considered as the microcontroller
that uses the Atmega2560 in it. There are total 54
input pins and output pins in it in which 14 pins
are of PWM output, 4 pins are of hardware port,
16 pins as analog inputs. The board also contain
one USB connection, ICSP header, power jack
and one REST pin. Used in home automation
appliances
Arduino Types
Arduino Leonardo
This board is considered as the microcontroller
that uses the Atmega32u4 in it. There are total 20
digital input pins and output pins in it, in that 7
pins are used As PWM and 12 pins used as
analog inputs. The board also contain one micro
USB connection, power jack, and one RESET
button fit in it. There are additional pins which act
as crystal oscillator of frequency 16 MHz. used in
making of keyboards, mouse, joystick and other
appliances.
Arduino Types
Arduino UNO
The development of Arduino UNO board is
considered as new compared to other Arduino
boards. This board comes up with numerous
features that helps the user to use this in their
project. The Arduino UNO uses the Atmega16U2
microcontroller that helps to increase the transfer
rate and contain large memory compared to other
boards. No extra devices are needed for the
Arduino UNO board like joystick, mouse,
keyboard and many more. The Arduino UNO
contain SCL and SDA pins and also have two
additional pins fit near to RESET pin.
Arduino Shields
● Allows you to easily control motor direction and speed using an Arduino
● By allowing you to simply address Arduino pins, it makes it very simple to incorporate a
motor into your project
● allows you to be able to power a motor with a separate power supply of up to 12v.
Arduino UNO pin diagram
Obstacle detection pin diagram
CODING IN ARDUINO
1. IDE - The Arduino software (IDE) is open-source software.
2. Code online or download it for your PC.
CODING IN ARDUINO
Low : 0 volt
delay (time)
Time must be in milli-seconds
analogWrite(pin, value)
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
const int trigPin1 = 11; //sends waves
const int in3 = 4; //rm1
pinMode(echoPin3, INPUT); }
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
void loop() {
if ( FrontSensor() < DIS && RightSensor () <DIS && LeftSensor ()<DIS) // obstacle in front of all 3 sides
{
turn_right ();
delay(3000);
else if (FrontSensor() <DIS && RightSensor () <DIS && LeftSensor ()>DIS) // obstacle on right and front sides
turn_left ();
delay(3000);
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
else if (FrontSensor() <DIS && RightSensor () >DIS && LeftSensor() < DIS) // obstacle on left and front sides {
turn_right ();
delay(3000);
else if (FrontSensor() <DIS && RightSensor () >DIS && LeftSensor ()>DIS) //obstacle on front sides
turn_right ();
delay(3000);}
else if (FrontSensor() >DIS && RightSensor () >DIS && LeftSensor ()<DIS) // obstacle on left sides
turn_right ();
delay(3000);
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
else if (FrontSensor() >DIS && RightSensor () <DIS && LeftSensor()>DIS) // obstacle on right sides
turn_left ();
delay(3000);
else{
forward();
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
void forward (){ void turn_right ()
digitalWrite(in1, HIGH); //dir1 {
digitalWrite(in2, LOW); //dir2 digitalWrite(in1, LOW);
digitalWrite(in3, HIGH); digitalWrite(in2, HIGH);
digitalWrite(in4, LOW); digitalWrite(in3, HIGH);
analogWrite(enA, PWM); //speed digitalWrite(in4, LOW);
analogWrite(enB, PWM); analogWrite(enA, PWM);
} analogWrite(enB, PWM);
void turn_left (){
digitalWrite(in1, HIGH); }
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enA, PWM);
analogWrite(enB, PWM);
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
long FrontSensor ()
{
long dur;
digitalWrite(trigPin1, LOW); // dont send signal
delayMicroseconds(5);
digitalWrite(trigPin1, HIGH); // send UltraSonic signal
delayMicroseconds(10);
digitalWrite(trigPin1, LOW); // stop sending US
dur = pulseIn(echoPin1, HIGH); // returns duration
return (dur/60); // convert the time to dist
}
long RightSensor ()
{
long dur;
digitalWrite(trigPin2, LOW);
delayMicroseconds(5);
digitalWrite(trigPin2, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin2, LOW);
dur = pulseIn(echoPin2, HIGH);
return (dur/60);
}
CODING IN ARDUINO - OBSTACLE AVOIDANCE ROBOT
long LeftSensor ()
{
long dur;
digitalWrite(trigPin3, LOW);
delayMicroseconds(5);
digitalWrite(trigPin3, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin3, LOW);
dur = pulseIn(echoPin3, HIGH);
return (dur/60); // convert the distance to centimeters.
}
Explanation for movement
1. digitalWrite(in1, HIGH);: This sets the in1 pin to HIGH, which means the corresponding terminal of the motor driver is connected
to the positive terminal of the battery.
2. digitalWrite(in2, LOW);: This sets the in2 pin to LOW, which means the corresponding terminal of the motor driver is connected
to the negative terminal of the battery.
3. digitalWrite(in3, HIGH);: This sets the in3 pin to HIGH, which means the corresponding terminal of the second motor driver is
connected to the positive terminal of the battery. This causes the second motor to rotate in the same direction as the first motor.
4. digitalWrite(in4, LOW);: This sets the in4 pin to LOW, which means the corresponding terminal of the second motor driver is
connected to the negative terminal of the battery. This completes the circuit and allows the second motor to rotate in the same
direction as the first motor.
5. analogWrite(enA, PWM);: This sets the enA pin to a specific pulse width modulation (PWM) value, which controls the speed of
the first motor. The higher the PWM value, the faster the motor will spin.
6. analogWrite(enB, PWM);: This sets the enB pin to the same PWM value as enA, which controls the speed of the second motor.
Time For Some Hands on
Experience
LED + UltraSonic code : https://github.com/Shivaram35144/IEEERAS
Connections : https://www.tinkercad.com/things/18js3FMGefD