Skip to content

Instantly share code, notes, and snippets.

@5shekel
Created January 17, 2016 13:16
Show Gist options
  • Save 5shekel/42218b6f97e85597dca3 to your computer and use it in GitHub Desktop.
Save 5shekel/42218b6f97e85597dca3 to your computer and use it in GitHub Desktop.
//game (with cornell)
#define DEBUG 1
//GRID lib using neopixel_grid
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
//pin connected to bus
#define pixpin_grid 5
#define pixpin_BTA 6
#define pixpin_BTB 3
#define pixpin_ST12 4
//number of pixels in bus
#define pixcount_grid 64
#define pixcount_ST12 12
#define pixcount_BTA 11 //bta1 is 2 leds, rest are groups of 3
int bta1 = 0, bta3 = 2, bta5 = 5, bta7 = 8;
#define pixcount_BTB 9 // groups of 3
int btb2 = 0, btb4 = 3, btb6 = 6;
Adafruit_NeoPixel BTA = Adafruit_NeoPixel(pixcount_BTA, pixpin_BTA, NEO_GRB);
Adafruit_NeoPixel BTB = Adafruit_NeoPixel(pixcount_BTB, pixpin_BTB, NEO_GRB);
Adafruit_NeoPixel ST12 = Adafruit_NeoPixel(pixcount_ST12, pixpin_ST12, NEO_GRB);
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, pixpin_grid,
NEO_MATRIX_TOP + NEO_MATRIX_RIGHT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE,
NEO_GRB + NEO_KHZ800);
#define WHITE 0xFFFFFF
void setup() {
if (DEBUG) Serial.begin(57600);
//LED instances
BTA.setBrightness(100); BTB.setBrightness(100); ST12.setBrightness(100);
BTB.begin(); BTA.begin(); ST12.begin();
BTB.show(); BTA.show(); ST12.show() ;
matrix.begin();
matrix.setBrightness(40);
matrix.setTextWrap(false);
matrix.fillScreen(0); //blank
matrix.show();
BTB_on(btb2);
Serial.println("btb2");
delay(1000);
BTB_on(btb4);
Serial.println("btb4");
delay(1000);
BTB_on(btb6);
Serial.println("btb6");
delay(1000);
BTA_on(bta1);
Serial.println("bta1");
delay(1000);
BTA_on(bta3);
Serial.println("bta3");
delay(1000);
BTA_on(bta5);
Serial.println("bta5");
delay(1000);
BTA_on(bta7);
Serial.println("bta7");
delay(1000);
}
void loop() {
}
void BTA_on(int group) {
int length = 3;
if (group == 0) length = 2; //first group has only 2 pixels
for (int iii = group; iii <= length; iii++)
BTA.setPixelColor(iii, WHITE);
}
void BTB_on(int group) {
for (int iii = group; iii <= 3; iii++)
BTB.setPixelColor(iii, WHITE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment