-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_safepixel.ino
203 lines (177 loc) · 4.87 KB
/
_safepixel.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_8x16minimatrix matrix = Adafruit_8x16minimatrix();
const int JOY_X = A1; // analog
const int JOY_Y = A3; // analog ___ JOY ___
void setup() {
//while (!Serial);
Serial.begin(9600);
Serial.println("16x8 LED Mini Matrix Test");
matrix.begin(0x70); // pass in the address
}
static const uint8_t PROGMEM
smile_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100 },
neutral_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10111101,
B10000001,
B01000010,
B00111100 },
frown_bmp[] =
{ B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01000010,
B00111100 },
alert_bmp[] =
{
B00011000,
B00011000,
B00011000,
B00011000,
B00011000,
B00000000,
B00011000,
B00011000 },
left_bmp[] =
{
B00011001,
B00110011,
B01100110,
B11001100,
B11001100,
B01100110,
B00110011,
B00011001 },
right_bmp[] =
{
B10011000,
B11001100,
B01100110,
B00110011,
B00110011,
B01100110,
B11001100,
B10011000 };
void loop() {
int joy_x = analogRead(JOY_X); // 변수 X에 아날로그 1번핀에 입력되는 신호를 대입
int joy_y = analogRead(JOY_Y); // 변수 Y에 아날로그 0번핀에 입력되는 신호를 대입
Serial.write(joy_x);
if(joy_x < 100) { // DOWN
matrix.setTextSize(1);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x=7; x>=-70; x--) {
matrix.clear();
matrix.drawBitmap(0, 8, alert_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
matrix.setCursor(x,0);
matrix.print("WARNING! **");
matrix.writeDisplay();
joy_x = analogRead(JOY_X);
if(joy_x > 100){break;}
delay(100);
}
}
if(joy_x > 1000) { // UP
matrix.setTextSize(1);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x=7; x>=-40; x--) {
matrix.clear();
matrix.drawBitmap(0, 8, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
matrix.setCursor(x,0);
matrix.print("Thanks!");
matrix.writeDisplay();
joy_x = analogRead(JOY_X);
if(joy_x < 1000){break;}
delay(100);
}
while(joy_x > 1000){
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
delay(750);
matrix.clear();
matrix.drawBitmap(0, 8, smile_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
delay(750);
joy_x = analogRead(JOY_X);
if(joy_x < 1000){break;}
delay(100);
}
}
if(joy_y > 1000) { // right
matrix.setTextSize(1);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x=-64; x<=0; x++) {
matrix.clear();
matrix.drawBitmap(0, 8, right_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
matrix.setCursor(x,0);
matrix.print(">>>>>>>>>>>>>>");
matrix.writeDisplay();
joy_y = analogRead(JOY_Y);
if(joy_y < 1000){break;}
delay(100);
}
}
if(joy_y <100) { // left
matrix.setTextSize(1);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x=0; x>=-64; x--) {
matrix.clear();
matrix.drawBitmap(0, 8, left_bmp, 8, 8, LED_ON);
matrix.writeDisplay();
matrix.setCursor(x,0);
matrix.print("<<<<<<<<<<<<<<<");
matrix.writeDisplay();
joy_y = analogRead(JOY_Y);
if(joy_y > 100){break;}
delay(100);
}
}
if(joy_x > 400 && joy_x < 600 && joy_y > 400 && joy_y < 600) {
matrix.setTextSize(2);
matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
matrix.setTextColor(LED_ON);
for (int8_t x=0; x>=-110; x--) {
matrix.clear();
matrix.setCursor(x,0);
matrix.print("SAFEPIXEL");
matrix.writeDisplay();
if(joy_x < 400 || joy_x > 600 || joy_y < 400 || joy_y > 600){break;}
joy_x = analogRead(JOY_X);
joy_y = analogRead(JOY_Y);
delay(100);
}
while(joy_x > 400 && joy_x < 600 && joy_y > 400 && joy_y < 600){
matrix.clear();
matrix.drawRect(0,0, 8,16, LED_ON);
matrix.fillRect(2,2, 4,12, LED_ON);
matrix.writeDisplay(); // write the changes we just made to the display
delay(500);
if(joy_x < 400 || joy_x > 600 || joy_y < 400 || joy_y > 600){break;}
joy_x = analogRead(JOY_X);
joy_y = analogRead(JOY_Y);
}
}
}