Created
December 7, 2013 18:58
-
-
Save jgraup/7847065 to your computer and use it in GitHub Desktop.
TinkerKit-Examples - http://www.tinkerkit.com/
This file contains hidden or 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
// LED | |
TKLed led(O0); | |
led.on(); // turn LED on | |
led.off(); // turn LED off | |
// BUTTON | |
TKButton button(I0); | |
if (button.get() == HIGH) { // if it is, the button.state() is HIGH | |
led.on(); // turn LED on | |
} | |
else { // if it is not, the button.state() is LOW | |
led.off(); // turn LED off | |
} | |
// TOUCH | |
TKTouchSensor touch(I0); | |
if (touch.get() == HIGH) { | |
led.on(); // turn LED on | |
} else { | |
led.off(); // turn LED off | |
} | |
// POTENTIOMETER | |
TKPotentiometer pot(I0); | |
int brightnessValue = 0; | |
brightnessValue = pot.get(); | |
led.brightness(brightnessValue); | |
// wait 10 milliseconds before the next loop | |
// for the analog-to-digital converter to settle | |
// after the last reading: | |
delay(10); | |
// TILT SENSOR | |
TKTiltSensor tilt(I0); | |
if (tilt.get() == HIGH) { // if it is, the tilt.state() is HIGH | |
led.on(); // turn LED on | |
} | |
else { // if it is not, the tilt.state() is LOW | |
led.off(); // turn LED off | |
} | |
// LIGHT SENSOR | |
TKLightSensor ldr(I0); | |
int brightnessValue = 0; | |
brightnessValue = ldr.get(); | |
led.brightness(brightnessValue); | |
delay(10); // wait 10 milliseconds before the next loop | |
// THERMISTOR | |
TKThermistor therm(I0); | |
float C, F; | |
C = therm.getCelsius(); // Reading the temperature in Celsius degrees and store in the C variable | |
F = therm.getFahrenheit(); // Reading the temperature in Fahrenheit degrees and store in the F variable | |
Serial.begin(9600); | |
// Print the collected data in a row on the Serial Monitor | |
Serial.print("Analog reading: \t"); // Reading the analog value from the thermistor | |
Serial.print(therm.get()); | |
Serial.print("\tC: \t"); | |
Serial.print(C); | |
Serial.print("\tF: \t"); | |
Serial.println(F); | |
delay(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment