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

Robotics Note

1) An Arduino is a microcontroller that can be programmed to process inputs and outputs to control external components. It can send and receive data from sensors, websites, and other devices. 2) The document discusses several robotics and IoT projects that use an Arduino board, including a laser trip wire alarm, motion sensor alarm, and smart gate that controls servomotors. 3) The projects cover how to connect sensors like photoresistors and PIR motion sensors to the Arduino, and how to output signals to devices like LEDs, buzzers, and servomotors. Code examples are provided to read sensor values and control the outputs.

Uploaded by

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

Robotics Note

1) An Arduino is a microcontroller that can be programmed to process inputs and outputs to control external components. It can send and receive data from sensors, websites, and other devices. 2) The document discusses several robotics and IoT projects that use an Arduino board, including a laser trip wire alarm, motion sensor alarm, and smart gate that controls servomotors. 3) The projects cover how to connect sensors like photoresistors and PIR motion sensors to the Arduino, and how to output signals to devices like LEDs, buzzers, and servomotors. Code examples are provided to read sensor values and control the outputs.

Uploaded by

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

ROBOTICS PROJECTS

What Exactly is an Arduino?


An Arduino is a single-board microcontroller and a software suite for programming it. The hardware consists
of a simple open hardware design for the controller with an Atmel AVR processor and on-board I/O support.
The software consists of a standard programming language and the boot loader that runs on the board.”
To put that in layman’s terms, an Arduino is a tiny computer that you can program to process inputs and outputs
between the device and external components you connect to it.
The Arduino can be used to develop stand-alone interactive objects or it can be connected to a
computer, a network, or the Internet to retrieve and send data to and from the Arduino and then process it.
In other words, it can send a set of data received from some sensors to a website, which can then be
displayed in the form of a graph. The Arduino can be connected to LEDs, buttons, switches,
motors, temperature sensors, pressure sensors, distance sensors, GPS receivers, Ethernet modules, or just about
anything that outputs data or can be controlled. A look around the Internet will bring up a wealth of projects
where an Arduino has been used to read data from or control an amazing array of devices.

Exploring the Arduino Board

you can see a photo of an Arduino Uno board and its most important parts. I’ll explain them one by one.
Let’s start with the USB connector. To connect an Arduino to your computer, you just need an USB cable. Then
you can use the USB connection for various purposes:
• Upload new software to the board.
• Communicate with the Arduino board and your computer.
• Supply the Arduino board with power.
To supply power to the Arduino, the USB port only delivers 5 volts, and sometimes you need more therefore,
in these situations, the best solution usually is an AC adapter supplying 9 volts (the recommended range is
7V to 12V). you can also power the Arduino with 9V batteries.
Now you know two ways to supply the Arduino with power. But the Arduino isn’t greedy and happily shares
its power with other devices. At the bottom of Figure 1.2, on the preceding page, you can see several sockets
(sometimes I’ll also call them pins, because internally they are connected to pins in the microcontroller) related
to power supply:
• Using the pins labeled 3.3V and 5V, you can power external devices connected to the Arduino with
3.3 volts or 5 volts.
• Two ground pins labeled Gnd allow your external devices to share a common ground with the Arduino.
• Some projects need to be portable, so they’ll use a portable power supply such as batteries. You
connect an external power source such as a battery pack to the Vin and Gnd sockets. If you connect
an AC adapter to the Arduino’s power jack, you can supply the adapter’s voltage through this pin.

On the lower right of the board, you see six analog input pins named A0–A5. You can use them to
connect analog sensors to the Arduino. They take sensor data and convert it into a number between
0 and 1023.
At the board’s top are 14 digital IO pins named D0–D13. Depending on your needs, you can use
these pins for both digital input and output, so you can read the state of a pushbutton or switch to
turn on and off an LED.

Installing the Arduino IDE


To make it as easy as possible to get started with the Arduino, the Arduino developers have created a
simple but useful integrated development environment (IDE). It runs on many different operating systems.
Before you can create your first projects, you have to install it.

1. OUR FIRST PROJECT


In our first little project, we’ll make the Arduino’s status LED blink. The status LED is connected to digital
IO pin 13. Digital pins act as a kind of switch and can be in one of two states: HIGH or LOW. If set to
HIGH, the output pin is set to 5 volts, causing a current to flow through the LED, so it lights up. If it’s set
back to LOW, the current flow stops, and the LED turns off. You do not need to know exactly how
electricity works at the moment,
Let’s see how this works and dissect the program’s source code piece by piece. In the first two lines we define
two int constants using the const keyword. LED_PIN refers to the number of the digital IO pin we’re using,
and PAUSE defines the length of the blink period in milliseconds. Every Arduino program needs a function
named setup (), and ours starts in line 4. A function definition always adheres to the following scheme:’ (’’)’
In our case the function’s name is setup (), and its return value type is void: it returns nothing. setup () doesn’t
expect any arguments, so we left the parameter list empty.

PROJECTSS

2. Laser Trip Wire Alarm


PARTS REQUIRED
• Arduino board • Breadboard • Jumper wires • Photoresistor • Piezo buzzer • Green LED • 10k-ohm resistor
• Laser pen
HOW IT WORKS
When the laser pen shines on the photoresistor, the green LED will light up to signify that the circuit is
ready. When the laser beam is broken, the LED turns off and the buzzer sounds. As we know from Projects
13 and 18, photoresistors produce variable resistance depending on the amount of light falling on their
sensor. When the photoresistor does not detect light from the laser, it will drop its resistance and trigger
the Arduino to send voltage to the pin controlling the buzzer. Laser beams that are visible in daylight or
even in the dark are very powerful and can be extremely dangerous. In this project we’ll use a low-
powered laser pen instead.

THE BUILD
1. Insert your photoresistor into the breadboard. Connect one leg to the +5V rail using a jumper wire.
Connect a 10k-ohm resistor to the other leg, and connect the other side of this resistor to Arduino A0
and GND on the breadboard.
PHOTORESISTOR ARDUINO
Leg 1 +5V
Leg 2 A0 via 10k-ohm resistor and GND

2. Connect the red (positive) wire of the piezo buzzer directly to Arduino pin 11 on the Arduino and
the black (GND) wire to GND on the breadboard.

PIEZO ARDUINO
Black wire GND
Red wire Pin 11

3. Insert the green LED’s long leg into Arduino pin 13 and the short leg into GND.
4. Connect the power rails to the breadboard.
5. Before you upload the code, you need to check the photoresistor’s value in ambient light. Run the
following small program with the photoresistor set up as instructed.

THE CONNECTION
The sketch first sets Arduino pin 11 as an OUTPUT for the piezo buzzer and pin 13 as an OUTPUT
for the LED. The photoresistor is connected to Arduino pin A0. If the analog reading from A0 is more
than 850 (meaning that there is less light and the laser beam has been broken), the buzzer will be
set to HIGH and turn on and the LED will turn off. Remember to change the resistance value
depending on your calibration on this line: As noted earlier, when the laser is shining on the resistor
it reads about 620, so in the sketch I’ve set the buzzer to sound only if the value is more than 850.
This value is between our laser value and our non-laser value, so we know the laser beam to the
resistor has been broken if the value reaches 850.

THE CODE
3. Motion Sensor Alarm
PARTS REQUIRED
• Arduino board • Breadboard • HC SR501 PIR sensor • LED • Piezo buzzer

How It Works
This project is based on the HC SR501 PIR sensor, which is widely available online for a few dollars. We’re
going to set it up so that when someone passes in front of the PIR sensor, the LED will light up and the
piezo buzzer will sound, but you can adapt it for various other output.

The Build
1. Connect the PIR sensor’s +5V and GND wires to the +5V and GND rails on the breadboard, and
connect these rails to the Arduino. Connect the PIR sensor’s output wire to Arduino pin 2.

PIR SENSOR ARDUINO


+5V +5V
GND GND
OUTPUT PIN 2
2. Insert an LED into the breadboard and connect the long, positive leg to Arduino pin 13, and the
short, negative leg to GND. You don’t need a resistor for the LED in this project.

LED ARDUINO
Positive leg Pin 13
Negative leg GND

3. Connect the piezo buzzer by attaching the red wire to Arduino pin 10 and the black wire to GND.

LED ARDUINO
Red wire Pin 10
Black wire GND

4. Confirm that your setup matches the circuit diagram, and then upload the code in “The Sketch” on.
The Sketch

