-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch1.c
60 lines (57 loc) · 1006 Bytes
/
sketch1.c
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
#include <LiquidCrystal.h>
//#include <Serial.h>
byte emoji[8] =
{ B00000,
B00000,
B01010,
B10101,
B10001,
B01010,
B00100,
B00000
};
byte znak = 0;
LiquidCrystal LCD = LiquidCrystal(12, 11, 5, 4, 3, 2);
int col = 14;
int row = 0;
void setup() {
LCD.createChar(0, emoji);
LCD.begin(16, 2);
LCD.clear();
LCD.setCursor(col, row);
LCD.write(byte(0));
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available()){
znak = Serial.read();
if(znak == 'a'){
col -= 1;
if(col == -1) {
col = 15;
}
}
if(znak == 'w'){
row -= 1;
if(row == -1){
row = 1;
}
}
if(znak == 's'){
row += 1;
if(row == 2){
row = 0;
}
}
if(znak == 'd'){
col += 1;
if(col == 16) {
col = 0;
}
}
LCD.clear();
LCD.setCursor(col, row);
LCD.write(byte(0));
}
}