Components and supplies
Plexiglass 4 mm
Temperature Sensor
Resistor 221 ohm
Standard LCD - 16x2 White on Blue
Breadboard (generic)
Sunfounder Starter RFID Kit
Jumper wires (generic)
IR receiver (generic)
DS1307 64 x 8, Serial, I²C Real-Time Clock
Arduino UNO
Water Level Sensor
DHT11 Temperature & Humidity Sensor (4 pins)
USB-A to Micro-USB Cable
Photo resistor
Tools and machines
Laser cutter (generic)
Project description
Code
AWS code.ino
c_cpp
1//include sketch libraries 2#include <IRremote.h> 3#include <stdio.h> //clock library 4#include <string.h> //clock library 5#include <DS1302.h> //clock library 6#include <dht.h> //dht11 library 7#include <LiquidCrystal_I2C.h> //LCD library 8#include <Wire.h> //Wire for LCD library 9 10#define lmPin A1 //LM35 attach to A1 11 12LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display 13dht DHT; //create a variable type of dht 14 15const int DHT11_PIN = 4; //attach dht11 to pin 4 16const int waterSensor = 0; //set water sensor variable 17int waterValue = 0; //variable for water sensor 18int mmwaterValue = 0; 19int sensorPin = A3; // select the input pin for the potentiometer 20int luce = 0; //variable for the ldr 21int pluce = 0; //variable for the ldr 22float tem = 0; //variable for the temperature 23long lmVal = 0; //variable for the LM35 24//ir 25const int irReceiverPin = 3; 26IRrecv irrecv(irReceiverPin); //Creates a variable of type IRrecv 27decode_results results; 28 29 30//define clock variable 31uint8_t RST_PIN = 5; //RST pin attach to 32uint8_t SDA_PIN = 6; //IO pin attach to 33uint8_t SCL_PIN = 7; //clk Pin attach to 34/* Create buffers */ 35char buf[50]; 36char day[10]; 37 38 39/* Create a DS1302 object */ 40DS1302 rtc(RST_PIN, SDA_PIN, SCL_PIN);//create a variable type of DS1302 41 42void print_time() 43{ 44 /* Get the current time and date from the chip */ 45 Time t = rtc.time(); 46 /* Name the day of the week */ 47 memset(day, 0, sizeof(day)); 48 switch (t.day) 49 { 50 case 1: 51 strcpy(day, "Sun"); 52 break; 53 case 2: 54 strcpy(day, "Mon"); 55 break; 56 case 3: 57 strcpy(day, "Tue"); 58 break; 59 case 4: 60 strcpy(day, "Wed"); 61 break; 62 case 5: 63 strcpy(day, "Thu"); 64 break; 65 case 6: 66 strcpy(day, "Fri"); 67 break; 68 case 7: 69 strcpy(day, "Sat"); 70 break; 71 } 72 /* Format the time and date and insert into the temporary buffer */ 73 snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d", day, t.yr, t.mon, t.date, t.hr, t.min, t.sec); 74 /* Print the formatted string to serial so we can see the time */ 75 Serial.println(buf); 76 lcd.setCursor(2, 0); 77 lcd.print(t.yr); 78 lcd.print("-"); 79 lcd.print(t.mon / 10); 80 lcd.print(t.mon % 10); 81 lcd.print("-"); 82 lcd.print(t.date / 10); 83 lcd.print(t.date % 10); 84 lcd.print(" "); 85 lcd.print(day); 86 lcd.setCursor(4, 1); 87 lcd.print(t.hr); 88 lcd.print(":"); 89 lcd.print(t.min / 10); 90 lcd.print(t.min % 10); 91 lcd.print(":"); 92 lcd.print(t.sec / 10); 93 lcd.print(t.sec % 10); 94} 95 96void setup() { 97 //clock 98 Serial.begin(9600); 99 rtc.write_protect(false); 100 rtc.halt(false); 101 //ir 102 irrecv.enableIRIn(); //enable ir receiver module 103 104 lcd.init(); //initialize the lcd 105 lcd.backlight(); //open the backlight 106 pinMode(sensorPin, INPUT); 107 Time t(2017, 12, 9, 11, 20, 00, 7);//initialize the time 108 /* Set the time and date on the chip */ 109 rtc.time(t); 110} 111 112void loop() { 113 lcd.setCursor(0, 0); 114 lcd.print("A"); 115 delay(50); 116 lcd.setCursor(1, 0); 117 lcd.print("r"); 118 delay(50); 119 lcd.setCursor(2, 0); 120 lcd.print("d"); 121 delay(50); 122 lcd.setCursor(3, 0); 123 lcd.print("u"); 124 delay(50); 125 lcd.setCursor(4, 0); 126 lcd.print("i"); 127 delay(50); 128 lcd.setCursor(5, 0); 129 lcd.print("n"); 130 delay(50); 131 lcd.setCursor(6, 0); 132 lcd.print("o"); 133 delay(50); 134 lcd.setCursor(8, 0); 135 lcd.print("W"); 136 delay(50); 137 lcd.setCursor(9, 0); 138 lcd.print("e"); 139 delay(50); 140 lcd.setCursor(10, 0); 141 lcd.print("a"); 142 delay(50); 143 lcd.setCursor(11, 0); 144 lcd.print("t"); 145 delay(50); 146 lcd.setCursor(12, 0); 147 lcd.print("h"); 148 delay(50); 149 lcd.setCursor(13, 0); 150 lcd.print("e"); 151 delay(50); 152 lcd.setCursor(14, 0); 153 lcd.print("r"); 154 delay(50); 155 lcd.setCursor(4, 1); 156 lcd.print("S"); 157 delay(50); 158 lcd.setCursor(5, 1); 159 lcd.print("t"); 160 delay(50); 161 lcd.setCursor(6, 1); 162 lcd.print("a"); 163 delay(50); 164 lcd.setCursor(7, 1); 165 lcd.print("t"); 166 delay(50); 167 lcd.setCursor(8, 1); 168 lcd.print("i"); 169 delay(50); 170 lcd.setCursor(9, 1); 171 lcd.print("o"); 172 delay(50); 173 lcd.setCursor(10, 1); 174 lcd.print("n"); 175 delay(50); 176 177if (irrecv.decode(&results)) //if the ir receiver module receiver data 178 { 179if (results.value == 0xFF6897) //if "0" is pushed print TIME 180{ 181 lcd.clear(); //clear the LCD 182 print_time(); 183 delay(10000); //delay 10000ms 184 lcd.clear(); //clear the LCD 185 delay (200); //wait for a while 186 irrecv.resume(); // Receive the next value 187} 188if (results.value == 0xFF30CF) //if "1" is pushed print TEMPERATURE and HUMIDITY 189{ 190 lcd.clear(); //clear the LCD 191 //READ DATA of the DHT 192 int chk = DHT.read11(DHT11_PIN); 193 // DISPLAY DATA 194 lcd.setCursor(0, 0); 195 lcd.print("Tem:"); 196 lmVal = analogRead(lmPin);//read the value of A1 197 tem = (lmVal * 0.0048828125 * 100);//5/1024=0.0048828125;1000/10=100 198 lcd.print(tem);//print tem 199 lcd.print(char(223));//print the unit" " 200 lcd.print("C "); 201 // Serial.println(" C"); 202 lcd.setCursor(0, 1); 203 lcd.print("Hum:"); 204 //Serial.print("Hum:"); 205 lcd.print(DHT.humidity, 1); //print the humidity on lcd 206 //Serial.print(DHT.humidity,1); 207 lcd.print(" % "); 208 //Serial.println(" %"); 209 delay(10000); //wait for 3000 ms 210 lcd.clear(); //clear the LCD 211 delay(200); //wait for a while 212 irrecv.resume(); // Receive the next value 213} 214if (results.value == 0xFF18E7) //if "2" is pushed print the DARKNESS 215{ 216 lcd.clear(); //clear the LCD 217 lcd.setCursor(4, 0); //place the cursor on 4 column, 1 row 218 lcd.print("Darkness:"); 219 luce = analogRead(sensorPin); //read the ldr 220 pluce = map(luce, 0, 1023, 0, 100); //the value of the sensor is converted into values from 0 to 100 221 lcd.setCursor(6, 1); //place the cursor on the middle of the LCD 222 lcd.print(pluce); //print the percentual 223 lcd.print("%"); //print the symbol 224 delay(10000); //delay 10000 ms 225 lcd.clear(); //clear the LCD 226 delay(200); //wait for a while 227 irrecv.resume(); // Receive the next value 228} 229if (results.value == 0xFF7A85) //if "3" is pushed print the SNOW or WATER LEVEL 230{ 231 lcd.clear(); //clear the LCD 232 lcd.setCursor(0, 0); //place the cursor on 0 column, 1 row 233 lcd.print("Fluid level(mm):"); //print "Fluid level(mm):" 234 int waterValue = analogRead(waterSensor); // get water sensor value 235 lcd.setCursor(6, 1); //place cursor at 6 column,2 row 236 mmwaterValue = map(waterValue, 0, 1023, 0, 40); 237 lcd.print(mmwaterValue); //value displayed on lcd 238 delay(10000); //delay 10000ms 239 lcd.clear(); //clear the LCD 240 delay(200); 241 irrecv.resume(); // Receive the next value 242} 243 244if (results.value == 0xFF9867) //if "PRESENTATION" is pushed print TIME, TEM and HUM, DARKNESS and S or W LEVEL one time 245{ 246 lcd.clear(); //clear the LCD 247 print_time(); 248 delay(4000); //delay 10000ms 249 lcd.clear(); //clear the LCD 250 delay (200); //wait for a while 251 252 //READ DATA of the DHT 253 int chk = DHT.read11(DHT11_PIN); 254 // DISPLAY DATA 255 lcd.setCursor(0, 0); 256 lcd.print("Tem:"); 257 lmVal = analogRead(lmPin);//read the value of A0 258 tem = (lmVal * 0.0048828125 * 100);//5/1024=0.0048828125;1000/10=100 259 lcd.print(tem);//print tem 260 lcd.print(char(223));//print the unit" " 261 lcd.print("C "); 262 // Serial.println(" C"); 263 lcd.setCursor(0, 1); 264 lcd.print("Hum:"); 265 //Serial.print("Hum:"); 266 lcd.print(DHT.humidity, 1); //print the humidity on lcd 267 //Serial.print(DHT.humidity,1); 268 lcd.print(" % "); 269 //Serial.println(" %"); 270 delay(4000); //wait for 3000 ms 271 lcd.clear(); //clear the LCD 272 delay(200); //wait for a while 273 274 lcd.setCursor(4, 0); //place the cursor on 4 column, 1 row 275 lcd.print("Darkness:"); 276 luce = analogRead(sensorPin); //read the ldr 277 pluce = map(luce, 0, 1023, 0, 100); //the value of the sensor is converted into values from 0 to 100 278 lcd.setCursor(6, 1); //place the cursor on the middle of the LCD 279 lcd.print(pluce); //print the percentual 280 lcd.print("%"); //print the symbol 281 delay(4000); //delay 10000 ms 282 lcd.clear(); //clear the LCD 283 delay(200); //wait for a while 284 285 lcd.setCursor(0, 0); //place the cursor on 0 column, 1 row 286 lcd.print("Fluid level(mm):"); //print "Fluid level(mm):" 287 int waterValue = analogRead(waterSensor); // get water sensor value 288 lcd.setCursor(6, 1); //place cursor at 6 column,2 row 289 mmwaterValue = map(waterValue, 0, 1023, 0, 40); 290 lcd.print(mmwaterValue); //value displayed on lcd 291 delay(4000); //delay 10000ms 292 lcd.clear(); //clear the LCD 293 delay(200); 294 irrecv.resume(); // Receive the next value 295} 296} 297} 298
Downloadable files
aws_DMDwb4iUZp.fzz
aws_DMDwb4iUZp.fzz
aws_DMDwb4iUZp.fzz
aws_DMDwb4iUZp.fzz
Documentation
box_a5et5f4U9F.dwg
box_a5et5f4U9F.dwg
box_a5et5f4U9F.dwg
box_a5et5f4U9F.dwg
Comments
Only logged in users can leave comments