Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define KNOPF 11
- #define SUMMER 10
- #define LED1 2
- #define LED2 3
- #define LED3 4
- #define LED4 5
- #define LED5 6
- #define LED6 7
- #define LED7 8
- #define LED8 9
- #define A 256
- #define B 288
- #define C 320
- #define D 341
- #define E 384
- #define F 427
- #define G 480
- #define H 512
- typedef struct
- {
- char act;
- char edge;
- char edge_pos;
- char old;
- } tst_t;
- void setup()
- {
- pinMode(2, OUTPUT);
- pinMode(3, OUTPUT);
- pinMode(4, OUTPUT);
- pinMode(5, OUTPUT);
- pinMode(6, OUTPUT);
- pinMode(7, OUTPUT);
- pinMode(8, OUTPUT);
- pinMode(9, OUTPUT);
- pinMode(10, OUTPUT);
- pinMode(11, INPUT);
- digitalWrite(1, HIGH);
- digitalWrite(2, HIGH);
- digitalWrite(3, HIGH);
- digitalWrite(4, HIGH);
- digitalWrite(5, HIGH);
- digitalWrite(6, HIGH);
- digitalWrite(7, HIGH);
- digitalWrite(8, HIGH);
- digitalWrite(9, HIGH);
- }
- char started = 0;
- char modus = 1;
- tst_t tst = {0};
- void loop()
- {
- tst.act = digitalRead(KNOPF);
- if(tst.act == 1) started = 1;
- if(started == 1)
- {
- switch(modus)
- {
- /* case 1:
- digitalWrite(LED1, LOW);
- tone(SUMMER, A);
- delay(250);
- unterbruch(20);
- tone(SUMMER, B);
- delay(250);
- unterbruch(20);
- tone(SUMMER, C);
- delay(250);
- unterbruch(20);
- tone(SUMMER, D);
- delay(250);
- unterbruch(20);
- tone(SUMMER, E);
- delay(500);
- unterbruch(20);
- tone(SUMMER, E);
- delay(500);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, E);
- delay(750);
- unterbruch(200);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, F);
- delay(250);
- unterbruch(20);
- tone(SUMMER, E);
- delay(750);
- unterbruch(200);
- tone(SUMMER, D);
- delay(250);
- unterbruch(20);
- tone(SUMMER, D);
- delay(250);
- unterbruch(20);
- tone(SUMMER, D);
- delay(250);
- unterbruch(20);
- tone(SUMMER, D);
- delay(250);
- unterbruch(20);
- tone(SUMMER, C);
- delay(500);
- unterbruch(20);
- tone(SUMMER, C);
- delay(500);
- unterbruch(20);
- tone(SUMMER, B);
- delay(250);
- unterbruch(20);
- tone(SUMMER, B);
- delay(250);
- unterbruch(20);
- tone(SUMMER, B);
- delay(250);
- unterbruch(20);
- tone(SUMMER, B);
- delay(250);
- unterbruch(20);
- tone(SUMMER, A);
- delay(750);
- unterbruch(1000);
- modus++;
- break;
- case 2:
- digitalWrite(LED2, LOW);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, B);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, A);
- delay(1200);
- unterbruch(30);
- tone(SUMMER,D);
- delay(1200);
- unterbruch(30);
- tone(SUMMER,C);
- delay(2000);
- unterbruch(30);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, B);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, A);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, E);
- delay(500);
- unterbruch(30);
- tone(SUMMER, D);
- delay(2000);
- unterbruch(30);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, A);
- delay(500);
- unterbruch(30);
- tone(SUMMER, H);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, F);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, D);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, C);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, B);
- delay(2000);
- unterbruch(30);
- tone(SUMMER, G);
- delay(500);
- unterbruch(30);
- tone(SUMMER, G);
- delay(500);
- unterbruch(30);
- tone(SUMMER, F);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, D);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, E);
- delay(1200);
- unterbruch(30);
- tone(SUMMER, D);
- delay(1200);
- unterbruch(30);
- noTone(SUMMER);
- modus++;
- break;
- */
- case 1:
- digitalWrite(LED3, HIGH);
- tone(SUMMER, H);
- delay(200);
- unterbruch(1);
- tone(SUMMER, F);
- delay(200);
- unterbruch(1);
- tone(SUMMER, G);
- delay(200);
- unterbruch(1);
- tone(SUMMER, E);
- delay(200);
- unterbruch(1);
- tone(SUMMER, F);
- delay(200);
- unterbruch(1);
- tone(SUMMER, D);
- delay(200);
- unterbruch(1);
- tone(SUMMER, E);
- delay(200);
- unterbruch(1);
- tone(SUMMER, C);
- delay(200);
- unterbruch(1);
- tone(SUMMER, H);
- delay(200);
- unterbruch(1);
- tone(SUMMER, H);
- delay(200);
- unterbruch(1);
- default:
- modus = 1;
- digitalWrite(LED1, HIGH);
- digitalWrite(LED2, HIGH);
- digitalWrite(LED3,HIGH);
- delay(500);
- break;
- }
- }
- }
- void unterbruch(short warten)
- {
- tst.act = digitalRead(KNOPF);
- tst.edge = tst.act & tst.old;
- tst.edge_pos = tst.edge & tst.act;
- tst.old = tst.act;
- if(tst.edge_pos == 1) started = 0;
- noTone(SUMMER);
- delay(warten);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement