Fun with the Digispark Pro "Beta Supporters" Shield. Uses everything on the board!
| #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) | |
| #include <LedControl.h> | |
| #define JOYX A5 | |
| #define JOYY A8 | |
| #define BUTTON 1 | |
| #define LIGHT A9 | |
| LedControl lc = LedControl(10,11,12,1); | |
| void setup() { | |
| lc.shutdown(0, false); | |
| lc.setIntensity(0, 8); | |
| lc.clearDisplay(0); | |
| pinMode(JOYX, INPUT); | |
| pinMode(JOYY, INPUT); | |
| pinMode(BUTTON, INPUT); | |
| pinMode(LIGHT, INPUT); | |
| } | |
| void loop() { | |
| lc.setIntensity(0, map(analogRead(LIGHT), 0, 1024, 0, 15)); | |
| lc.clearDisplay(0); | |
| if(!digitalRead(BUTTON)) { | |
| for(int x = 0; x < 8; x++) { | |
| for(int y = 0; y < 8; y++) { | |
| lc.setLed(0, x, y, true); | |
| } | |
| } | |
| delay(10); | |
| return; | |
| } | |
| long xint = analogRead(JOYX); | |
| long yint = analogRead(JOYY); | |
| long x = map(xint, 0, 1023, 15, 0); | |
| long y = map(yint, 0, 1023, 15, 0); | |
| if(x % 2 == 1) { | |
| lc.setLed(0, (x / 2) + 1, y/2, true); | |
| } | |
| if(y % 2 == 1) { | |
| lc.setLed(0, x/2, (y / 2) + 1, true); | |
| } | |
| if(x % 2 == 1 && y % 2 == 1) { | |
| lc.setLed(0, (x / 2) + 1, (y / 2) + 1, true); | |
| } | |
| lc.setLed(0, x/2, y/2, true); | |
| delay(10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment