-
Notifications
You must be signed in to change notification settings - Fork 0
/
Three_dot_forward.ino
121 lines (96 loc) · 3.05 KB
/
Three_dot_forward.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
int clockPin = 2;
int latchPin = 3;
int dataPin = 4;
int rate_delay = 100;
int send_data(String str){
int result = 0;
if(str[0]=='1') result = result+ pow(2,7);
if(str[1]=='1') result = result+ pow(2,6);
if(str[2]=='1') result = result+ pow(2,5);
if(str[3]=='1') result = result+ pow(2,4);
if(str[4]=='1') result = result+ pow(2,3);
if(str[5]=='1') result = result+ pow(2,2);
if(str[6]=='1') result = result+ pow(2,1);
if(str[7]=='1') result = result+ pow(2,0);
return result;
}
void setup() {
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
String str1 = "10000000";
String str2 = "10000000";
String str3 = "10000000";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "01000000";
str2 = "01000000";
str3 = "01000000";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00100000";
str2 = "00100000";
str3 = "00100000";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00010000";
str2 = "00010000";
str3 = "00010000";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00001000";
str2 = "00001000";
str3 = "00001000";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00000100";
str2 = "00000100";
str3 = "00000100";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00000010";
str2 = "00000010";
str3 = "00000010";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
str1 = "00000001";
str2 = "00000001";
str3 = "00000001";
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str1));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str2));
shiftOut(dataPin, clockPin, LSBFIRST,send_data(str3));
digitalWrite(latchPin, HIGH);
delay(rate_delay);
}