Danke Euch Allen!
Nun dachte ich, es wäre Einfach.
War aber nichts.
Dieser Code schaltet so lange man den Taster hält:
Code:
*/
const int ledPin_1 = 8;
const int ledPin = 13;
const int Pin = 6; // Taster
const int Pin_1 = 7; // Taster
void setup()
{
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{
int Taster = digitalRead(6);//Taster A
while (Taster == 1)//while the button is pressed
{
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13, LOW);
Taster = digitalRead(6); //refresh value of variable
}
{
int Taster_1 = digitalRead(7);//Taster B
while (Taster_1 == 1)//while the button is pressed
{
digitalWrite(8, HIGH);
delay(10);
digitalWrite(8, LOW);
Taster_1 = digitalRead(7); //refresh value of variable
}
}
}
Dieser nicht???:
Code:
const int Motor_1 = 10; //Motor
const int Motor_2 = 11;
const int Fern_3 = 4; //Fern Vor
const int Fern_1 = 5; //Fern Rück
const int FERNON = 13;
int Start = 12; // start Motor
void setup() {
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(12, OUTPUT);//Start
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(Start, HIGH);
digitalWrite(FERNON, HIGH);
{
int Taster = digitalRead(Fern_3);//Fern Vor
while (Taster == 1)//while the button is pressed
{
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
delay(100);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
Taster = digitalRead(Fern_3); //refresh value of variable
}
{
int Taster_1 = digitalRead(Fern_1);//Fern vor
while (Taster_1 == 1)//while the button is pressed
{
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
delay(100);
digitalWrite(11, LOW);
digitalWrite(10, LOW);
Taster_1 = digitalRead(Fern_1); //refresh value of variable
}
}
}
}
Wo ist der Fehler?
Wieso fehlt bei mir das Zeichen Codeblock setzen??
Lesezeichen