Devices & Components
Arduino Uno Rev3
Ultrasonic Sensor - HC-SR04 (Generic)
Buzzer
Buzzer
Solderless Breadboard Full Size
LED (generic)
Hardware & Tools
Tape, Scotch
Software & Tools
Arduino IDE
Project description
Code
upload this code
c_cpp
it is in the C/C++ language
1/* 2 * make a smart stick that helps the Blind 3 */ 4 #define trigPin 9 5 #define echoPin 8 6 7 #define Buzzer1 5//active 8 #define Buzzer2 7//passive 9 #define Led1 6//Vibration 10 11 12int sound = 250; 13 14 15void setup() { 16 Serial.begin (9600); 17 pinMode(trigPin, OUTPUT); 18 pinMode(echoPin, INPUT); 19 pinMode(Buzzer1, OUTPUT); 20 pinMode(Buzzer2, OUTPUT); 21 pinMode(Led1, OUTPUT); 22} 23 24void loop() { 25 Serial.begin(9600); 26 27 long duration, distance; 28 digitalWrite(trigPin, LOW); 29 delay(2); 30 digitalWrite(trigPin, HIGH); 31 delay(10); 32 digitalWrite(trigPin, LOW); 33 duration = pulseIn(echoPin, HIGH); 34 distance = (duration/2) / 29.1; 35 digitalWrite(Buzzer1, LOW); 36 digitalWrite(Buzzer2, LOW); 37 digitalWrite(Led1, LOW); 38 39 if (distance<40) { 40 digitalWrite(Led1, HIGH); 41 delay(2000); 42 } 43 if (distance<20) { 44 digitalWrite(Led1, HIGH); 45 delay(2000); 46 digitalWrite(Buzzer1, HIGH); 47 delay(2000); 48 } 49 if (distance<10) { 50 digitalWrite(Led1, HIGH); 51 delay(2000); 52 digitalWrite(Buzzer1, HIGH); 53 delay(2000); 54 digitalWrite(Buzzer2, HIGH); 55 delay(2000); 56 } 57 } 58 59
Downloadable files
the schematic
first the ultrasonic sensor 2 buzzer Led should be attached to breadboard then we should connect these components to arduino by wires after that the circuit should be attached to a stick with a tape
the schematic

the schematic
first the ultrasonic sensor 2 buzzer Led should be attached to breadboard then we should connect these components to arduino by wires after that the circuit should be attached to a stick with a tape
the schematic

Comments
Only logged in users can leave comments