Skip to content

Instantly share code, notes, and snippets.

@ShawnHymel
Created May 2, 2018 20:24
Show Gist options
  • Save ShawnHymel/9efcdfd76635fe2b4d85ca01f88022af to your computer and use it in GitHub Desktop.
Save ShawnHymel/9efcdfd76635fe2b4d85ca01f88022af to your computer and use it in GitHub Desktop.
Demo of the Grid-EYE IR sensor using an LED array
/**
* GridEye LED Array Demo
* Author: Shawn Hymel (SparkFun Electronics)
* Date: May 1, 2018
*
* Displays a heat map of what the GridEye sees (8x8 pixels).
*
* Required Components
* - Arduino: https://www.sparkfun.com/products/13975
* - Qwiic Shield: https://www.sparkfun.com/products/14352
* - Qwiic cable: https://www.sparkfun.com/products/14426
* - Grid-EYE Breakout: https://www.sparkfun.com/products/14607
* - 8x8 NeoPixel Array: https://www.sparkfun.com/products/12662
* - Wire: https://www.sparkfun.com/products/8867
*
* Hardware connections:
* - Connect the GridEye over QWIIC
* - 8x8 RGB LED array VCC to 5V (Arduino)
* - 8x8 RGB LED array GND to GND (Arduino)
* - 8x8 RGB LED array DIN to pin 3 (Arduino)
*
* MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Feel like supporting our work? Buy a board from SparkFun!
* https://www.sparkfun.com/products/14607
*/
#include <Wire.h>
#include <FastLED.h>
#include <SparkFun_GridEYE_Arduino_Library.h>
// Parameters
const int MIN_TEMP = 22;
const int MAX_TEMP = 30;
const int NUM_LEDS = 64;
const int MAX_X = 8;
const int MAX_Y = 8;
const int BRIGHTNESS = 50;
const int SATURATION = 255;
// Pins
const int DATA_PIN = 3;
// Globals
CRGB leds[NUM_LEDS];
GridEYE grideye;
uint8_t temps[NUM_LEDS];
void setup() {
// Init LED array
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
// Start I2C and init GridEye
Wire.begin();
grideye.begin();
}
void loop() {
uint8_t idx;
float pixel_temp;
// Read temperature values from GridEye
for ( int y = 0; y < MAX_Y; y++ ) {
for ( int x = 0; x < MAX_X; x++ ) {
// Read temperature and constrain it to a min and max
idx = (y * MAX_X) + x;
pixel_temp = grideye.getPixelTemperature(idx);
if ( pixel_temp < MIN_TEMP ) {
pixel_temp = MIN_TEMP;
} else if ( pixel_temp > MAX_TEMP ) {
pixel_temp = MAX_TEMP;
}
// Map temperatures in an array and rotate image 90 deg CW
temps[(x * MAX_Y) + y] = map( (pixel_temp * 100),
(MIN_TEMP * 100),
(MAX_TEMP * 100),
127,
0 );
// Map temperatures to hue in HSV space
leds[idx] = CHSV(temps[idx], SATURATION, BRIGHTNESS);
}
}
// Let LEDs update
FastLED.show();
delay(50);
}
@ruidantunes
Copy link

Hi, can you send me the schematics to connect a led matriz to a arduino uno?

@ShawnHymel
Copy link
Author

Not sure what kind of LED array you're looking for. This sketch uses the Adafruit NeoPixel 8x8 grid, which you can find how to use here: NeoPixel Uberguide. Here's an example of wiring a basic LED matrix to Arduino. Finally, here is how to wire a Charlieplex array to an Arduino.

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