-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommuArd.ino
60 lines (56 loc) · 867 Bytes
/
CommuArd.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
int hash[4][4]={
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{0,0,0,1}
};
char dato = '0';
bool ver;
void setup() {
Serial.begin(9600);
pinMode(4,OUTPUT);
for(int i = 7; i < 13; i++){
pinMode(i,OUTPUT);
}
}
void mec1(){
for(int t = 0; t < 501;t++){
for(int w = 0; w < 4;w++){
digitalWrite(8,hash[w][0]);
digitalWrite(9,hash[w][1]);
digitalWrite(10,hash[w][2]);
digitalWrite(11,hash[w][3]);
delay(4);
}
delay(4);
}
}
void mec2(){
for(int t = 0; t < 501;t++){
for(int w = 0; w < 4;w++){
digitalWrite(8,hash[w][3]);
digitalWrite(9,hash[w][2]);
digitalWrite(10,hash[w][1]);
digitalWrite(11,hash[w][0]);
delay(4);
}
delay(4);
}
}
void loop() {
if(Serial.available()){
dato = Serial.read();
}
if(dato == '1'){
digitalWrite(7,1);
mec1();
dato = '0';
digitalWrite(7,0);
}
if(dato == '2'){
digitalWrite(4,1);
mec2();
dato = '0';
digitalWrite(4,0);
}
}