Skip to content

Commit 0e59cb4

Browse files
authored
Add files via upload
1 parent 20f4600 commit 0e59cb4

File tree

2 files changed

+153
-0
lines changed

2 files changed

+153
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* ledData.h
3+
*
4+
* data to be loaded onto the LED matrix, note that it is
5+
* a weird Xmas tree, mostly because "the winter is coming"
6+
*
7+
*/
8+
9+
int red[] = {
10+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,
11+
0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,
12+
0,40,0,0,0,0,0,100,100,100,0,0,0,0,0,0,
13+
0,0,40,0,0,0,0,100,0,0,0,0,0,0,0,0,
14+
0,0,0,40,0,0,0,0,100,0,0,0,0,0,0,0,
15+
0,0,0,0,0,0,100,0,100,0,0,0,0,0,0,0,
16+
0,0,0,0,0,0,100,0,0,0,100,0,0,0,0,0,
17+
0,0,0,0,100,0,0,0,0,0,100,0,0,0,0,0,
18+
0,0,0,0,0,100,0,0,0,0,0,100,0,0,0,0,
19+
0,0,0,100,0,0,0,0,0,0,0,100,0,0,0,0,
20+
0,0,0,0,100,0,0,0,0,0,0,0,100,0,0,0,
21+
0,0,100,0,0,0,0,0,0,0,0,0,100,0,0,0,
22+
0,0,0,100,0,0,0,0,0,0,0,0,0,100,0,0,
23+
0,0,0,0,0,100,0,0,0,100,0,0,0,0,0,0,
24+
0,0,0,0,0,0,100,0,0,0,100,0,0,0,0,0,
25+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26+
};
27+
28+
int green[] = {
29+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,
30+
0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,
31+
0,40,0,0,0,0,0,100,100,100,0,0,0,0,0,0,
32+
0,0,40,0,0,0,0,100,0,0,0,0,0,0,0,0,
33+
0,0,0,40,0,0,0,0,0,0,0,0,0,0,0,0,
34+
0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,
35+
0,0,0,0,0,0,0,100,100,100,0,0,0,0,0,0,
36+
0,0,0,0,0,100,100,100,100,100,0,0,0,0,0,0,
37+
0,0,0,0,0,0,100,100,100,100,100,0,0,0,0,0,
38+
0,0,0,0,100,100,100,100,100,100,100,0,0,0,0,0,
39+
0,0,0,0,0,100,100,100,100,100,100,100,0,0,0,0,
40+
0,0,0,100,100,100,100,100,100,100,100,100,0,0,0,0,
41+
0,0,0,0,100,100,100,100,100,100,100,100,100,0,0,0,
42+
0,0,0,0,0,0,100,100,100,0,0,0,0,0,0,0,
43+
0,0,0,0,0,0,0,100,100,100,0,0,0,0,0,0,
44+
0,0,0,0,0,100,100,100,100,100,0,0,0,0,0,0,
45+
};
46+
47+
int blue[] = {
48+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,
49+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
50+
0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,
51+
0,0,0,0,0,0,100,100,100,0,0,0,0,0,0,0,
52+
0,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,
53+
0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,
54+
0,0,0,0,0,0,0,100,100,100,0,0,0,0,0,0,
55+
0,0,0,0,0,100,100,100,100,100,0,0,0,0,0,0,
56+
0,0,0,0,0,0,100,100,100,100,100,0,0,0,0,0,
57+
0,0,0,0,100,100,100,100,100,100,100,0,0,0,0,0,
58+
0,0,0,0,0,100,100,100,100,100,100,100,0,0,0,0,
59+
0,0,0,100,100,100,100,100,100,100,100,100,0,0,0,0,
60+
0,0,0,0,100,100,100,100,100,100,100,100,100,0,0,0,
61+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
62+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
63+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
64+
};
65+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
NeoMatrix with two buttons
3+
4+
Control a NeoPixel LED matrix using two buttons.
5+
6+
The LED data is stored in arrays, allowing the generation of
7+
possible "screens" using external software
8+
9+
(c) 2018 Karl, Josefine, and David for Arduino
10+
this code is GPLv3
11+
12+
based on code by Shae Erisson (c) 2013
13+
14+
*/
15+
16+
#include <Adafruit_NeoPixel.h>
17+
#include "ledData.h"
18+
19+
#ifdef __AVR__
20+
#include <avr/power.h>
21+
#endif
22+
23+
// NeoPixel string is connected to pin 6
24+
#define PIN 6
25+
26+
// size of the LED matrix: 16x16
27+
#define NUMPIXELS 256
28+
29+
// create the NeoPixel object
30+
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
31+
32+
// variables to control the buttons
33+
// by default they have to be "HIGH"
34+
// because of using the internal pullup
35+
int buttonPin1 = 2;
36+
int buttonPin2 = 3;
37+
int buttonState1 = HIGH;
38+
int buttonState2 = HIGH;
39+
int buttonStateOld1 = HIGH;
40+
int buttonStateOld2 = HIGH;
41+
42+
// see the other tab for checking
43+
// the arrays storing the LED data
44+
45+
void setup() {
46+
// init the NeoPixel matrix
47+
pixels.begin();
48+
49+
// configure the buttons with internal pullup resistors
50+
pinMode(buttonPin1, INPUT_PULLUP);
51+
pinMode(buttonPin2, INPUT_PULLUP);
52+
}
53+
54+
void loop() {
55+
// check the status of the buttons
56+
buttonState1 = digitalRead(buttonPin1);
57+
buttonState2 = digitalRead(buttonPin2);
58+
59+
// if button 1 is pressed, load the image
60+
if (buttonState1 == LOW && buttonStateOld1 == HIGH)
61+
showImage();
62+
63+
// if button 2 is pressed, clear the image
64+
if (buttonState2 == LOW && buttonStateOld2 == HIGH)
65+
clearImage();
66+
67+
// update the button states
68+
buttonStateOld1 = buttonState1;
69+
buttonStateOld2 = buttonState2;
70+
}
71+
72+
// send the color information to the screen taking the data
73+
// from the arrays declared at the beginning of the program
74+
void showImage() {
75+
for (int i = 0; i < NUMPIXELS; i++)
76+
pixels.setPixelColor(i, pixels.Color(red[i], green[i], blue[i]));
77+
78+
pixels.show();
79+
}
80+
81+
// send a bunch of zeroes to the string
82+
void clearImage() {
83+
for (int i = 0; i < NUMPIXELS; i++)
84+
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
85+
86+
pixels.show();
87+
}
88+

0 commit comments

Comments
 (0)