const int S1LED = A0;
const int S2LED = A1;
const int S3LED = A2;
const int S4LED = A3;
const int S5LED = A4;
const int S6LED = A5;
const int S1TASTER = 8;
const int S2TASTER = 11;
const int S3TASTER = 10;
const int S4TASTER = 12;
const int S5TASTER = 9;
const int S6TASTER = 7;
const int Buzzer = 13;
const int potPin = A7;
int switchStateS1 = 0;
int switchStateS2 = 0;
int switchStateS3 = 0;
int switchStateS4 = 0;
int switchStateS5 = 0;
int switchStateS6 = 0;
int potVal;
int Dauer;
int dauerGesamt;
#include "pitches.h"
void setup() {
/*Serial.begin(9600);*/
pinMode(S1LED, OUTPUT);
pinMode(S2LED, OUTPUT);
pinMode(S3LED, OUTPUT);
pinMode(S4LED, OUTPUT);
pinMode(S5LED, OUTPUT);
pinMode(S6LED, OUTPUT);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
tone(Buzzer, NOTE_F3, 200);
delay(200);
tone(Buzzer, NOTE_A3, 200);
delay(400);
tone(Buzzer, NOTE_F3, 200);
delay(200);
tone(Buzzer, NOTE_AS3, 200);
delay(400);
tone(Buzzer, NOTE_F3, 200);
delay(200);
tone(Buzzer, NOTE_C4, 800);
delay(800);
noTone(Buzzer);
}
void loop() {
Start:
int dauerSchluss = 3;
int i = 0;
potVal = analogRead(potPin);
Dauer = map(potVal, 0, 1023, 0, 7);
switchStateS1 = digitalRead(S1TASTER);
switchStateS2 = digitalRead(S2TASTER);
switchStateS3 = digitalRead(S3TASTER);
switchStateS4 = digitalRead(S4TASTER);
switchStateS5 = digitalRead(S5TASTER);
switchStateS6 = digitalRead(S6TASTER);
/*
Serial.print(potVal);
Serial.print(" ");
Serial.print(Dauer);
Serial.print(" ");
Serial.print(switchStateS1);
Serial.print(switchStateS2);
Serial.print(switchStateS3);
Serial.print(switchStateS4);
Serial.print(switchStateS5);
Serial.print(switchStateS6);*/
pinMode(S1TASTER, INPUT);
pinMode(S2TASTER, INPUT);
pinMode(S3TASTER, INPUT);
pinMode(S4TASTER, INPUT);
pinMode(S5TASTER, INPUT);
pinMode(S6TASTER, INPUT);
if (Dauer == 1) {
dauerGesamt = 3;
}
else if (Dauer == 2) {
dauerGesamt = 5;
}
else if (Dauer == 3) {
dauerGesamt = 10;
}
else if (Dauer == 4) {
dauerGesamt = 20;
}
else if (Dauer == 5) {
dauerGesamt = 30;
}
else if (Dauer == 6 or Dauer == 7) {
dauerGesamt = 60;
}
else {
dauerGesamt = 3;
}
/*Serial.print(" ");
Serial.println(dauerGesamt);*/
if (Dauer != 0) {
//Spieler 1
if (switchStateS1 == HIGH) {
//Ton bei Druck
digitalWrite(S1LED, HIGH);
tone(Buzzer, NOTE_G4, 35);
delay(35);
tone(Buzzer, NOTE_G5, 35);
delay(35);
tone(Buzzer, NOTE_G6, 35);
delay(35);
noTone(Buzzer);
//Warten
delay((dauerGesamt + 1 - dauerSchluss - 0.21) * 900);
digitalWrite(S1LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss - 0.21) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
goto Start;
}
//Spieler 2
if (switchStateS2 == HIGH) {
digitalWrite(S2LED, HIGH);
//Ton bei Druck
tone(Buzzer, NOTE_B5, 100);
delay(100);
tone(Buzzer, NOTE_E6, 700);
delay(700);
noTone(Buzzer);
//Warten
delay((dauerGesamt + 1 - dauerSchluss - 0.8) * 900);
digitalWrite(S2LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss - 0.8) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, LOW);
goto Start;
}
//Spieler 3
if (switchStateS3 == HIGH) {
digitalWrite(S3LED, HIGH);
for (int hz = 2000; hz > 440; hz--) {
tone(Buzzer, hz, 50);
delay(0.5);
}
//Warten
delay((dauerGesamt + 1 - dauerSchluss - 0.4) * 900);
digitalWrite(S3LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss - 0.4) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
goto Start;
}
//Spieler 4
if (switchStateS4 == HIGH) {
digitalWrite(S4LED, HIGH);
tone(Buzzer, NOTE_C7, 115);
delay(125);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_GS6, 115);
delay(125);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_DS7, 115);
delay(125);
//Warten
delay((dauerGesamt + 1 - dauerSchluss - 1.0) * 900);
digitalWrite(S4LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss - 1.0) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
goto Start;
}
//Spieler 5
if (switchStateS5 == HIGH) {
digitalWrite(S5LED, HIGH);
tone(Buzzer, NOTE_E6, 125);
delay(125);
tone(Buzzer, NOTE_G6, 125);
delay(125);
tone(Buzzer, NOTE_E7, 125);
delay(125);
tone(Buzzer, NOTE_C7, 125);
delay(125);
tone(Buzzer, NOTE_D7, 125);
delay(125);
tone(Buzzer, NOTE_G7, 125);
delay(125);
noTone(Buzzer);
//Warten
delay((dauerGesamt + 1 - dauerSchluss - 0.85) * 900);
digitalWrite(S5LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss - 0.85) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S5LED, LOW);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
goto Start;
}
//Spieler 6
if (switchStateS6 == HIGH) {
digitalWrite(S6LED, HIGH);
for (int hz = 440; hz < 1000; hz++) {
tone(Buzzer, hz, 50);
delay(0.75);
}
//Warten
delay((dauerGesamt + 1 - dauerSchluss) * 900);
digitalWrite(S6LED, LOW);
//Ende
delay((dauerGesamt + 1 - dauerSchluss) * 100);
while (i < dauerSchluss - 1) {
tone(Buzzer, NOTE_G4);
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
noTone(Buzzer);
delay(500);
i++;
}
digitalWrite(S1LED, HIGH);
digitalWrite(S2LED, HIGH);
digitalWrite(S3LED, HIGH);
digitalWrite(S4LED, HIGH);
digitalWrite(S5LED, HIGH);
digitalWrite(S6LED, HIGH);
tone(Buzzer, NOTE_G5);
delay(500);
digitalWrite(S1LED, LOW);
digitalWrite(S2LED, LOW);
digitalWrite(S3LED, LOW);
digitalWrite(S4LED, LOW);
digitalWrite(S5LED, LOW);
digitalWrite(S6LED, LOW);
noTone(Buzzer);
digitalWrite(S6LED, HIGH);
delay(30);
digitalWrite(S1LED, HIGH);
delay(30);
digitalWrite(S2LED, HIGH);
delay(30);
digitalWrite(S3LED, HIGH);
delay(30);
digitalWrite(S4LED, HIGH);
delay(30);
digitalWrite(S5LED, HIGH);
delay(30);
digitalWrite(S6LED, LOW);
delay(30);
digitalWrite(S1LED, LOW);
delay(30);
digitalWrite(S2LED, LOW);
delay(30);
digitalWrite(S3LED, LOW);
delay(30);
digitalWrite(S4LED, LOW);
delay(30);
digitalWrite(S5LED, LOW);
delay(30);
goto Start;
}
}
else if (potVal < 145) {
//Spieler 1
if (switchStateS1 == HIGH) {
//Ton bei Druck
digitalWrite(S1LED, HIGH);
tone(Buzzer, NOTE_G4, 35);
delay(35);
tone(Buzzer, NOTE_G5, 35);
delay(35);
tone(Buzzer, NOTE_G6, 35);
delay(35);
noTone(Buzzer);
delay(dauerGesamt * 1000);
digitalWrite(S1LED, LOW);
}
}
//Spieler 2
if (switchStateS2 == HIGH) {
digitalWrite(S2LED, HIGH);
//Ton bei Druck
tone(Buzzer, NOTE_B5, 100);
delay(100);
tone(Buzzer, NOTE_E6, 700);
delay(700);
noTone(Buzzer);
delay(dauerGesamt * 1000);
digitalWrite(S2LED, LOW);
}
//Spieler 3
if (switchStateS3 == HIGH) {
digitalWrite(S3LED, HIGH);
for (int hz = 2000; hz > 440; hz--) {
tone(Buzzer, hz, 50);
delay(0.5);
}
delay(dauerGesamt * 1000);
digitalWrite(S3LED, LOW);
}
//Spieler 4
if (switchStateS4 == HIGH) {
digitalWrite(S4LED, HIGH);
tone(Buzzer, NOTE_C7, 115);
delay(125);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_GS6, 115);
delay(125);
tone(Buzzer, NOTE_C7, 240);
delay(250);
tone(Buzzer, NOTE_DS7, 115);
delay(125);
noTone(Buzzer);
delay(dauerGesamt * 1000);
digitalWrite(S4LED, LOW);
}
//Spieler 5
if (switchStateS5 == HIGH) {
digitalWrite(S5LED, HIGH);
tone(Buzzer, NOTE_E6, 125);
delay(125);
tone(Buzzer, NOTE_G6, 125);
delay(125);
tone(Buzzer, NOTE_E7, 125);
delay(125);
tone(Buzzer, NOTE_C7, 125);
delay(125);
tone(Buzzer, NOTE_D7, 125);
delay(125);
tone(Buzzer, NOTE_G7, 125);
delay(125);
noTone(Buzzer);
delay(dauerGesamt * 1000);
digitalWrite(S5LED, LOW);
}
//Spieler 6
if (switchStateS6 == HIGH) {
digitalWrite(S6LED, HIGH);
for (int hz = 440; hz < 1000; hz++) {
tone(Buzzer, hz, 50);
delay(0.75);
}
delay(dauerGesamt * 1000);
digitalWrite(S6LED, LOW);
}
}
Comments