LED Radar
This LED radar can help me know when something is close, when the ultrasonic sensor senses something within the chosen distance the LED will light up. This project consists of three main things and ultrasonic sensor stepper motor and the LED.
Supplies
- 12 or more Jump Wires
- Ultrasonic Emitter
- LED (any color)
- x1 (ohm) resistor
- Stepper Motor
Circuit and Everything Else
From the stepper motor Connect IN1 IN2 IN3 IN4 to digital 8 to 11.
Connect the VCC of the supersonic sensor to the negative side of the breadboard. Then connect Trigg to digital six and Eco to digital seven. After that connect GND to power a GND of the arduino board.
Next connect the GND from the arduino board to the negative side of the breadboard then connect 5V to the positive side of the breadboard.
for the LED lights connect a wire from the negative side of the breadboard to the bottom side of the breadboard. Place a resistor from one side of the breadboard to the other side of the breadboard. Then placed a wire from the top of the resistor to anywhere on the breadboard. Then add another wire next to the why are you just put on to digital five and place your LED on those two wires. Then run the code
Code
int UltrasonicSensorCM(int trigPin, int echoPin)
{
long duration;
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(20);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
duration = duration / 59;
if ((duration < 2) || (duration > 200)) return false;
return duration; } void StepMotor(int MotorStep,int MotorSpeed,int pinNumberA, int pinNumberB,int pinNumberC,int pinNumberD)
{ pinMode(pinNumberA, OUTPUT);
pinMode(pinNumberB, OUTPUT);
pinMode(pinNumberC, OUTPUT);
pinMode(pinNumberD, OUTPUT);
for(int i=0;i
void setup(){
Serial.begin(9600);
digitalWrite( 6 , LOW );
pinMode( 5 , OUTPUT);
}
void loop(){
Serial.print("distance:");
Serial.print(" ");
Serial.print( UltrasonicSensorCM( 6 , 7 ));
Serial.print(" ");
Serial.println();
StepMotor(1024, 10, 8, 9, 10, 11);
delay( 1000 );
StepMotor(1024, 10, 11, 10, 9, 8);
if ( UltrasonicSensorCM( 6 , 7 ) < 30 && UltrasonicSensorCM( 6 , 7 ) < 0 ) {
digitalWrite( 5 , HIGH );
}
else {
digitalWrite( 5 , LOW );
} }
Process
This is me working on the project