Skip to content

Instantly share code, notes, and snippets.

@zoellner
Last active September 23, 2017 12:22
Show Gist options
  • Save zoellner/5585857 to your computer and use it in GitHub Desktop.
Save zoellner/5585857 to your computer and use it in GitHub Desktop.
Grideye demo for Grid-EYE Evaluation Unit with COM-00759 RG LED Array (8x8). based on http://pewa.panasonic.com/assets/pcsd/manuals/grid-eye/grid-eye-arduino-code-examples.pdf . corrected errors in original code. Now using SPI library and serial output of data
#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;
float celsius;
unsigned long time;
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);
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);
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;
Serial.print(celsius,2);
Serial.print(" ");
}
Serial.println(" ");
//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
@isitro
Copy link

isitro commented Sep 23, 2017

hi nucflash , same problems for me too , now is ok

first : time is a reserved for a function and here was written and orange coloured , substitue it with Time as a variable declaration , and so no comp error

two : change Wire.nnnnn with Wire1.nnnn ,exepted Wire.h is ok at the firsts lines ..
because ard due with the grid eye ev kit uses pins sda1 and scl1 located near aref pin on the board , with the file written on the original mode
ard2 writes and reads on the standard sda and scl pins (20 and 21 pins) hasnt connection with the ev board ...

enjoy

isidoro modiano italy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment