Automatic Chicken Coop Door (Porte Automatique Poulailler)
Automatically open and close the chicken coop door (poulailler in French) at local sunrise and sunset as well manually if/when needed.
Components and supplies
1
Graphic OLED, 128 x 64 Pixels
1
Plastic Enclosure, Project Box
1
5 mm LED: Green
1
Jumper wires (generic)
1
Linear Solenoid, 12.2 VDC
1
Perma-Proto Breadboard Half Size
3
Proximity Sensor
1
Level Shifter Board
1
SparkFun Benchtop Power Board Kit
1
5 mm LED: Red
2
LED Strip, 4 LEDs
2
Timer, Oscillator & Pulse Generator IC
1
Arduino Nano R3
1
Real Time Clock (RTC)
1
Chip Antenna, 433 MHz
1
Rechargeable Battery, 12 V
1
Test Accessory, AC Power Adapter
1
4-port Relay Board
3
Pushbutton Switch, Momentary
7
Phone Audio Connector, Jack
Project description
Code
Chicken
csharp
Automatic Chicken coop door operating system
1#include <math.h> 2#include <Dusk2Dawn.h> // 3 This library seems to take the least memory and does what is needed 4#include 5 <Arduino.h> 6#include <Wire.h> 7#include <RTClib.h> // 8 Library for the RTC (real Time Clock). The project uses a DS1307 to which a Dallas 9 DS18B20 / 1-Wire Digital Thermometer TO-92 was added 10 // 11 IMPORTANT NOTE: as this project uses both 3.3V (RTC) and 5V (the others) I2C modules. 12 Be sure to add a bi-direction level shifter or you are likely to blow-up your Arduino. 13 I did that twice before getting the message... :-( 14#include <RCSwitch.h> // 15 Library for the 433Mhz remote control 16#include <U8x8lib.h> // 17 This library seems to take the least memory and does what is needed 18 19#include 20 <OneWire.h> // These two libraries are used to measure 21 the temperature with the DS18B20 soldered onto the RTC 22#include <DallasTemperature.h> 23 24/* 25 ---------------------- Some basic settings you will need/want to change to suit 26 your needs ---------------------------------- */ 27 28#define myLatitude 43.649572 29 // My chicken coop location 30#define myLongtitude 3.562498 31#define 32 myTimezone 0.0 // In case you need to adjust your timezone. 33 See the library documentation for details 34 35int myDoorDuration = 34; 36 // Time to open or close the door. The time duration in seconds 37 we need to provide power to the linear actuator 38int closingPause = 3; 39 // Number of minutes the Door Closing will pause when an obstacle 40 is detected inside the door while closing 41 42int sunRiseOffset = 0; // 43 Number of minutes the coop door will open earlier / later than the calculated time 44int 45 sunSetOffset = 30; // Number of minutes the coop door will 46 close earlier / later than the calculated time 47 48int enableFlash1 = 49 1; // Setting to enable Flash1 or not. 1=ON, 0=OFF. Obstacle detector 50 and Flash LED above the door (that closes at night) pointing outwards 51int enableFlash2 52 = 1; // Setting to enable Flash2 or not. 1=ON, 0=OFF. Obstacle 53 detector and Flash LED above the door to the garden pointing outwards (door does 54 not close automatically at night), pointing outwards 55int flash1duration = 56 3; // Duration of the flash light in seconds above the door (that 57 closes at night) pointing outwards 58int flash2duration = 3; // 59 Duration of the flash light in seconds above the door to the garden pointing outwards 60 (door does not close automatically at night), pointing outwards 61 62int screenOnTime 63 = 10; // Duration in seconds the screen stays on. Required 64 as there is a conflict between the 'screen on' state of the OLED with the used library 65 and RCSwitch. When the screen is on, the remote control signals are not captured.... 66int 67 enableRemote = 1; // Setting to use remote control or not. 68 1=ON, 0=OFF 69 70unsigned long remoteDoorOpen = 1396644; // These 4 rows 71 contain the codes from the 433Mhz remote-control. You will need to use the RCSwitch 72 > ReceiveDemo_Simple from the IDE examples to detect yours and update these codes 73 74unsigned long remoteDoorClose = 1396648; 75unsigned long remoteDoorStop = 76 1396641; 77unsigned long remoteLightFlash = 1396642; 78 79 80#define ONE_WIRE_BUS 81 A3 // Analog pin for the data wire for temperature measuments 82 83/* 84 ---------------------- These settings are only needed to be changed if you also 85 change the electric wiring ------------------ */ 86 87const int openRelay = 88 3; // This project uses a linear actuator and only requires +/- 89 12V for actioning which is managed by 2 relays 90const int closeRelay = 4; 91const 92 int obstacleDoor = 5; // IR Obstacle detector inside the door 93 94const 95 int DoorOpenLed = 6; // Lights up when the door is open 96const 97 int DoorClosedLed = 7; // Lights up when the door is closed 98const 99 int pushOpen = 8; // Open the door 100const int pushClose 101 = 9; // Close the door 102 103const int obstacleFlash1 = 10; 104 // IR obstacle detector above the door (that closes at night) pointing 105 outwards 106const int obstacleFlash2 = 11; // IR obstacle detector 107 above the door to the garden pointing outwards (door does not close automatically 108 at night), pointing outwards 109 110const int flash1Relay = 12; // 111 Actioning the flash-light door (outside obstacle) 112const int flash2Relay = 113 13; // Actioning the flash-light exterior (exterior obstacle) 114 115int 116 screenSwitch = A2; // Analog pin for the momentary push 117 button to switch-on the OLED 118 119 120 121/* ---------------------- End of settings 122 ----------------------------------------------------------------------------------------- 123 */ 124 125 126RTC_DS1307 rtc; // if you are getting a 127 "165" output on the OLED instead of the propoer time & date, you probably need 128 to use a 3.3V pin instead of a 5V pin for your RTC module (and therefore a I2C level 129 shifter) 130RCSwitch mySwitch = RCSwitch(); 131U8X8_SSD1306_128X64_NONAME_HW_I2C 132 u8x8(/* reset=*/ U8X8_PIN_NONE); 133 134Dusk2Dawn myLocation(myLatitude, myLongtitude, 135 myTimezone); 136 137OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire 138 instance to communicate with any OneWire devices (not just Maxim/Dallas temperature 139 ICs) 140DallasTemperature sensors(&oneWire); // Pass our oneWire reference 141 to Dallas Temperature chip. 142 143int year, month, day, hour, minute, second, x, 144 mySunrise, mySunset, mySRHR, mySRMN, mySDHR, mySDMN, myDoor, myDoorObstacle, closingDuration, 145 pausedAfter, myNow, myCounter, myTemp; 146int doorDetection = HIGH; // no obstacle 147int 148 flash1Detection = HIGH; // no obstacle 149int flash2Detection = HIGH; // no 150 obstacle 151 152int myDoorStatus = 0; 153int myPause = 0; 154long startDoorMovement; 155long 156 stopDoorMovement; 157 158/* 159 // myDoorStatus = 0 => default value at startup. 160 Status will show "Initiate". Press the open or close button at startup (depending 161 the actual door status) to change and capture the correct status 162 // myDoorStatus 163 = 1 => Door open 164 // myDoorStatus = 2 => Door opening 165 // myDoorStatus = 166 3 => Door closed 167 */ 168 // Most activity is managed 169 thru functions in order to keep the core code clean and easily update/add functionality 170void 171 openDoor(); 172void closeDoor(); 173void stopDoor(); 174void flash1(); 175void 176 flash2(); 177void checkRemote(); 178void getTime(); 179void getRiseAndSet(); 180 181// 182 A number of messages to print on the OLED. 183void screenON(); 184void printMain(); 185void 186 printDate(); 187void printTime(); 188void printSunrise(); 189void printSunset(); 190 191void 192 printInitiate(); 193void printOpening(); 194void printOpen(); 195void printClosing(); 196void 197 printClosed(); 198void printPaused(); 199void printFlash1(); 200void printFlash2(); 201void 202 printTemp(); 203void printCounter(); 204void resetCounter(); 205 206/* ---------------------- 207 Program Setup ------------------ */ 208void setup() { 209 Serial.begin(9600); 210 211 212 if (! rtc.begin()) { 213 Serial.println("Couldn't find RTC"); 214 while 215 (1); 216 } 217 218 Wire.begin(); 219 mySwitch.enableReceive(0); // 220 Receiver on interrupt 0 => that is pin #2 It can also be (1), that would be pin 221 #3 222 223 u8x8.initDisplay(); 224 u8x8.clearDisplay(); 225 u8x8.setPowerSave(0); 226 227 u8x8.setFont(u8x8_font_victoriamedium8_r); // This font allows for 7 rows on 228 the OLED 28X64 229 230 //rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Note 231 that if you are having a (charged) battery on your RTC you need to run this command 232 only once. If you let it run each time the code boots, it will reset the date/time 233 to the original loaded when it was connected thru USB when you reboot the board. 234 235 236 237 sensors.begin(); // IC Default 9 bit. If you have troubles 238 consider upping it 12. Ups the delay giving the IC more time to process the temperature 239 measurement 240 241 // Before you connect 242 the relay board check the Voltage required to make the relays function correctly. 243 In my case I need to supply it with 12V on the JD-VCC pin and GND (read: don't use 244 GND from the Arduino board in this case). 245 pinMode(openRelay, OUTPUT); 246 // set pin as output for relay 1 247 pinMode(closeRelay, OUTPUT); 248 // set pin as output for relay 2 249 pinMode(DoorOpenLed, OUTPUT); 250 // set pin as output for DoorOpenLed 251 pinMode(DoorClosedLed, OUTPUT); 252 // set pin as output for DoorClosedLed 253 pinMode(flash1Relay, OUTPUT); 254 // set pin as output for relay 3 255 pinMode(flash2Relay, OUTPUT); 256 // set pin as output for relay 4 257 258 pinMode(obstacleDoor, INPUT); 259 // set pin as input for the door obstacle infrared detector 260 pinMode(obstacleFlash1, 261 INPUT); // set pin as input for the IR obstacle detector above the door 262 (that closes at night) pointing outwards 263 pinMode(obstacleFlash2, INPUT); // 264 set pin as input for the IR obstacle detector above the door to the garden pointing 265 outwards (door does not close at night), pointing outwards 266 pinMode(pushOpen, 267 INPUT); // set pin as intput for pushbutton to manually open 268 the coop door 269 pinMode(pushClose, INPUT); // set pin as intput 270 for pushbutton to manually close the coop door 271 272 digitalWrite(DoorOpenLed, 273 LOW); // Keep both LED's off at startup 274 digitalWrite(DoorClosedLed, 275 LOW); 276 digitalWrite(openRelay, HIGH); // keep the motor off at 277 start-up by keeping both HIGH 278 digitalWrite(closeRelay, HIGH); 279 digitalWrite(flash1Relay, 280 HIGH); // keep the flash-lights off at start-up by keeping both HIGH 281 282 digitalWrite(flash2Relay, HIGH); 283 284 285 printInitiate(); // 286 Write the "Initiate message to the OLED 287 screenON(); // 288 Update all other info on the OLED and swith it on for the duration set in the settings 289 above 290 291 } 292 293/* ---------------------- Main Program Section ------------------ 294 */ 295void loop() { 296 297 getTime(); 298 if (analogRead(screenSwitch) >700) 299 {screenON();} // Check if we need to switch the screen 300 on for a moment. 433Mhz RC does not work during 'screenOn time' due to a conflict 301 in libraries. 302 303 if(myNow==0){getRiseAndSet(); printSunrise(); printSunset(); 304 printDate();} // At the start of a new day (at zero hours) we update the Sunrise 305 & Sunset data 306 307 // Below the logic deciding the opening & closing of 308 the door 309 // myDoorStatus = 1 => Door open 310 // myDoorStatus = 2 => Door 311 opening 312 // myDoorStatus = 3 => Door closed 313 314 if((myNow == mySunrise) 315 && (myDoorStatus != 1)) {openDoor(); } 316 if((myNow == myPause) && (myDoorStatus 317 == 2)) {digitalWrite(DoorOpenLed, HIGH); closeDoor();} 318 if((myNow == mySunset) 319 && (myDoorStatus != 3)) {closeDoor();} 320 321 if((digitalRead(pushClose) 322 == HIGH) && (myDoorStatus != 3)) {closeDoor();} 323 if((digitalRead(pushOpen) 324 == HIGH) && (myDoorStatus != 1)) {openDoor();} 325 326 // Below the logic for 327 the intrudor alerts 328 if((enableFlash1==1) && (digitalRead(obstacleFlash1) == 329 LOW) && (myNow > mySunset)) {flash1();} 330 if((enableFlash1==1) && (digitalRead(obstacleFlash1) 331 == LOW) && (myNow < mySunrise)) {flash1();} 332 if((enableFlash2==1) && (digitalRead(obstacleFlash2) 333 == LOW) && (myNow > mySunset)) {flash2();} 334 if((enableFlash2==1) && (digitalRead(obstacleFlash2) 335 == LOW) && (myNow < mySunrise)) {flash2();} 336 337 if((myNow < myPause) && (myPause!=0)){ 338 339 digitalWrite(DoorClosedLed, !digitalRead(DoorClosedLed)); // Alternating 340 the 'open' and 'closed' LED's to show the door is paused 341 digitalWrite(DoorOpenLed, 342 !digitalRead(DoorOpenLed)); 343 } 344 345 checkRemote(); // 346 Catching the remote control signal every second 347 stopDoor(); 348 349 delay(1000); 350 // Create a 1 second 351 delay in order to avoid 'panic mode' 352}// loop end 353 354 355/* ---------------------- 356 Program Funtions ------------------ */ 357 358 359/* ---------------------- 360 Door Funtions ------------------ */ 361void openDoor() 362{ 363 digitalWrite(openRelay, 364 LOW); // turn relay 1 ON 365 digitalWrite(closeRelay, 366 HIGH); // turn relay 2 OFF 367 printOpening(); 368 myCounter=myDoorDuration; 369 370 // loop to make the LED blink while the door is opening 371 for (int i = 372 0; i <= myDoorDuration*2; i++) { 373 if ( (i % 2) == 0) { myCounter=myCounter-1; 374 u8x8.setCursor(8, 7); u8x8.print(" "); u8x8.setCursor(8, 7);u8x8.print(myCounter);u8x8.setCursor(11, 375 7);u8x8.print("sec."); } 376 digitalWrite(DoorOpenLed, !digitalRead(DoorOpenLed)); 377 378 getTime(); 379 //printTime(); 380 //checkRemote(); 381 delay(500); 382 383 } 384 myDoorStatus = 1; // Status=1 ==> Door is open 385 digitalWrite(DoorClosedLed, 386 LOW); 387 digitalWrite(DoorOpenLed, HIGH); 388 resetCounter; 389 printOpen(); 390}//openDoor() 391 392 393void 394 closeDoor() 395{ 396 //startDoorMovement = millis(); 397 digitalWrite(openRelay, 398 HIGH); // turn relay 1 OFF 399 digitalWrite(closeRelay, 400 LOW); // turn relay 2 ON 401 myDoorStatus = 2; // Status=2 402 ==> Door is closing 403 printClosing(); 404 if (myPause!=0) {closingDuration=myDoorDuration-pausedAfter; 405 myPause=0;} else {closingDuration=myDoorDuration;} 406 myCounter=closingDuration; 407 408 for (int i = 0; i <= closingDuration*2; i++) { 409 if ( (i & 0x01) == 0) 410 { myCounter=myCounter-1; u8x8.setCursor(8, 7); u8x8.print(" "); u8x8.setCursor(8, 411 7);u8x8.print(myCounter);u8x8.setCursor(11, 7);u8x8.print("sec.");} 412 printCounter; 413 414 digitalWrite(DoorClosedLed, !digitalRead(DoorClosedLed)); 415 doorDetection 416 = digitalRead(obstacleDoor); 417 getTime(); 418 //printTime(); 419 //checkRemote(); 420 421 if(doorDetection == LOW){ getTime(); 422 myPause=myNow+closingPause; 423 424 pausedAfter=round((i/2)+0.5); // adding 0.5 425 will ensure we round the number up or down correctly as 'round' always rounds down. 426 427 printPaused(); 428 digitalWrite(DoorClosedLed, 429 HIGH); 430 digitalWrite(DoorOpenLed, LOW); 431 stopDoor(); 432 433 return; 434 } 435 436 delay(500); 437 } 438 myDoorStatus = 3; // Status=3 ==> Door is closed 439 440 digitalWrite(DoorOpenLed, LOW); 441 digitalWrite(DoorClosedLed, HIGH); 442 443 resetCounter; 444 printClosed(); 445 446}//closeDoor() 447 448 449void stopDoor() 450{ 451 452 digitalWrite(openRelay, HIGH); // turn relay 1 OFF 453 454 digitalWrite(closeRelay, HIGH); // turn relay 2 OFF 455 456 resetCounter(); 457}//stopDoor() 458 459 460 461/* ---------------------- Flash 462 light Funtions ------------------ */ 463 464void flash1() 465{ 466 printFlash1(); 467 468 digitalWrite(flash1Relay, LOW); 469 delay(flash1duration*1000); 470 digitalWrite(flash1Relay, 471 HIGH); 472 if(myDoorStatus==1){printOpen();} 473 if(myDoorStatus==3){printClosed();} 474} 475 476 477void 478 flash2() 479{ 480 printFlash2(); 481 digitalWrite(flash2Relay, LOW); 482 delay(flash1duration*1000); 483 484 digitalWrite(flash2Relay, HIGH); 485 if(myDoorStatus==1){printOpen();} 486 487 if(myDoorStatus==3){printClosed();} 488} 489 490 491/* ---------------------- 492 Remote Control Funtion ------------------ */ 493 494void checkRemote() 495{ 496 497 if (enableRemote==1){ 498 /* Serial.print("Received "); 499 Serial.print( 500 mySwitch.getReceivedValue() ); 501 Serial.print(" / "); 502 Serial.print( 503 mySwitch.getReceivedBitlength() ); 504 Serial.print("bit "); 505 Serial.print("Protocol: 506 "); 507 Serial.println( mySwitch.getReceivedProtocol() ); */ 508 509 510 u8x8.setCursor(8, 7); u8x8.print(" "); u8x8.setCursor(8, 7);u8x8.print("remote"); 511 512 if ((mySwitch.getReceivedValue()==remoteDoorOpen) && (myDoorStatus != 1)) 513 {openDoor(); } 514 if ((mySwitch.getReceivedValue()==remoteDoorClose) && 515 (myDoorStatus != 3)) {closeDoor(); } 516 if ( mySwitch.getReceivedValue()==remoteDoorStop) 517 {stopDoor(); } 518 if ( mySwitch.getReceivedValue()==remoteLightFlash) 519 {flash1(); flash2(); } 520 mySwitch.resetAvailable(); 521 522 } 523} //checkRemote 524 525 526/* 527 ---------------------- Time related Funtions ------------------ */ 528void getTime() 529{ 530 531 DateTime now = rtc.now(); 532 year = now.year(); 533 month = now.month(); 534 535 day = now.day(); 536 hour = now.hour(); 537 minute = now.minute(); 538 539 second = now.second(); 540 myNow = (hour*60)+minute; // Create a 541 "minutes after midnight" integer in order to easily compare with the sunRise & 542 sunSet from Dusk2Dawn 543}//getTime 544 545void getRiseAndSet() 546{ 547 getTime(); 548 // Get my local Sunrise and Sunset time for today 549 550 mySunrise = myLocation.sunrise(year, month, day, true); 551 mySunset = myLocation.sunset(year, 552 month, day, true); 553 554 char time[6]; // Calculate 555 the local Sunrise + Sunset hours and minutes (as the function provides minutes after 556 midnight) so we can print them on the OLED 557 Dusk2Dawn::min2str(time, mySunrise); 558 559 mySunrise = mySunrise + sunRiseOffset; 560 mySRHR = int(mySunrise/60); 561 mySRMN 562 = int(mySunrise - (mySRHR*60)); 563 564 Dusk2Dawn::min2str(time, mySunset); 565 566 mySunset = mySunset + sunSetOffset; 567 mySDHR = int(mySunset/60); 568 mySDMN 569 = int(mySunset - (mySDHR*60)); 570}//getRiseAndSet 571 572 573/* ---------------------- 574 OLED screen messages Funtions ------------------ */ 575 576// If ever you want 577 to translate or modify the text shown on the OLED, this is the place to be ;-) 578 579void 580 screenON() 581{ 582 u8x8.setPowerSave(0); // Switch-on the OLED (Remote 583 control messages are received, but not executed until the screen switches-off... 584 585 printMain(); 586 getRiseAndSet(); // Get sunRise & sunSet 587 for today 588 printSunrise(); 589 printSunset(); 590 printDate(); 591 printTemp(); 592 593 594 for (int i = 0; i <= screenOnTime; i++) { 595 getTime(); 596 printTime(); 597 598 delay(1000); // Sow the time pogressing whilst the 599 OLED is on. 600 } 601 u8x8.setPowerSave(1); // Switch-off the 602 OLED 603}// screenON 604 605void printMain() 606{ 607 u8x8.setCursor(0,0); u8x8.print("Date:"); 608 609 u8x8.setCursor(0,1); u8x8.print("Time:"); 610 u8x8.setCursor(0,3); u8x8.print("Sunrise 611 | Sunset"); 612 u8x8.setCursor(8,4); u8x8.print("|"); 613 u8x8.setCursor(0,6); 614 u8x8.print("---- Status: ---"); 615}//printMain 616 617 618void printInitiate(){u8x8.setCursor(0, 619 7); u8x8.print(" "); u8x8.setCursor(0, 7);u8x8.print("Initiate");} //initiate 620 the status. Press the open or close button (depending actual door status) to change 621 and capture the correct status 622void printOpening() {u8x8.setCursor(0, 7); u8x8.print(" 623 "); u8x8.setCursor(0, 7);u8x8.print("Opening ");} //open 624void printOpen() 625 {u8x8.setCursor(0, 7); u8x8.print(" "); u8x8.setCursor(0, 7);u8x8.print("Open 626 ");} //opening 627void printClosing() {u8x8.setCursor(0, 7); u8x8.print(" 628 "); u8x8.setCursor(0, 7);u8x8.print("Closing ");} //closing 629void printClosed() 630 {u8x8.setCursor(0, 7); u8x8.print(" "); u8x8.setCursor(0, 7);u8x8.print("Closed 631 ");} //closed 632void printPaused() {u8x8.setCursor(0, 7); u8x8.print(" "); 633 u8x8.setCursor(0, 7);u8x8.print("Paused ");} //paused 634void printFlash1() 635 {u8x8.setCursor(0, 7); u8x8.print(" "); u8x8.setCursor(0, 7);u8x8.print("Flash 636 1 ");} //printFlash1 637void printFlash2() {u8x8.setCursor(0, 7); u8x8.print(" 638 "); u8x8.setCursor(0, 7);u8x8.print("Flash 2 ");} //printFlash2 639void 640 printCounter() {u8x8.setCursor(8, 7); u8x8.print(" "); u8x8.setCursor(8, 641 7);u8x8.print(myCounter);u8x8.setCursor(11, 7);u8x8.print("sec."); }//printCounter 642void 643 resetCounter() {u8x8.setCursor(8, 7); u8x8.print(" ");}//resetCounter 644 645void 646 printDate() 647{ 648 u8x8.setCursor(5,0); 649 if (day<=9) {u8x8.print("0");} 650 u8x8.print(day); u8x8.print("-"); 651 if (month<=9){u8x8.print("0");} u8x8.print(month);u8x8.print("-"); 652 653 u8x8.print(year); 654}// printDate() 655 656void printTime() 657{ 658 //u8x8.setPowerSave(1); 659 660 u8x8.setCursor(5,1); 661 if (hour<=9) {u8x8.print("0");} u8x8.print(hour); 662 u8x8.print(":"); 663 if (minute<=9){u8x8.print("0");} u8x8.print(minute);u8x8.print(":"); 664 665 if (second<=9){u8x8.print("0");} u8x8.print(second); 666} // printTime(); 667 668void 669 printSunrise() 670{ 671 u8x8.setCursor(1, 4); if (mySRHR<=9){u8x8.print("0");} 672 u8x8.print(mySRHR); 673 u8x8.setCursor(3,4); u8x8.print(":"); 674 u8x8.setCursor(4,4); 675 if (mySRMN<=9){u8x8.print("0");} u8x8.print(mySRMN); 676}//printSunrise 677 678void 679 printSunset() 680{ 681 u8x8.setCursor(10, 4); if (mySDHR<=9){u8x8.print("0");} 682 u8x8.print(mySDHR); 683 u8x8.setCursor(12,4); u8x8.print(":"); 684 u8x8.setCursor(13,4); 685 if (mySDMN<=9){u8x8.print("0");}u8x8.print(mySDMN); 686}//printSunset 687 688void 689 printTemp() 690{ 691 sensors.requestTemperatures(); // 692 Send the command to get temperatures 693 myTemp = round(sensors.getTempCByIndex(0)+0.5); 694 // If you want to show Fahrenheit, you need to change the C to 695 F 696 //Serial.print(myTemp); // Why 697 "byIndex"? You can have more than one IC on the same bus. 0 refers to the first 698 IC on the wire 699 u8x8.setCursor(13, 7); u8x8.print(" "); u8x8.setCursor(13, 700 7);u8x8.print(myTemp);u8x8.setCursor(15, 7);u8x8.print("C"); 701}//printTemp 702 703 704/* 705*/ 706
Downloadable files
Chicken
Chicken
Chicken
Chicken
Comments
Only logged in users can leave comments