const int LED_1 = 0;
const int LED_2 = 1;
const int LED_3 = 2;
const int LED_4 = 3;
#define PRADC 0
#define PRR _SFR_IO8(0x25)
void setup()
{
// not sure anymore, attiny13?
// PRR |= (uint8_t)(1 << PRADC);
// not sure anymore, attiny45?
}
void loop() {
for (int i = 0; i < 8; i++) {
charlie(i);
delay(50);
}
for (int i = 0; i < 8; i++) {
charlie(7-i);
delay(50);
}
charlie(-1);
delay(1000);
}
void charlie (int var) {
pinMode(LED_1, INPUT);
digitalWrite(LED_1, LOW);
pinMode(LED_2, INPUT);
digitalWrite(LED_2, LOW);
pinMode(LED_3, INPUT);
digitalWrite(LED_3, LOW);
pinMode(LED_4, INPUT);
digitalWrite(LED_4, LOW);
switch (var) {
case 0:
pinMode(LED_1, OUTPUT);
digitalWrite(LED_1, HIGH);
pinMode(LED_2, OUTPUT);
digitalWrite(LED_2, LOW);
break;
case 1:
pinMode(LED_1, OUTPUT);
digitalWrite(LED_1, LOW);
pinMode(LED_2, OUTPUT);
digitalWrite(LED_2, HIGH);
break;
case 2:
pinMode(LED_2, OUTPUT);
digitalWrite(LED_2, HIGH);
pinMode(LED_3, OUTPUT);
digitalWrite(LED_3, LOW);
break;
case 3:
pinMode(LED_2, OUTPUT);
digitalWrite(LED_2, LOW);
pinMode(LED_3, OUTPUT);
digitalWrite(LED_3, HIGH);
break;
case 4:
pinMode(LED_3, OUTPUT);
digitalWrite(LED_3, HIGH);
pinMode(LED_4, OUTPUT);
digitalWrite(LED_4, LOW);
break;
case 5:
pinMode(LED_3, OUTPUT);
digitalWrite(LED_3, LOW);
pinMode(LED_4, OUTPUT);
digitalWrite(LED_4, HIGH);
break;
case 6:
pinMode(LED_1, OUTPUT);
digitalWrite(LED_1, HIGH);
pinMode(LED_4, OUTPUT);
digitalWrite(LED_4, LOW);
break;
case 7:
pinMode(LED_1, OUTPUT);
digitalWrite(LED_1, LOW);
pinMode(LED_4, OUTPUT);
digitalWrite(LED_4, HIGH);
break;
default:
;
}
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.