1
0
Fork 0
This repository has been archived on 2019-12-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
arduinisten/projekte/miniledcube/miniledcube_test2/applet/miniledcube_test2.cpp
2010-03-30 18:55:18 +02:00

52 lines
897 B
C++

// digital pins 2-7 => kathoden 0-5
// analog pins 3-5 => kathoden 6-8
// analog pins 0-2 => anoden A0, B1, C2
#include "WProgram.h"
void setup();
void loop();
void setup() {
// digital pins 2-7
DDRD |= 0b11111100;
// analog pins 0-2 + 3-5
DDRC |= 0b00111111;
}
void loop() {
for(int ebene=0; ebene<=2; ebene++) {
// anoden auf 0
PORTC &= 0b11111000;
// unsere anode auf 1
PORTC |= _BV(ebene+0);
for (int kathode=0; kathode<=8; kathode++) {
// kathoden auf 1 (leuchtet nicht)
PORTD |= 0b11111100;
PORTC |= 0b00111000;
// unsere kathode auf 0 (leuchtet)
if (kathode <= 5) {
PORTD &= ~_BV(kathode+2);
}
if (kathode >= 6 && kathode <= 8) {
PORTC &= ~_BV(kathode-6+3);
}
delay(400);
}
}
}
int main(void)
{
init();
setup();
for (;;)
loop();
return 0;
}