76 lines
1.7 KiB
C++
76 lines
1.7 KiB
C++
/*
|
|
Das Programm gibt eine Bitfolge aus, die ein DCF 77 Signal simuliert
|
|
Es sind genau 59 Bit, die nach einer kurzen Pause wiederholt werden
|
|
Die simulierte Zeit ist 17.03 Uhr
|
|
0-00011110001110-001001-11000000-1110100-011000-111-00001-001001000
|
|
*/
|
|
|
|
|
|
#define outPin 16 // D0
|
|
#define ledPin 2 // D4
|
|
byte selectBit;
|
|
|
|
int timeBit[59] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 2};
|
|
|
|
void setup() {
|
|
pinMode(outPin, OUTPUT);
|
|
pinMode(ledPin, OUTPUT);
|
|
digitalWrite(outPin, LOW);
|
|
digitalWrite(ledPin, HIGH);
|
|
}
|
|
|
|
void loop() {
|
|
for (int i = 0; i <= 58; i++) {
|
|
int a = timeBit[i];
|
|
if (a == 0) {
|
|
selectBit = 0;
|
|
}
|
|
if (a == 1) {
|
|
selectBit = 1;
|
|
}
|
|
if (a == 2) {
|
|
selectBit = 2;
|
|
}
|
|
|
|
switch (selectBit) {
|
|
case 0:
|
|
digitalWrite(outPin, HIGH);
|
|
digitalWrite(ledPin, LOW);
|
|
delay(100);
|
|
digitalWrite(outPin, LOW);
|
|
digitalWrite(ledPin, HIGH);
|
|
delay(900);
|
|
break;
|
|
|
|
case 1:
|
|
digitalWrite(outPin, HIGH);
|
|
digitalWrite(ledPin, LOW);
|
|
delay(200);
|
|
digitalWrite(outPin, LOW);
|
|
digitalWrite(ledPin, HIGH);
|
|
delay(800);
|
|
break;
|
|
|
|
case 2:
|
|
digitalWrite(outPin, HIGH);
|
|
digitalWrite(ledPin, LOW);
|
|
delay(100);
|
|
digitalWrite(outPin, LOW);
|
|
digitalWrite(ledPin, HIGH);
|
|
delay(1900);
|
|
break;
|
|
|
|
case 3:
|
|
digitalWrite(outPin, HIGH);
|
|
digitalWrite(ledPin, LOW);
|
|
delay(200);
|
|
digitalWrite(outPin, LOW);
|
|
digitalWrite(ledPin, HIGH);
|
|
delay(1800);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|