Hi,
ich habe einen Arduino Mega und möchte damit 48 LEDs ansteuern, die mit drei externen Tastern hoch und runter laufen, bzw. einen Reset durchführen.
Ich gehe aus den Digitalausgängen über einen BC548 Transistor auf einen Widerstand zur LED.
jetzt habe ich alles aufgebaut und den Arduino auf meine Platine aufgesteckt und die LEDs leuchten nach ein paar Sekunden dauerhaft und lassen sich über keinen Taster beeinflussen.
hier noch mein Code:
int LED [] ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49};
int auf = 90;
int set = 0;
int ab = 91;
int setter = 0;
int reset = 92;
int setting = 0;
int zaehler = 0;
void setup() {
// put your setup code here, to run once:
for (int i = 0; i<48; i++)
{pinMode(LED[i], OUTPUT);
digitalWrite(LED[i], LOW);}
pinMode(auf, INPUT);
pinMode(ab, INPUT);
pinMode(reset, INPUT);
digitalWrite(auf, HIGH);
digitalWrite(ab, HIGH);
digitalWrite(reset, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(auf) == LOW && set == 0) {zaehler = zaehler+1; set=1;}
if (digitalRead(auf) == HIGH && set == 1) {delay(1000); set=0;}
if (digitalRead(ab) == LOW && setter == 0) {zaehler = zaehler-1; setter=1;}
if (digitalRead(ab) == HIGH && setter == 1) {delay(1000); setter=0;}
if (digitalRead(reset) == LOW && setting == 0) {zaehler =0; setting=1;}
if (digitalRead(reset) == HIGH && setting == 1) {delay(1000); setting=0;}
if (zaehler = 0)
{for (int j = 0; j<48; j++) {digitalWrite(LED[j], LOW);}}
if (zaehler = 1) {digitalWrite(LED[1], HIGH);} else {digitalWrite(LED[1], LOW);}
if (zaehler = 2) {digitalWrite(LED[2], HIGH);} else {digitalWrite(LED[2], LOW);}
if (zaehler = 3) {digitalWrite(LED[3], HIGH);} else {digitalWrite(LED[3], LOW);}
if (zaehler = 4) {digitalWrite(LED[4], HIGH);} else {digitalWrite(LED[4], LOW);}
if (zaehler = 5) {digitalWrite(LED[5], HIGH);} else {digitalWrite(LED[5], LOW);}
if (zaehler = 6) {digitalWrite(LED[6], HIGH);} else {digitalWrite(LED[6], LOW);}
if (zaehler = 7) {digitalWrite(LED[7], HIGH);} else {digitalWrite(LED[7], LOW);}
if (zaehler = 8) {digitalWrite(LED[8], HIGH);} else {digitalWrite(LED[8], LOW);}
if (zaehler = 9) {digitalWrite(LED[9], HIGH);} else {digitalWrite(LED[9], LOW);}
if (zaehler = 10) {digitalWrite(LED[10], HIGH);} else {digitalWrite(LED[10], LOW);}
if (zaehler = 11) {digitalWrite(LED[11], HIGH);} else {digitalWrite(LED[11], LOW);}
if (zaehler = 12) {digitalWrite(LED[12], HIGH);} else {digitalWrite(LED[12], LOW);}
if (zaehler = 13) {digitalWrite(LED[13], HIGH);} else {digitalWrite(LED[13], LOW);}
if (zaehler = 14) {digitalWrite(LED[14], HIGH);} else {digitalWrite(LED[14], LOW);}
if (zaehler = 15) {digitalWrite(LED[15], HIGH);} else {digitalWrite(LED[15], LOW);}
if (zaehler = 16) {digitalWrite(LED[16], HIGH);} else {digitalWrite(LED[16], LOW);}
if (zaehler = 17) {digitalWrite(LED[17], HIGH);} else {digitalWrite(LED[17], LOW);}
if (zaehler = 18) {digitalWrite(LED[18], HIGH);} else {digitalWrite(LED[18], LOW);}
if (zaehler = 19) {digitalWrite(LED[19], HIGH);} else {digitalWrite(LED[19], LOW);}
if (zaehler = 20) {digitalWrite(LED[20], HIGH);} else {digitalWrite(LED[20], LOW);}
if (zaehler = 21) {digitalWrite(LED[21], HIGH);} else {digitalWrite(LED[21], LOW);}
if (zaehler = 22) {digitalWrite(LED[22], HIGH);} else {digitalWrite(LED[22], LOW);}
if (zaehler = 23) {digitalWrite(LED[23], HIGH);} else {digitalWrite(LED[23], LOW);}
if (zaehler = 24) {digitalWrite(LED[24], HIGH);} else {digitalWrite(LED[24], LOW);}
if (zaehler = 25) {digitalWrite(LED[25], HIGH);} else {digitalWrite(LED[25], LOW);}
if (zaehler = 26) {digitalWrite(LED[26], HIGH);} else {digitalWrite(LED[26], LOW);}
if (zaehler = 27) {digitalWrite(LED[27], HIGH);} else {digitalWrite(LED[27], LOW);}
if (zaehler = 28) {digitalWrite(LED[28], HIGH);} else {digitalWrite(LED[28], LOW);}
if (zaehler = 29) {digitalWrite(LED[29], HIGH);} else {digitalWrite(LED[29], LOW);}
if (zaehler = 30) {digitalWrite(LED[30], HIGH);} else {digitalWrite(LED[30], LOW);}
if (zaehler = 31) {digitalWrite(LED[31], HIGH);} else {digitalWrite(LED[31], LOW);}
if (zaehler = 32) {digitalWrite(LED[32], HIGH);} else {digitalWrite(LED[32], LOW);}
if (zaehler = 33) {digitalWrite(LED[33], HIGH);} else {digitalWrite(LED[33], LOW);}
if (zaehler = 34) {digitalWrite(LED[34], HIGH);} else {digitalWrite(LED[34], LOW);}
if (zaehler = 35) {digitalWrite(LED[35], HIGH);} else {digitalWrite(LED[35], LOW);}
if (zaehler = 36) {digitalWrite(LED[36], HIGH);} else {digitalWrite(LED[36], LOW);}
if (zaehler = 37) {digitalWrite(LED[37], HIGH);} else {digitalWrite(LED[37], LOW);}
if (zaehler = 38) {digitalWrite(LED[38], HIGH);} else {digitalWrite(LED[38], LOW);}
if (zaehler = 39) {digitalWrite(LED[39], HIGH);} else {digitalWrite(LED[39], LOW);}
if (zaehler = 40) {digitalWrite(LED[40], HIGH);} else {digitalWrite(LED[40], LOW);}
if (zaehler = 41) {digitalWrite(LED[41], HIGH);} else {digitalWrite(LED[41], LOW);}
if (zaehler = 42) {digitalWrite(LED[42], HIGH);} else {digitalWrite(LED[42], LOW);}
if (zaehler = 43) {digitalWrite(LED[43], HIGH);} else {digitalWrite(LED[43], LOW);}
if (zaehler = 44) {digitalWrite(LED[44], HIGH);} else {digitalWrite(LED[44], LOW);}
if (zaehler = 45) {digitalWrite(LED[45], HIGH);} else {digitalWrite(LED[45], LOW);}
if (zaehler = 46) {digitalWrite(LED[46], HIGH);} else {digitalWrite(LED[46], LOW);}
if (zaehler = 47) {digitalWrite(LED[47], HIGH);} else {digitalWrite(LED[47], LOW);}
if (zaehler = 48) {digitalWrite(LED[48], HIGH);} else {digitalWrite(LED[48], LOW);}
}