soicalwork12
Published

Led and sensor control

In this project we will control the LED and control the sensor. by using phone. we are using wireless serial monitor. and help for sensor data

IntermediateFull instructions provided595
Led and sensor control

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Male/Male Jumper Wires
×12
Resistor 1k ohm
Resistor 1k ohm
×4
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×4
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

1)Circuit

I Already divide the circuit in some part

2)Circuit

Interfacing of Bluetooth module

3)Circuit (LED-1) Red LED

I forget add some resistor in LED so

Circuit (LED-1) Green LED

Circuit (LED-1) Yellow LED

Circuit (LED-1) White LED

4)Power Up Arduino

We are using 9v battery.

Code

Code

Arduino
const int trigPin = 9;
const int echoPin = 8;
#define redLED 3 
#define GreenLED 4
#define YellowLED 5
#define WhiteLED 6
long duration;
int distance;
int LED_Value;
void setup() 
{
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
pinMode(redLED, OUTPUT);
pinMode(GreenLED, OUTPUT);
pinMode(YellowLED, OUTPUT);
pinMode(WhiteLED, OUTPUT);   
Serial.begin(9600); 
}
void loop() {
LED_Value=Serial.read();
if (LED_Value=='r'){
digitalWrite(redLED,HIGH);
}
else if (LED_Value=='f'){
digitalWrite(redLED,LOW);
digitalWrite(GreenLED,LOW);
digitalWrite(YellowLED,LOW);
digitalWrite(WhiteLED,LOW);
}
else if (LED_Value=='g'){
digitalWrite(GreenLED,HIGH);
}
else if (LED_Value=='y'){
digitalWrite(YellowLED,HIGH);
}
else if (LED_Value=='w'){
digitalWrite(WhiteLED,HIGH);
}
else if(LED_Value=='d'){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
Serial.print("Distance in CM= ");
Serial.print(distance);
Serial.print("\n");
delay(1000);
}
}

Credits

soicalwork12
0 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.