hallo landsleut,
ich bekomm es einfach nicht auf den schirm. was muss ich tun damit das nichtmehr automatisch von LED eins zu LED 16
zählt sondern immer nur dann wenn ich einen schalter drücke.
ziel ist:
arduino an den strom hängen, LED 1 leuchtet, nun drück ich den taster, LED eins geht aus und die zweite LED geht an .. usw
nach der16ten LED fängt alles wieder von vorne an = tastedrück, nächste LED.
ich weiss das ich das mit den variablen
int tasterstatus = 0; //pressing this button
int tasterValue = 0; //i think i need that integer
int previousTasterValue = 0; // and this one
machen muss, dazu IF und else kommandos setzen muss .. nur wie und wo.
das die leds vor und zurücklaufen hab ich auch schon hinbekommen und auch das man zwischen nur vor und vor/zurück wechseln
kann .... aber das die leds nur durch tastendruck vorlaufen bekomm ich einfach nich hin.
mit ner analogen schlatung würde ich das hinbekommen, digital und programmieren sind aber NEULAND welches
ich unbedingt betreten will. das spart massig analoge komponenten.
wäre ganz super wenn mir jemand helfen könnte. danke im voraus und beste grüße vom anfänger
int ledPin[] = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45};
int schalterPin = 8;
int schalterStatus;
int sensorPin = A1;
int taster = 22; //doesnt know how i can start counting led after led by
int tasterstatus = 0; //pressing this button
int tasterValue = 0; //i think i need that integer
int previousTasterValue = 0; // and this one
int sensorValue;
void setup()
{
for(int i = 0; i < 16; i++)
for(int i = 15; i >= 0; i--)
pinMode(ledPin[i], OUTPUT);
pinMode(schalterPin, INPUT);
}
/*void forthback(){ // the delay is unusual but iam glad that iam able to control the rate :)
for (int i = 0; i < 16; i++)
{
sensorValue = analogRead(sensorPin);
// turn the pin on:
digitalWrite(ledPin[i], HIGH);
delay(sensorValue);
// turn the pin off:
digitalWrite(ledPin[i], LOW);
}
// loop from the highest pin to the lowest:
for (int i = 15; i >= 0; i--)
{
sensorValue = analogRead(sensorPin);
// turn the pin on:
digitalWrite(ledPin[i], HIGH);
delay(sensorValue);
// turn the pin off:
digitalWrite(ledPin[i], LOW);
}
}*/
void forth(){ // lets take this one for experimenting
for (int i = 0; i < 16; i++)
{
sensorValue = analogRead(sensorPin); // do i need to insert a IF ELSE commandline here?
digitalWrite(ledPin[i], HIGH); // how can i make it count ????
delay(sensorValue);
// turn the pin off:
digitalWrite(ledPin[i], LOW);
}
}
void loop() { // here i can switch between leds forware or forward and then backward
schalterStatus = digitalRead(schalterPin);
if(schalterStatus == HIGH)
forthback();
else
forth();
}