Hardware components | ||||||
| × | 3 | ||||
| × | 3 | ||||
| × | 3 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
|
This Project Is a blind stick which I simulated on tinkercad
the link:
https://www.tinkercad.com/things/l7icPjPgrkE
an Image of the simulation:
This is the circuit diagram
Buzzer - A0
Left side:
ultrasonic sensor
trigger-11
echo-10
motor:
transistor collector- motor ground
transistor base - 1 k ohm, which connects to Dp12
transistor emitter - ground
motor positive - VCC
Middle :
trigger pin-9
echo pin - 6
transistor connections are the same as the left sides, only base connects to 8
Right Side:
trigger pin - 5
echo pin - 3
transistor connections are the same as the left sides, only base connects to 2
Left side:
ultrasonic sensor
trigger-11
echo-10
motor:
transistor collector- motor ground
transistor base - 1 k ohm, which connects to Dp12
transistor emitter - ground
motor positive - VCC
Middle :
trigger pin-9
echo pin - 6
transistor connections are the same as the left sides, only base connects to 8
Right Side:
trigger pin - 5
echo pin - 3
transistor connections are the same as the left sides, only base connects to 2
long readDistance(int trigPin, int echoPin)
{
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
return pulseIn(echoPin, HIGH)/2;
}
void setup()
{
pinMode(A0, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
pinMode(2, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int cm1 = readDistance(11,10)/29.1;
int cm2 = readDistance(9,6)/29.1;
int cm3 = readDistance(5,3)/29.1;
map(A0,0,1023,0,255);
Serial.println(cm1);
Serial.println(cm2);
Serial.println(cm3);
if(cm1 <= 100)
{
digitalWrite(12, HIGH);
digitalWrite(A0, HIGH);
delay(1000);
digitalWrite(A0, LOW);
} else
{
digitalWrite(12, LOW);
}
if(cm2 <= 100)
{
digitalWrite(8, HIGH);
digitalWrite(A0, HIGH);
delay(1000);
digitalWrite(A0, LOW);
} else
{
digitalWrite(8, LOW);
}
if(cm3 <= 100)
{
digitalWrite(2, HIGH);
digitalWrite(A0, HIGH);
delay(1000);
digitalWrite(A0, LOW);
} else
{
digitalWrite(2, LOW);
digitalWrite(A0, LOW);
}
}
Comments