bLINK/Blink/Blink.ino

270 lines
4.6 KiB
Arduino
Raw Normal View History

2019-12-29 17:39:41 +00:00
const int L = 3;
const int I = 5;
2019-12-28 19:05:20 +00:00
const int N = 4;
2019-12-29 17:39:41 +00:00
const int K = 6;
2019-12-29 17:58:00 +00:00
long randomTime;
2019-12-28 19:05:20 +00:00
void setup() {
pinMode(L, OUTPUT);
pinMode(I, OUTPUT);
pinMode(N, OUTPUT);
pinMode(K, OUTPUT);
}
void loop() {
2019-12-30 11:45:58 +00:00
// int test[] = {I, N, K};
// order(test, 200, false);
// off();
fromLeft(100);
toRight(100);
}
void off() {
digitalWrite(L, LOW);
digitalWrite(I, LOW);
digitalWrite(N, LOW);
digitalWrite(K, LOW);
delay(1000);
}
void startLetter(int letter, int time) {
digitalWrite(letter, HIGH);
delay(2 * time);
}
void endLetter(int letter, int time) {
delay(2 * time);
digitalWrite(letter, LOW);
}
void schng(int from, int to, int time) {
delay(2 * time);
digitalWrite(to, HIGH);
delay(time);
digitalWrite(from, LOW);
delay(2 * time);
}
void order(int list[], int time, bool keepEnd) {
int length = (int) (sizeof(list) / sizeof(int));
if(length == 0) {
return;
}
startLetter(list[0], time);
for (int i = 1; i < length; i++) {
schng(list[i-1], list[i], time);
}
if(keepEnd) {
return;
}
endLetter(list[length], time);
2019-12-29 17:54:11 +00:00
}
void singleOn(int delayTime) {
2019-12-28 19:05:20 +00:00
digitalWrite(L, HIGH);
2019-12-29 17:54:11 +00:00
delay(delayTime);
2019-12-28 19:05:20 +00:00
digitalWrite(L, LOW);
digitalWrite(I, HIGH);
2019-12-29 17:54:11 +00:00
delay(delayTime);
2019-12-28 19:05:20 +00:00
digitalWrite(I, LOW);
digitalWrite(N, HIGH);
2019-12-29 17:54:11 +00:00
delay(delayTime);
2019-12-28 19:05:20 +00:00
digitalWrite(N, LOW);
digitalWrite(K, HIGH);
2019-12-29 17:54:11 +00:00
delay(delayTime);
2019-12-29 19:26:13 +00:00
digitalWrite(K, LOW);
2019-12-29 18:11:53 +00:00
}
void MiamiMidnight() {
2019-12-29 17:58:00 +00:00
digitalWrite(L, HIGH);
digitalWrite(I, HIGH);
digitalWrite(N, HIGH);
digitalWrite(K, HIGH);
randomTime = random(1000, 10000);
delay(randomTime);
digitalWrite(K, LOW);
delay(200);
digitalWrite(K, HIGH);
delay(400);
digitalWrite(I, LOW);
delay(200);
digitalWrite(I, HIGH);
delay(300);
2019-12-28 19:05:20 +00:00
digitalWrite(K, LOW);
2019-12-29 17:58:00 +00:00
delay(900);
2019-12-28 19:05:20 +00:00
}
2019-12-29 19:20:52 +00:00
2019-12-30 11:45:58 +00:00
void klinik(int time) {
int letters[] = {K, L, I, N, I, K};
order(letters, time, false);
2019-12-29 19:20:52 +00:00
delay(1000);
}
2019-12-29 20:28:11 +00:00
2019-12-30 11:45:58 +00:00
void fromLeft(int del) {
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
delay(3000);
}
2019-12-30 11:45:58 +00:00
void fromRight(int del) {
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
delay(3000);
}
2019-12-30 11:45:58 +00:00
void toLeft(int del) {
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
digitalWrite(I, HIGH);
digitalWrite(N, HIGH);
digitalWrite(K, HIGH);
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
delay(3000);
}
2019-12-30 11:45:58 +00:00
void toRight(int del) {
2019-12-29 20:28:11 +00:00
digitalWrite(L, HIGH);
digitalWrite(I, HIGH);
digitalWrite(N, HIGH);
digitalWrite(K, HIGH);
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
2019-12-30 11:45:58 +00:00
delay(del*2);
2019-12-29 20:28:11 +00:00
digitalWrite(I, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(L, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(N, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(I, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, HIGH);
2019-12-30 11:45:58 +00:00
delay(del/4);
2019-12-29 20:28:11 +00:00
digitalWrite(N, LOW);
2019-12-30 11:45:58 +00:00
delay(del);
2019-12-29 20:28:11 +00:00
digitalWrite(K, LOW);
delay(3000);
}