You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.2 KiB

6 years ago
int langs[] = {2,4,7,8,12,13};
int leds[] = {3,5,6,9,10,11};
bool state[] = {0,0,0,0,0,0};
int old = 0;
int current = 0;
void setup() {
6 years ago
Serial.begin(9600);
6 years ago
for(int i=0; i<6; i++) {
pinMode(langs[i], INPUT);
pinMode(leds[i], OUTPUT);
}
}
void loop() {
checkStatus();
6 years ago
if(current == 0) {
for(int i=0; i<255; i++) {
checkStatus();
6 years ago
for(int x=0; x<6; x++) {
analogWrite(leds[x], i);
}
delay(10);
}
for(int i=255; i>0; i--) {
checkStatus();
6 years ago
for(int x=0; x<6; x++) {
analogWrite(leds[x], i);
}
delay(10);
}
} else {
for(int i=0; i<100; i++) {
checkStatus();
if(current != 0) {
analogWrite(leds[current-1], i);
}
delay(10);
}
for(int i=100; i>0; i--) {
checkStatus();
if(current != 0) {
analogWrite(leds[current-1], i);
}
delay(10);
}
}
}
void checkStatus() {
6 years ago
current = 0;
6 years ago
for(int i=0; i<6; i++) {
state[i] = digitalRead(langs[i]);
//Serial.print(state[i]);
//Serial.print("\t");
if(state[i] == LOW) {
current = i+1;
}
6 years ago
}
if(old != current) {
old = current;
Serial.println(current);
}
}