Step 1: Connect the Ultrasonic Sensor to the Jumper Cable (Ground + VCC)
Step 2: Connect the corresponding Jumper Cable ends to Arduino UNO R3 board at pins referring to 5V and GND.
Step 3: Connect Pins Tr1g and Echo on the Ultrasonic sensor with Jumper Cables
Step 4: The other end of the jumper cables connect to Pin 7 and Pin 8 Respectively on the Arduino.
Step 5: Ultrasonic measures the nearby distance:
Step 6: Measurement displayed on Graph in cm:
Step 7: Ultrasonic measuring farther object:
Step 8: Measurement displayed on Graph in cm. We can observe the shift in readings:
Code for running the Ultrasonic sensor:
/* HC-SR04 Ping distance sensor: VCC to arduino 5v GND to arduino GND Echo to Arduino pin 7 Trig to Arduino pin 8
This sketch originates from Virtualmix: http://goo.gl/kJ8Gl Has been modified by Winkle ink here: http://winkleink.blogspot.com.au/2012/05/arduino-hc-sr04-ultrasonic-distance.html And modified further by ScottC here: http://arduinobasics.blogspot.com.au/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html on 10 Nov 2012. */ #define echoPin 7 // Echo Pin #define trigPin 8 // Trigger Pin #define LEDPin 13 // Onboard LED int maximumRange = 200; // Maximum range needed int minimumRange = 0; // Minimum range needed long duration, distance; // Duration used to calculate distance void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) } void loop() { /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10);
//Calculate the distance (in cm) based on the speed of sound. distance = duration/58.2;
if (distance >= maximumRange || distance <= minimumRange){ /* Send a negative number to computer and Turn LED ON to indicate "out of range" */ Serial.println("-1"); digitalWrite(LEDPin, HIGH); } else { /* Send the distance to the computer using Serial protocol, and turn LED OFF to indicate successful reading. */ Serial.println(distance); digitalWrite(LEDPin, LOW); }
Step 1: Connect the IR Proximity Sensor to the jumper cables:
Ground should connect with Ground on the Arduino Board
5V should connect with 5V on Arduino Board.
Step 2: We can observe in the pic below, our Arduino UNO R3 is having all female pins:
Step 3: Hence , we need to use berg sticks to convert it to male
pin. This is because, we use the jumper cable to connect to other IC's
and Jumper cable are having female pins.
Step 4: Insert the Berg Sticks into Female Pins of Arduino:
Step 5: Connect the jumper cables such that the 5V cable from the IR proximity sensor connects to the 5V on the Arduino UNO R3 board and GND from the Sensor connects to the GND on the board:
Step 6: Connect Arduino Uno R3 board to the computer using cable.
Step 7: The Red LED on the proximity sensor glows when the finger obstructs the path of the sensor.
Step 8: The Red LED stops glowing on the finger being removed from the path of the IR proximity sensor.
Step 1: We need to make the connection as per the below circuit:
Step 2: Connect the jumper cables to the Piezo Buzzer. Connect he positive cable to the longer wire on the Buzzer.
In case of sensors, positive terminal is the longer wire.
Step 3: Connect the Positve jumper cable to Pin 9 and the negative jumper cable to ground:
Always remember, when connecting cables, positive will connect to positive and negative to negative / ground.
Step 4: Connect the Arduino UNO R3 to the computer using the USB printer cable :
Step 5: Upload the following code to Arduino: This is for providing power supply to the Arduino UNO R3 board.
/* Arduino tutorial - Buzzer / Piezo Speaker More info and circuit: http://www.ardumotive.com/how-to-use-a-buzzer-en.html Dev: Michalis Vasilakis // Date: 9/6/2015 // www.ardumotive.com */
const int buzzer = 9; //buzzer to arduino pin 9
void setup(){ pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
Sketch uses 928 bytes
(2%) of program storage space. Maximum is 32256 bytes. Global variables use
9 bytes (0%) of dynamic memory, leaving 2039 bytes for local
variables. Maximum is 2048 bytes. avrdude:
ser_open(): can't open device "/dev/ttyACM0": Permission
denied Problem uploading to
board. See
http://www.arduino.cc/en/Guide/Troubleshooting#upload for
suggestions.
This report would
have more information with "Show verbose output
during compilation" option enabled in
File -> Preferences.
To solve this error, I
have referred the below blog:
Step 13. Upload Again. This time Upload is successful - we have
received the following message: Done Uploading
This time received the message:
Sketch uses 928 bytes
(2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving
2039 bytes for local variables. Maximum is 2048 bytes.
The blinker is blinking every 1 second. It was already blinking.
Hence let us now modify the program for making it to blink every 3
seconds.
Step 14. Make the
program to blink every 3 seconds:
// the setup function
runs once when you press reset or power the board void setup() { // initialize
digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT); }
// the loop function
runs over and over again forever void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH
is the voltage level)
delay(3000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by
making the voltage LOW
delay(3000); // wait for a second }
We find that the orange LED in Arduino is now blinking every 3
seconds:
100%[==============================================================================================================================>]
31,455,488 1022KB/s in 26s
100%[==============================================================================================================================>]
45,892,904 590KB/s in 85s
Step 2: To upgrade Chrome: Let us use gdebi to install this
package:
~/Downloads $ sudo
gdebi "google-chrome-stable_current_amd64.deb" Reading package
lists... Done Building dependency
tree Reading state
information... Done Building data
structures... Done Building data
structures... Done
The web browser from
Google Google Chrome is a
browser that combines a minimal design with sophisticated
technology to make the web faster, safer, and easier. Do you want to
install the software package? [y/N]:y (Reading database ...
223107 files and directories currently installed.) Preparing to unpack
google-chrome-stable_current_amd64 (3).deb ... Unpacking
google-chrome-stable (56.0.2924.87-1) over (51.0.2704.63-1)
... Setting up
google-chrome-stable (56.0.2924.87-1) ... Processing triggers
for man-db (2.6.7.1-1ubuntu1) ... Processing triggers
for gnome-menus (3.10.1-0ubuntu2) ... Processing triggers
for desktop-file-utils (0.22-1ubuntu1) ... Processing triggers
for mime-support (3.54ubuntu1.1) ... ~/Downloads $
Step 3: Check out the version of Chrome Installed:
~/Downloads $
google-chrome --version Google Chrome
56.0.2924.87 ~/Downloads $