Components and supplies
DHT11 Temperature & Humidity Sensor (4 pins)
Resistor 220 ohm
Rotary potentiometer (generic)
RGB Diffused Common Cathode
Jumper wires (generic)
HC-05 Bluetooth Module
Alphanumeric LCD, 16 x 2
Arduino UNO
Tools and machines
Breadboard, 400 Pin
Project description
Code
Arduino Code
c_cpp
1//An Arduino Uno Remote Bluetooth Control Project by Joel Varghese 2 3#include <DHT.h> 4#include <LiquidCrystal.h> 5#define TYPE DHT11 6 7int rs=7; //setting up lcd pins 8int en=8; 9int d4=9; 10int d5=10; 11int d6=11; 12int d7=12; 13 14int sensePin=2; //dht sensor pin 15float humidity; 16float tempC; 17 18int setTime = 500; //constants for time delay 19int dt=5000; 20 21String ic ; //bluetooth incoming string 22int rPin = 6; //rgb led pin connections 23int gPin = 5; 24int bPin = 4; 25int rBright=0; 26int bBright=0; 27int gBright=0; 28float dfact=1; 29 30LiquidCrystal lcd(rs,en,d4,d5,d6,d7); //create an lcd object 31DHT ht(sensePin, TYPE); //create a DHT sensor object 32 33void setup() { 34 Serial.begin(9600); //UART Communication 35 pinMode (rPin, OUTPUT); //setting RGB pins in output mode 36 pinMode (gPin, OUTPUT); 37 pinMode (bPin, OUTPUT); 38 ht.begin(); //initializes the DHT SENSOR 39 lcd.begin(16,2); //initializes the LCD display 40 41 42} 43 44void loop() { 45 if (Serial.available() >0){ //we are waiting for a remote Bluetooth control 46 ic = Serial.readString(); 47 Serial.print(ic); 48 Serial.print("\ 49"); 50 51 if (ic == "T") { //Temperature Display Mode has been clicked 52 lcd.noBlink(); 53 Serial.print("Welcom"); 54 lcd.print ("Welcome"); 55 delay(2000); 56 lcd.clear(); 57 humidity= ht.readHumidity(); 58 tempC = ht.readTemperature (); 59 lcd.setCursor(0,0); 60 lcd.print("Temp is "); 61 lcd.setCursor(2,1); 62 lcd.print(tempC); 63 lcd.print ("C"); 64 delay(dt); 65 lcd.clear(); 66 lcd.setCursor(0,0); 67 lcd.print("Humidity is "); 68 lcd.setCursor(2,1); 69 lcd. print (humidity); 70 delay(dt); 71 lcd.clear(); 72 lcd.print("Thank You"); 73 delay(1000); 74 lcd.clear(); 75 } 76 77 else if (ic == "0"){ //Lamp Switch OFF 78 rBright=0; 79 bBright=0; 80 gBright=0; 81 dfact=0; 82 83 } 84 else if (ic == "7"){ //Lamp Switch ON 85 rBright=255; 86 bBright=255; 87 gBright=255; 88 dfact=1; 89 90 } 91 92 else if (ic == "Red"){ 93 rBright=255; 94 bBright=0; 95 gBright=0; 96 dfact=1; 97 } 98 else if (ic== "Blue"){ 99 rBright=0; 100 bBright=255; 101 gBright=0; 102 dfact=1; 103 } 104 else if (ic == "Green"){ 105 rBright=0; 106 bBright=0; 107 gBright=255; 108 dfact=1; 109 } 110 else if (ic== "Cyan"){ 111 rBright=0; 112 bBright=255; 113 gBright=255; 114 dfact=1; 115 } 116 else if (ic == "Magenta"){ 117 rBright=255; 118 bBright=255; 119 gBright=0; 120 dfact=1; 121 } 122 else if (ic == "Yellow"){ 123 rBright=255; 124 bBright=0; 125 gBright=255; 126 dfact=1; 127 } 128 129 130 else if (ic =="25"){ 131 dfact=0.25; 132 } 133 else if (ic =="50"){ 134 dfact=0.5; 135 } 136 else if (ic =="75"){ 137 dfact=0.75; 138 } 139 else if (ic =="100"){ 140 dfact=1; 141 } 142 143 analogWrite(rPin, dfact*rBright); 144 analogWrite(gPin, dfact*gBright); 145 analogWrite(bPin, dfact*bBright); 146 } 147 }
Arduino Code
c_cpp
1//An Arduino Uno Remote Bluetooth Control Project by Joel Varghese 2 3#include <DHT.h> 4#include <LiquidCrystal.h> 5#define TYPE DHT11 6 7int rs=7; //setting up lcd pins 8int en=8; 9int d4=9; 10int d5=10; 11int d6=11; 12int d7=12; 13 14int sensePin=2; //dht sensor pin 15float humidity; 16float tempC; 17 18int setTime = 500; //constants for time delay 19int dt=5000; 20 21String ic ; //bluetooth incoming string 22int rPin = 6; //rgb led pin connections 23int gPin = 5; 24int bPin = 4; 25int rBright=0; 26int bBright=0; 27int gBright=0; 28float dfact=1; 29 30LiquidCrystal lcd(rs,en,d4,d5,d6,d7); //create an lcd object 31DHT ht(sensePin, TYPE); //create a DHT sensor object 32 33void setup() { 34 Serial.begin(9600); //UART Communication 35 pinMode (rPin, OUTPUT); //setting RGB pins in output mode 36 pinMode (gPin, OUTPUT); 37 pinMode (bPin, OUTPUT); 38 ht.begin(); //initializes the DHT SENSOR 39 lcd.begin(16,2); //initializes the LCD display 40 41 42} 43 44void loop() { 45 if (Serial.available() >0){ //we are waiting for a remote Bluetooth control 46 ic = Serial.readString(); 47 Serial.print(ic); 48 Serial.print("\ 49"); 50 51 if (ic == "T") { //Temperature Display Mode has been clicked 52 lcd.noBlink(); 53 Serial.print("Welcom"); 54 lcd.print ("Welcome"); 55 delay(2000); 56 lcd.clear(); 57 humidity= ht.readHumidity(); 58 tempC = ht.readTemperature (); 59 lcd.setCursor(0,0); 60 lcd.print("Temp is "); 61 lcd.setCursor(2,1); 62 lcd.print(tempC); 63 lcd.print ("C"); 64 delay(dt); 65 lcd.clear(); 66 lcd.setCursor(0,0); 67 lcd.print("Humidity is "); 68 lcd.setCursor(2,1); 69 lcd. print (humidity); 70 delay(dt); 71 lcd.clear(); 72 lcd.print("Thank You"); 73 delay(1000); 74 lcd.clear(); 75 } 76 77 else if (ic == "0"){ //Lamp Switch OFF 78 rBright=0; 79 bBright=0; 80 gBright=0; 81 dfact=0; 82 83 } 84 else if (ic == "7"){ //Lamp Switch ON 85 rBright=255; 86 bBright=255; 87 gBright=255; 88 dfact=1; 89 90 } 91 92 else if (ic == "Red"){ 93 rBright=255; 94 bBright=0; 95 gBright=0; 96 dfact=1; 97 } 98 else if (ic== "Blue"){ 99 rBright=0; 100 bBright=255; 101 gBright=0; 102 dfact=1; 103 } 104 else if (ic == "Green"){ 105 rBright=0; 106 bBright=0; 107 gBright=255; 108 dfact=1; 109 } 110 else if (ic== "Cyan"){ 111 rBright=0; 112 bBright=255; 113 gBright=255; 114 dfact=1; 115 } 116 else if (ic == "Magenta"){ 117 rBright=255; 118 bBright=255; 119 gBright=0; 120 dfact=1; 121 } 122 else if (ic == "Yellow"){ 123 rBright=255; 124 bBright=0; 125 gBright=255; 126 dfact=1; 127 } 128 129 130 else if (ic =="25"){ 131 dfact=0.25; 132 } 133 else if (ic =="50"){ 134 dfact=0.5; 135 } 136 else if (ic =="75"){ 137 dfact=0.75; 138 } 139 else if (ic =="100"){ 140 dfact=1; 141 } 142 143 analogWrite(rPin, dfact*rBright); 144 analogWrite(gPin, dfact*gBright); 145 analogWrite(bPin, dfact*bBright); 146 } 147 }
Downloadable files
Circuit Diagram
Circuit Diagram
Comments
Only logged in users can leave comments
yehya137
0 Followers
•0 Projects
Table of contents
Intro
0
0