Skip to content

Instantly share code, notes, and snippets.

@chris-schmitz
Last active May 2, 2019 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-schmitz/5e1deb552cd249a3ae95ea36fb350a21 to your computer and use it in GitHub Desktop.
Save chris-schmitz/5e1deb552cd249a3ae95ea36fb350a21 to your computer and use it in GitHub Desktop.
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#define break_beam_ONE 11
#define break_beam_TWO 10
int breakBeamState_ONE = 0;
int breakBeamState_TWO = 0;
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
static const uint8_t PROGMEM
slot_1_bmp[] =
{
B00000000,
B00011000,
B00011000,
B00111000,
B00011000,
B00011000,
B00011000,
B01111110},
slot_2_bmp[] =
{
B00000000,
B00111100,
B01100110,
B00000110,
B00001100,
B00110000,
B01100000,
B01111110};
const uint8_t *activeSlot[] PROGMEM = {slot_1_bmp, slot_2_bmp};
void setup()
{
Serial.begin(115200);
// while (!Serial)
// ;
Serial.println("Starting up");
pinMode(break_beam_ONE, INPUT);
digitalWrite(break_beam_ONE, HIGH);
pinMode(break_beam_TWO, INPUT);
digitalWrite(break_beam_TWO, HIGH);
matrix.begin(0x70);
}
int activeIndex;
bool toggle = false;
void loop()
{
toggle = !toggle;
breakBeamState_ONE = digitalRead(break_beam_ONE);
breakBeamState_TWO = digitalRead(break_beam_TWO);
if (toggle)
// if (!breakBeamState_ONE)
{
activeIndex = 0;
}
else if (!toggle)
// else if (!breakBeamState_TWO)
{
activeIndex = 1;
}
matrix.clear();
matrix.drawBitmap(0, 0, activeSlot[activeIndex], 8, 8, LED_YELLOW);
matrix.writeDisplay();
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment