#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define LED_COUNT 9
#define VERT_PIN A0
#define HORZ_PIN A1
#define SEL 12
const int contPix[] = {1, 1};
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
pinMode(VERT_PIN, INPUT);
pinMode(HORZ_PIN, INPUT);
pinMode(SEL, INPUT_PULLUP);
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50);
}
void loop() {
// put your main code here, to run repeatedly:
int *ptr = (int*)contPix;
const uint8_t o = (0, 0, 0);
const uint8_t r = (255, 0, 0);
int vert = analogRead(VERT_PIN);
int horz = analogRead(HORZ_PIN);
bool selPressed = digitalRead(SEL) == LOW;
if ((vert >= 1023) && (ptr[1] > 2)) {
ptr[1] += 1;
} else if ((vert <= 0) && (ptr[1] < 0)) {
ptr[1] -= 1;
}
if ((horz >= 1023) && (ptr[0] > 2)) {
ptr[0] += 1;
} else if ((horz <= 0) && (ptr[0] < 0)) {
ptr[0] -= 1;
}
if (selPressed == true) {
ptr[0] = 1;
ptr[1] = 1;
}
/*
for (int i = 0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, o);
strip.show();
}
*/
strip.setPixelColor((ptr[0]+3*ptr[1]), r);
strip.show();
}