arduino and friends
  • ardututes
    • Coco
    • twitter
    • IR Remote Piano
    • Light Clapper
    • Capacitive Touch Game
    • Musical Stairs
    • Boots Prank
    • Line Following Robot
  • simple hookups
    • examples

TMP006 + neopixel

12/24/2013

0 Comments

 
#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



Leave a Reply.

    Youtube

    Categories

    All
    Acceleromter
    Etc.
    Ethernet
    Gyroscope
    Neopixel
    Temperature

    RSS Feed

Powered by Create your own unique website with customizable templates.