Created
June 25, 2014 01:19
-
-
Save netguy204/7c336bbdbe50113b2abc to your computer and use it in GitHub Desktop.
Fun with the Digispark Pro "Beta Supporters" Shield. Uses everything on the board!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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