The sketch works by setting Arduino pin 13 as output for the LED, pin 2 as input for the PIR sensor,
and pin 10 as output for the piezo buzzer. When the PIR sensor is triggered, a HIGH signal is sent
to the Arduino, which will in turn light the LED and play a tone on the piezo buzzer.

THE CODE

4. SMART GATE
Parts Required
• Arduino board • Breadboard • Jumper wires • 38 kHz IR receiver • Remote control • 2 Tower Pro SG90
9g servomotors • Pan-and-tilt housing module

Libraries Required • Servo


How It Works
First, we’ll decode the remote control using an IR receiver. An IR receiver has three pins: OUT, GND, and
VCC. Check the data sheet for the receiver you bought to make sure it matches this pin layout. In rare cases
you might find that your receiver’s pin layout differs, but you should still be able to use the pinout to wire it
up.
You will also need a remote control. You can use any kind of remote, including a TV remote, but it is best to
use an old one that you no longer need. When you press a button on the remote, it sends out a digital value
that is picked up by the receiver. This value is different for each button. We’ll decode the values for each
button with the Arduino and then assign them to Arduino pins in the sketch to control the output—in this case,
a servo. By personalizing the sketch with the values, you decode, you can connect certain buttons to certain
instructions and use your remote to control the servos. We’ll assign a button to the directional movement of
the servos in the tilt-and-pan housing, so in total four buttons will control all movement: left and right for the
x-axis servo, and up and down for the y-axis servo. Short button presses will move the servos in small
increments, and extended presses will move the servo continuously until the maximum or minimum value is
reached.
The Setup
1. Download the IRremote library from http://www.nostarch.com/ arduinohandbook/ and add it to your
libraries folder
2. Insert the IR receiver into a breadboard. Connect the OUT pin on the receiver to Arduino pin 11, GND to
Arduino GND, and VCC to Arduino +5V. Again, with some versions of the 38 kHz receiver, the pin order
may differ from what’s shown here, so check the data sheet corresponding to your component.
IR RECIEVER ARDUINO
OUT PIN 11
GND GND
VCC +5V
3. Now upload and run the following code.
Once you’ve downloaded the libraries, you’ll need to install them.
To install a library in Arduino version 1.0.6 and higher, follow these steps:

1. Choose SketchInclude LibraryAdd .ZIP Library.


2. Browse to the ZIP file you downloaded and select it.

• For older versions of Arduino, you’ll need to unzip the library file and then put the whole folder
and its contents into the sketchbook/ libraries folder on Linux, My Documents\Arduino\Libraries
on Windows, or Documents/Arduino/libraries on OS X. To install a library manually, go to the
ZIP file containing the library and uncompress it. For example, if you were installing a library
called keypad in a compressed file called keypad.zip, you would uncompress keypad.zip,
which would expand into a folder called keypad, which in turn contains files like keypad.cpp
and keypad.h. Once the ZIP file was expanded, you would drag the keypad folder into the
libraries folder on your operating system: sketchbook/ libraries in Linux, My Documents\
Arduino\Libraries on Windows, and Documents/Arduino/libraries on OS X. Then restart the
Arduino application. Libraries are listed at the start of a sketch and are easily identified
because they begin with the command #include. Libraries are surrounded by angle brackets,
<>, and end with .h
• The sketch first calls on the IRremote library, which reads from the IR receiver and sends the
corresponding data to the Arduino. The IR receiver is assigned to pin 11 on the Arduino, and
the sketch begins communicating with the Arduino IDE so that when a button is pressed the input
is displayed in the Serial Monitor in real time. The sketch continues in a loop, looking for button
presses, and shows the corresponding value to the IDE.
4. Open the Serial Monitor in your IDE.
5. Point your remote toward the receiver and try pressing different buttons. They will appear in the Serial
Monitor decoded into letters and numbers in a format known as hexadecimal (HEX), Try short, sharp presses
to get the best results. If you press a button for too long, the Serial Monitor will show Fs for as long as you
hold the button. Write down the numbers that appear and the buttons they correspond to. You will need
these numbers later. Now that we’ve decoded the button signals from the remote control, we can use them
to control two servos.
The Build
1. Using your breadboard setup, with the receiver already connected, attach your servos to the Arduino
by connecting the brown wire on each to GND, and the red wire to +5V. Then, connect the yellow
control wire for the first servo to Arduino pin 10, and the yellow control wire for the second servo to
Arduino pin 9.
SERVOS ARDUINO
RED WIRES +5V
BROWN WIRES GND
YELLOW WIRE (SERVO 1) PIN 10
YELLOW WIRE (SERVO 2) PIN 9
2. Remember to attach power to your breadboard.

