Created
January 1, 2013 18:23
-
-
Save anonymous/4429135 to your computer and use it in GitHub Desktop.
For Arduino Esplora. Uses built-in sensors to display room temperature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Esplora.h> | |
//Press the Down button on joypad to display current temperature | |
//The red LED blinks the tens value, the blue blinks the ones value. Green indicates end. | |
//example: red red red blue blue green is 32 degrees (F) | |
//the light sensor is used to dim the LEDs in a brightly lit room | |
//copyleft Jan 01 13 www.gordonmeyer.com | |
// delay used to blink lights | |
int flashdelay = 250; | |
void setup(){ | |
} | |
void loop() { | |
if (Esplora.readButton(SWITCH_DOWN) == LOW) { | |
getTemp(); | |
} | |
} | |
void getTemp() { | |
int theTemp = (Esplora.readTemperature(DEGREES_F)); | |
// Serial.print(theTemp); | |
int theTens = (theTemp/10); | |
for (int i = 0; i < theTens; i++) { | |
flashRed(); | |
} | |
int theOnes = (theTemp%10); | |
Serial.print(theOnes); | |
for (int i = 0; i < theOnes; i++) { | |
flashBlue(); | |
} | |
delay (flashdelay); | |
int brt = (Esplora.readLightSensor()/10); | |
Esplora.writeGreen(brt); | |
delay (flashdelay); | |
Esplora.writeRGB(0,0,0); | |
} | |
void flashRed() { | |
// uses room brightness to set LED level | |
int brt = (Esplora.readLightSensor()/10); | |
// Serial.println("bright "); Serial.print(brt); | |
Esplora.writeRed(brt); | |
delay (flashdelay); | |
Esplora.writeRGB(0,0,0); | |
delay (flashdelay); | |
} | |
void flashBlue() { | |
int brt = (Esplora.readLightSensor()/10); | |
Esplora.writeBlue(brt); | |
delay (flashdelay); | |
Esplora.writeRGB(0,0,0); | |
delay (flashdelay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment