Last active
September 23, 2017 12:22
Revisions
-
zoellner revised this gist
May 15, 2013 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,8 @@ byte pixelTempL; byte pixelTempH; int ledNum = 1; char addr = 0x68; float celsius; unsigned long time; void setup() { Wire.begin(); @@ -38,12 +39,17 @@ void loop() Wire.requestFrom(addr,1); byte lowerLevelTherm = Wire.read(); int temperatureTherm = ((lowerLevelTherm << 8) | upperLevelTherm); float celsiusTherm = temperatureTherm*0.0625; //First two data registers for the pixel temp data are 0x80 and 0x81 pixelTempL=0x80; pixelTempH=0x81; //Get Temperature Data for each pixel in the 8x8 array. Will loop 64 times. time = millis(); Serial.print(time); Serial.print(" "); Serial.print(celsiusTherm,4); Serial.print(" "); for(int pixel = 0; pixel <= 63; pixel++){ //Get lower level pixel temp byte Wire.beginTransmission(addr); @@ -79,7 +85,10 @@ void loop() //Go to next pixel by advancing both the low and high bit two register values pixelTempL=pixelTempL+2; pixelTempH=pixelTempH+2; Serial.print(celsius,2); Serial.print(" "); } Serial.println(" "); //Transfer color contents of LED array for display digitalWrite(SLAVESELECT, LOW); @@ -90,4 +99,3 @@ void loop() delayMicroseconds(500); digitalWrite(SLAVESELECT, HIGH); } //end loop -
zoellner created this gist
May 15, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ #include <Wire.h> #include <SPI.h> //define our colors for LED Array #define GREEN 0x01 #define RED 0x02 #define ORANGE 0x03 //define the SPI pins for the LED Array #define SLAVESELECT 10//ss char ledArray [64]; byte pixelTempL; byte pixelTempH; int ledNum = 1; char addr = 0x68; int celsius; void setup() { Wire.begin(); Serial.begin(115200); SPI.begin(); // initialize the SPI library SPI.setClockDivider(SPI_CLOCK_DIV128); // set clock to 125kHz for 16MHz board //Make sure the RG matrix is deactivated digitalWrite(SLAVESELECT,HIGH); } void loop() { //Thermistor Register - Optional Wire.beginTransmission(addr); Wire.write(0x0E); Wire.endTransmission(); Wire.requestFrom(addr,1); byte upperLevelTherm = Wire.read(); Wire.beginTransmission(addr); Wire.write(0x0F); Wire.endTransmission(); Wire.requestFrom(addr,1); byte lowerLevelTherm = Wire.read(); int temperatureTherm = ((lowerLevelTherm << 8) | upperLevelTherm); int celsiusTherm = temperatureTherm*0.0625; //First two data registers for the pixel temp data are 0x80 and 0x81 pixelTempL=0x80; pixelTempH=0x81; //Get Temperature Data for each pixel in the 8x8 array. Will loop 64 times. for(int pixel = 0; pixel <= 63; pixel++){ //Get lower level pixel temp byte Wire.beginTransmission(addr); Wire.write(pixelTempL); Wire.endTransmission(); Wire.requestFrom(addr,1); byte lowerLevel = Wire.read(); // //Get upper level pixel temp byte Wire.beginTransmission(addr); Wire.write(pixelTempH); Wire.endTransmission(); Wire.requestFrom(addr,1); byte upperLevel = Wire.read(); //Combine the two bytes together to complete the 12-bit temp reading int temperature = ((upperLevel << 8) | lowerLevel); //Temperature data is in two's compliment, do conversion. if (upperLevel != 0) { temperature = -(2048 - temperature); } celsius = temperature*0.25; //Determine LED color based on temperature of pixel if (celsius < 26) { ledArray[pixel]=GREEN; } else if (celsius >=26 && celsius <=30) { ledArray[pixel]=ORANGE; } else { ledArray[pixel]=RED; } //Go to next pixel by advancing both the low and high bit two register values pixelTempL=pixelTempL+2; pixelTempH=pixelTempH+2; } //Transfer color contents of LED array for display digitalWrite(SLAVESELECT, LOW); delayMicroseconds(500); for(int pixel=0; pixel<=63; pixel++){ SPI.transfer(ledArray[pixel]); } delayMicroseconds(500); digitalWrite(SLAVESELECT, HIGH); } //end loop