3. Check that your setup matches the circuit diagram.

The Sketch
Make sure you use the values that you decoded in step 3 of “The Setup” on page 96 in place of the
values included here when completing the sketch. When you’re changing the value in the sketch to match
your own codes, keep the 0x and add your HEX code after it. For example, for the first button I
decoded, the HEX code is FFA05F, which looks like this in the sketch:
5. AUTOMATIC ALARM SYSTEM

Parts Required
• Arduino uno board • Breadboard • Jumper wires • 5V relay module • Real Time Clock (RTC) • LED• Resistor
• Buzzer.
HOW IT WORKS
This project is meant to replace the process of having a human to monitor time and ring the bell at
some specific time. Hence, the time will be monitored by the Arduino and also sound the alarm when
needed.
The Build
1. Connect the 5v of the Arduino to the positive rail of the breadboard and the GND of the
Arduino to the negative rail of the bread board.
2. Connect the clock module as follows:
CLOCK MODULE ARDUINO
VCC +5V
GND GND
CLK PIN 6
DAT PIN 9
RST PIN 8

3. Connect the relay module as follows:

RELAY MODULE ARDUINO


VCC +5V
GND GND
IN1(SIGNAL PIN) PIN 6

4. Connect the positive side of the led to the 220-ohm resistor on a rail on the breadboard also take
a jumper wire and connect the positive side which is connected with the resistor to pin 10 in the
Arduino.
5. Connect the buzzer to the relay or any other alarm like the school bell as you will see in the
schematic.
THE CODE
6. ULTRA SONIC INTRUDER ALARM SENSOR.
Parts Required • Arduino board • Breadboard • Jumper wires • Four-pin HC-SR04 ultrasonic sensor •
Servomotor • Red LED • Green LED • 2 220-ohm resistors.
How It Works
This project is versatile and can be used and adapted in various ways. Because the ultrasonic sensor can
define distance, you could, for example, use it to define an area and trigger an alarm when that perimeter
is breached. The sensor works similarly to a radar: it sends out an ultrasonic signal, or ping. When this signal
hits an object, it bounces back like an echo, and the time between the ping and the echo is used to calculate
distance. The Arduino can use this calculation to trigger an event, depending on the value received. In this
project, when the sensor detects an intruder within a predefined vicinity, the red LED will light and the servo
arm will move. You can adapt this project to trigger a different event when the intruder is detected, like
pressing a security system button or locking a door. For a friendlier scenario, you could set the distance really
close so that when you wave your hand in front of the sensor, the servo presses a button to release a treat,
like candy.
The Build
1. Insert the ultrasonic sensor into the breadboard. The sensor we’re using in this project has four pins.
Connect the sensor’s GND to the Arduino GND rail, VCC to Arduino +5V, Trig to Arduino pin 12,
and Echo to Arduino pin 13

ULTRASONIC SENSOR ARDUINO


VCC +5V
GND GND
TRIG PIN 12
ECHO PIN 13
2. Connect the servo’s brown (ground) wire to the Arduino GND rail, its red (power) wire to the Arduino
+5V rail, and its yellow signal (control) wire to Arduino pin 9.

SERVO ARDUINO
RED WIRE +5V
BROWN WIRE GND
YELLOW WIRE PIN 9
3. Insert the red and green LEDs into the breadboard with the shorter, negative legs in the Arduino GND
rail. Add a 220-ohm resistor to each of the positive legs, and connect the red LED to Arduino pin 2
and the green LED to pin 3 via the resistors.

LEDS ARDUINO
NEGATIVE LEADS GND
POSITIVE LEAD 1 PIN 2 VIA 220-OHM RESISTOR
POSITIVE LEAD 2 PIN 3 VIA 220-OHM RESISTOR
4. Connect the power rails on the breadboard to Arduino +5V and GND.
THE CODE

You might also like