Professional Documents
Culture Documents
Get the latest version from the download page. You can choose between the Installer
(.exe) and the Zip packages. We suggest you use the first one that installs directly everything
you need to use the Arduino Software (IDE), including the drivers. With the Zip package you
need to install the drivers manually. The Zip file is also useful if you want to create
importable installation.
When the download finishes, proceed with the installation and please allow the driver
installation process when you get a warning from the operating system.
The process will extract and install all the required files to execute properly the Arduino
Software (IDE) Proceed with board specific instructions. When the Arduino Software (IDE)
is properly installed you can go back to the Getting Started Home and choose your board
from the list on the right of the page.
Voltage Regulator
The function of the voltage regulator is to control the voltage given to the
3.
Arduino board and stabilize the DC voltages used by the processor and other
elements.
Crystal Oscillator
The crystal oscillator helps Arduino in dealing with time issues. How does
4. Arduino calculate time? The answer is, by using the crystal oscillator. The
number printed on top of the Arduino crystal is 16.000H9H. It tells us that the
frequency is 16,000,000 Hertz or 16 MHz.
Arduino Reset
You can reset your Arduino board, i.e., starts your program from the
5,17 beginning. You can reset the UNO board in two ways. First, by using the reset
button (17) on the board. Second, you can connect an external reset button to
the Arduino pin labeled RESET (5).
Analog pins
The Arduino UNO board has five analog input pins A0 through A5. These
10. pins can read the signal from an analog sensor like the humidity sensor or
temperature sensor and convert it into a digital value that can be read by the
microprocessor.
Main microcontroller
Each Arduino board has its own microcontroller (11). You can assume it as
the brain of your board. The main IC (integrated circuit) on the Arduino is
slightly different from board to board. The microcontrollers are usually of the
11.
ATMEL Company. You must know what IC your board has before loading up
a new program from the Arduino IDE. This information is available on the top
of the IC. For more details about the IC construction and functions, you can
refer to the data sheet.
ICSP pin
Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino
consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often referred
12.
to as an SPI (Serial Peripheral Interface), which could be considered as an
"expansion" of the output. Actually, you are slaving the output device to the
master of the SPI bus.
TX and RX LEDs
On your board, you will find two labels: TX (transmit) and RX (receive).
14.
They appear in two places on the Arduino UNO board. First, at the digital pins
0 and 1, to indicate the pins responsible for serial communication. Second, the
TX and RX led (13). The TX led flashes with different speed while sending
the serial data. The speed of flashing depends on the baud rate used by the
board. RX flashes during the receiving process.
Digital I/O
The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide
PWM (Pulse Width Modulation) output. These pins can be configured to work
15.
as input digital pins to read logic values (0 or 1) or as digital output pins to
drive different modules like LEDs, relays, etc. The pins labeled “~” can be
used to generate PWM.
AREF
AREF stands for Analog Reference. It is sometimes, used to set an external
16.
reference voltage (between 0 and 5 Volts) as the upper limit for the analog
input pins.
WEEK-2
LED:A light-emitting diode is a semiconductor light source that emits light when current
flows through it. Electrons in the semiconductor recombine with electron holes, releasing
energy in the form of photons.
Circuit:
Code:
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
Output:
WEEK-3
LED:A light-emitting diode is a semiconductor light source that emits light when current
flows through it. Electrons in the semiconductor recombine with electron holes, releasing
energy in the form of photons.
Circuit:
Code:
void setup()
{
pinMode(2, INPUT);
pinMode(13, OUTPUT);
}
void loop()
{
if (digitalRead(2) == HIGH) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
OUTPUT:
WEEK-4
LED:A light-emitting diode is a semiconductor light source that emits light when current
flows through it. Electrons in the semiconductor recombine with electron holes, releasing
energy in the form of photons.
Circuit:
Code:
void setup()
{
pinMode(4, OUTPUT); //green led
pinMode(3, OUTPUT); //orange led
pinMode(2, OUTPUT); //red led
void loop()
{
digitalWrite(4, HIGH); //turn on green led
delay(3000); // Wait for 3000 millisecond(s)
digitalWrite(4, LOW); //turn of green led
OUTPUT:
WEEK-5
AIM: Detecting the object distance by using ultrasonic sensor
Ultrasonic sensors: can measure the distance to a wide range of objects regardless of shape,
color or surface texture. They are also able to measure an approaching or receding object.
Circuit:
Code:
const int trigPin = 9;
const int echoPin = 10;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
Output:
WEEK-6
PIR Sensor:PIR sensors allow you to sense motion, almost always used to detect whether a
human has moved in or out of the sensor's range.
LED:A light-emitting diode is a semiconductor light source that emits light when current
flows through it. Electrons in the semiconductor recombine with electron holes, releasing
energy in the form of photons.
Circuit:
Code:
int sensorState = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// read the state of the sensor/digital input
sensorState = digitalRead(2);
// check if sensor pin is HIGH. if it is, set the
// LED on.
if (sensorState == HIGH) {
digitalWrite(13, HIGH);
Serial.println("Sensor activated!");
} else {
digitalWrite(13, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}
Output:
WEEK-7
Circuit:
Code:
void setup()
{
Serial.begin(9600);
pinMode(A0, OUTPUT);
}
void loop()
{
int temp=analogRead(A0);
temp=temp*0.48828125;
Serial.println("Temparature is: "+temp);
delay(1000);
}
WEEK-8
AIM: To Write an arduino program for LDR sensor to detect the light sensing.
LDR sensor: Photoresistors, also known as light dependent resistors (LDR), are light
sensitive devices most often used to indicate the presence or absence of light, or to measure
the light intensity.
Circuit:
Code:
int light;
void setup()
{
Serial.begin(9600);
}
void loop()
{
light=analogRead(A0);
Serial.println(light);
delay(1000);
}
Output:
WEEK-9
AIM: To write an arduino program to detect the smoke presence with the help of MQ-2
sensor.
Gas Sensor: MQ2 Gas sensor works on 5V DC and draws around 800mW. It can detect
LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations
anywhere from 200 to 10000ppm.
Circuit:
Code:
void setup()
{
Serial.begin(9600);
}
void loop()
{
int a=analogRead(A0);
int b=map(a,0,1025,0,255);
Serial.println(b);
if(b>80)
{
Serial.println("Smoke Detected");
}
else
{
Serial.println("Smoke Not Detected");
}
}
Output:
WEEK-10
AIM: To write an arduino program to implement a relay module along with the buzzer.
Buzzer: The buzzer consists of an outside case with two pins to attach it to power and
ground. ... When current is applied to the buzzer it causes the ceramic disk to contract or
expand. Changing the This then causes the surrounding disc to vibrate. That's the sound that
you hear.
Circuit:
Code:
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
tone(13, 200, 100);
delay(200);
Output:
WEEK-11
AIM: Write an arduino program for sensing the room temperature and humidity through
humidity sensing device and displaying on the LCD Screen.
Circuit:
Code:
#include<LiquidCrystal.h>
#define pinTemp A0
void setup(){
Serial.begin( 9600 );
pinMode( pinTemp,INPUT );
lcd.begin(16, 2);
lcd.print("Temperature:");
}
void loop() {
float temp = ((analogRead(pinTemp) * (5.0/1024))-0.5 )/0.01;
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print( temp );
Serial.println( temp );
delay( 1000 );
}
Output:
WEEK-12
AIM: Introduction to Raspberry pi.
DESCRIPTION:
1. Raspberry Pi 1 Model A
2. Raspberry Pi 1 Model A+
3. Raspberry Pi 1 Model B
4. Raspberry Pi 1 Model B+
5. Raspberry Pi 2 Model B
6. Raspberry Pi 3 Model B
7. Raspberry Pi Zero
DESCRIPTION:
A simple LED circuit consists of a LED and resistor. The resistor is used to limit the current
that is being drawn and is called a current limiting resistor. Without the resistor the LED
would run at too high of a voltage, resulting in too much current being drawn which in turn
would instantly burn the LED, and likely also the GPIO port on the Raspberry Pi.
When hooking up the circuit note the polarity of the LED. You will notice that the LED has
a long and short lead. The long lead is the positive side also called the anode, the short lead is
the negative side called the cathode. The long should be connected to the resistor and the
short lead should be connected to ground via the blue jumper wire and pin 6 on the Raspberry
Pi as shown on the diagram.
CIRCUIT DIAGRAM:
CODE:
Import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
While True:
GPIO.setmode(18, GPIO.OUT)
print(“LED on”)
GPIO.output(18, GPIO.HIGH)
print(“LED off”)
GPIO.output(18, GPIO.LOW)
time.sleep(5)
OUTPUT:
WEEK-14
AIM: To write a raspberry pi program for detecting the object distance by using ultrasonic
sensor.
DESCRIPTION:
Ultrasonic sensors: can measure the distance to a wide range of objects regardless of shape,
color or surface texture. They are also able to measure an approaching or receding object.
CODE:
import time
GPIO.setmode (GPIO.BCM)
GPIO.setwarnings(False)
GPIO_TRIGGER = 18
GPIO_ECHO = 24
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO. GPIO.IN)
def distance():
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00005)
GPIO.output(GPIO_TRIGGER, False)
StartTime = time.time()
StopTime = time.time()
while GPIO.input(GPIO_ECHO)==0:
StartTime = time. time()
return distance
try:
while True:
dist distance()
except KeyboardInterrupt:
GPIO.cleanup()
OUTPUT:
WEEK-15
AIM: To implement the PIR sensor with raspberry pi
DESCRIPTION:
PIRs are basically made of a pyroelectric sensor (which you can see below as the round metal
can with a rectangular crystal in the center), which can detect levels of infrared radiation.
Everything emits some low level radiation, and the hotter something is, the more radiation is
emitted. The sensor in a motion detector is actually split in two halves. The reason for that is
that we are looking to detect motion (change) not average IR levels. The two halves are wired
up so that they cancel each other out. If one half sees more or less IR radiation than the other,
the output will swing high or low.
A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR)
light radiating from objects in its field of view. They are most often used in PIR-
based motion detectors.
When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated
from the room or walls or outdoors. When a warm body like a human or animal passes by, it
first intercepts one half of the PIR sensor, which causes a positive differential change
between the two halves.
CODE:
DESCRIPTION:
The light dependent resistor or also known as the LDR sensor is the most important piece of
equipment in our circuit (obviously). Without it, we wouldn’t be able to detect whether it is
dark or light. In the light, this sensor will have a resistance of only a few hundred ohms while
in the dark, it can have a resistance of several megohms
.
The capacitor in our circuit is there, so we’re able to measure the resistance of the LDR
sensor. A capacitor essentially acts like a battery charging up while receiving power and then
discharging when no longer receiving power. Using this in series with the LDR, we can work
out how much resistance the LDR is giving out thus whether it is light or dark.
To get the light sensor circuit built correctly follow the steps below or check out the circuit
diagram right underneath the steps. In the following steps, I am referring to the physical
numbers of the pins (Logical order).
CODE:
GPIO.setmode (GPIO.BOARD)
pc = 7
try:
while True:
count = 0
GPIO.setup(pc, GPIO.OUT)
GPIO.output(pc, GPIO.LOW)
time.sleep(0.1)
GPIO.setup(pc, GPIO.IN)
while (GPIO. input(pc)==GPIO.LOW):
count+=1
print(count)
except keyboardInterrupt:
GPIO.cleanup()
OUTPUT:
CASE STUDY
AIM: - Interface Raspberry Pi board with IR sensor to measure the presence of an object.
Description:-In this project, we will learn about Infrared Sensors, simply known as IR
Sensor and how to interface an IR Sensor with Raspberry Pi. By interfacing this IR Sensor
with Raspberry Pi, you can implement a Proximity Sensor Application (Obstacle Detection).
Overview
Infrared Sensors or IR Sensors are one of the frequently used sensor modules by electronics
hobbyists and makers. They are often used as Obstacle Detecting Sensors or Proximity
Sensors.
IR Sensors emit and receive Infrared radiation. They are often used as Proximity Sensors i.e.
detect and alarm if an object is close to the sensor.
Let me help you understand better about IR Sensors by giving two real life applications of IR
Sensors. The first one is Mobile Phones.
Almost all mobile phones nowadays have IR Sensors in them. Usually, they will be placed
near the earpiece on the phone.
When the user make or receives a phone call, the IR Sensor detects how far the phone is from
the user’s ear. If it is close to the ear, the phone’s display will be turned off so that you do not
touch anything on the screen accidently.
Another important application is in automobiles. All modern cars are equipped with reverse
parking sensor that sense how far you can reverse your car without hitting anything. These
reverse sensors are implemented using IR Sensors.
Fig.1.1
Based on the application and requirement, IR Sensors can be implemented in two ways. In
the first method, both the IR Transmitter and the IR Detector are placed side-by-side. In the
second setup, the IR Transmitter and the IR Detector are placed facing each other.
The first way of implementation is known as Reflective Type IR Sensor. In this setup, the IR
Transmitter continuously emits infrared light and if there is any obstacle/object in front of the
sensor, the infrared light hits the object and bounces back. The reflected signal is captured by
the IR Detector and the control circuit will reflect a Logic HIGH on its output.
The second way of implementation, where the IR Transmitter and Detector are positioned
face-t-face, is known as Transmissive Type IR Sensor. Here, the infrared light from the IR
Transmitter always falls on the Detector.
If there is an object in between the Transmitter and Detector, then there will be an obstruction
to the infrared light and the control circuit will detect this and produces appropriate output.
The IR Sensor used in this project is a Reflective Type IR Sensor. You can easily build this
type of IR Sensor as a DIY Project as the circuit is very simple.
The following image shows the circuit diagram of the IR Sensor Module. It consists of the
following components.
● IR LED
● Photo Diode
● 150Ω Resistor
● 10 KΩ Resistor
● 10 KΩ Potentiometer
● LM358
● LED
● 1 KΩ Resistor
Now that we have seen a little bit about the IR Sensor Module and its connections, we will
proceed with interfacing IR Sensor with Raspberry Pi.
The Raspberry Pi IR Sensor Interface can be converted into a Proximity Detector, where the
application will detect if the object is too close to the sensor.
Components Required
● Raspberry Pi 3 Model B
● IR Sensor
● 5V Buzzer
● Mini Breadboard
● Connecting Wires
● Power Supply
● Computer
Circuit Design
The IR Sensor Module has only three Pins: VCC, GND and Data. Connect the VCC and
GND pins of the IR Sensor to +5V and GND pins of the Raspberry Pi.
Then connect the Data pin of the IR Sensor to GPIO23 i.e. Physical Pin 16 of the Raspberry
Pi.
In order to indicate the alarm, I have used a simple 5V Buzzer. Connect one terminal of the
buzzer to GND of Raspberry Pi and the other terminal (usually marked +) to GPIO24 i.e.
Physical Pin 18 of Raspberry Pi.
Working
We have learned how to interface an IR Sensor with Raspberry Pi. I’ll now explain the
working of the project.
All the magic happens in the IR Sensor Module. As it is a Reflective type IR Sensor,
whenever an object is placed in front of the sensor, the Infrared light from the IR LED gets
reflected back after hitting the object and falls on the Photo Diode.
The photo diode then starts conducting. As a result, the voltage at the non-inverting input of
the LM358 will be greater than that at the inverting input.
Since the LM358 is acting as a Comparator, its output will become HIGH and the on-board
LED glows. The HIGH on the Data Pin is detected by the Raspberry Pi and it activates the
buzzer.
Using the 10 KΩ Potentiometer, you can adjust how far the object can be placed in front of
the sensor in order to detect.
Applications
As mentioned in the earlier sections, Proximity Sensor or Obstacle Detection is the main
application of interfacing IR Sensor with Raspberry Pi. Some of the common applications
include:
● Contactless Tachometer
● Line Follower Robot
● Obstacle Avoiding Robot
● Car Reverse Sensor
DESCRIPTION OF THINGSPEAK:-
Definition:-
ThingSpeak is an open data platform for the Internet of Things. Your device or application
can communicate with ThingSpeak using a RESTful API, and you can either keep your data
private, or make it public. In addition, use ThingSpeak to analyze and act on your data.
ThingSpeak provides an online text editor to perform data analysis and visualization using
MATLAB. You can also perform actions such as running regularly scheduled MATLAB
code or sending a tweet when your data passes a defined threshold.
ThingSpeak is used for diverse applications ranging from weather data collection and
analysis, to synchronizing the color of lights across the world.
At the heart of ThingSpeak is a time-series database. ThingSpeak provides users with free
time-series data storage in channels. Each channel can include up to eight data fields.
Sensors, or things, sense data and typically act locally. ThingSpeak enables sensors,
instruments, and websites to send data to the cloud where it is stored in either a private or a
public channel.
ThingSpeak stores data in private channels by default, but public channels can be used to
share data with others. Once data is in a ThingSpeak channel, you can analyze and visualize
it, calculate new data, or interact with social media, web services, and other
devices. ThingSpeak allows you to aggregate, visualize and analyze live data streams in the
cloud. Some of the key capabilities of ThingSpeak include the ability to: Easily configure
devices to send data to ThingSpeak using popular IoT protocols. Visualize your sensor data
in real-time
CODE:-
import RPi.GPIO as GPIO
import time
sleep=1
key = '4AQOQCI2SI3VUP3G' # Write API key
def dist():
while True:
headers = {"Content-typZZe": "application/x-www-form-
urlencoded","Accept": "text/plain"}
conn = http.client.HTTPConnection("api.thingspeak.com:80")
sensor = 16
buzzer = 18
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor,GPIO.IN)
GPIO.setup(buzzer,GPIO.OUT)
GPIO.output(buzzer,False)
print "IR Sensor Ready....."
print " "
try:
while True:
if GPIO.input(sensor):
GPIO.output(buzzer,True)
print "Object Detected"
while GPIO.input(sensor):
time.sleep(0.2)
params = urllib.parse.urlencode({'field1': distance,
'key':key }) # channel name is field1 or field 2
conn.request("POST", "/update", params, headers)
response = conn.getresponse()
else:
GPIO.output(buzzer,False)
except KeyboardInterrupt:
GPIO.cleanup()
THINGSPEAK:
OUTPUT: