#include <Adafruit_NeoPixel.h> // download from adafruit's github
#include <Wire.h>
#include <Adafruit_TMP006.h> // download from adafruit's github
#define PIN 0
#define debug false
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_TMP006 tmp006;
int temp = 28;
void setup(void) {
strip.begin();
strip.show();
// Serial.begin(9600); // when uncommmented, neopixel does not work
#ifdef debug
if (! tmp006.begin()) {
Serial.println("No sensor found");
while (1);
}
#endif
}
void loop(void) {
float objt = tmp006.readObjTempC(); // temperature of the object pointed
// Serial.print("Object Temperature: "); Serial.print(objt); Serial.println("*C");
// float diet = tmp006.readDieTempC(); // temperature of the sensor itself
// Serial.print("Die Temperature: "); Serial.print(diet); Serial.println("*C");
// temp declared earlier
if (objt > temp){
colorWipe(strip.Color(55, 0, 0), 50);
}
else if (objt < temp){
colorWipe(strip.Color(0, 0, 55), 50);
}
else if (objt == temp){
colorWipe(strip.Color(0, 55, 0), 50);
}
delay(1000);
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
0 Comments
int fsrAnalogPin = 3; // FSR is connected to analog 3 Accelerometer: Adafruit ADXL345 [link] Gyroscope: Adafruit L3GD20 [link] For the Arduino Uno, SCL: A5 and SDA: A4 This is just a simple code to run the accelerometer and gyroscope at the same time. It is mostly adapted from the library. #include <Wire.h> |
Categories
All
|