Now time we have many connection like wire and wireless.But I like wireless.You.Now you already know we can control the LED or you can say fan, Light etc.By using Arduino, relay module.But in that case we are using normal Bluetooth control software which have button like that
You can control the relay or you can say LED but you can not get data wireless so we need another software like serial monitor.to get data and control the LED.
Let See something about code:-
Let me come to main part of code Void loop:-
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);
}
Here in this code We are using LED_Value as a variable to read and store the data read from the serial monitor Command(LED_Value=Serial.read();)
Now time to Enter the data time if we enter the r in serial monitor then Red LED will high or ON.serial data is f the all led will of here we are using 4 LED.
Now left thing is same for Green and Yellow and White only difference in data like if LED_Value==r then red led will high,
LED_Value==y then Yellow led will high,
LED_Value==g then green led will high,
LED_Value==w then White led will high,
Now Jump to sensor co control so LED_Value==d then Ultrasonic sensor will send data to wireless serial monitor and print data to serial monitor.
Now time to make it
Comments
Please log in or sign up to comment.