kk logo

 Motorrad LED Ganganzeige mit Arduino und Ardublock

 

Hier gehts zum YouTube Video

 

Zip. Datei mit Ardublock und Arduino IDE

 

Arduino Code 

-----------------------------------------------------------------------------

int time1 = 0 ;
int gang = 0 ;
bool HOCH= false ;
bool RUNTER= false ;
void Unterprogramm1();
void Unterprogramm0();
void setup()
{
pinMode( 2 , INPUT);
pinMode( 3 , INPUT);
pinMode( 11 , OUTPUT);
pinMode( 5 , OUTPUT);
pinMode( 6 , OUTPUT);
pinMode( 7 , OUTPUT);
pinMode( 8 , OUTPUT);
pinMode( 9 , OUTPUT);
pinMode( 10 , OUTPUT);
Serial.begin(9600);
time1 = 400 ;
gang = 2 ;Unterprogramm0();}void loop()
{
while ( ( digitalRead(2) && ( ( gang ) < ( 7 ) ) ) )
{
delay( 100 );
HOCH = HIGH ;
}
if (( ( HOCH ) == ( HIGH ) ))
{
HOCH = LOW ;
gang = ( gang + 1 ) ;
}
while ( ( digitalRead(3) && ( ( gang ) > ( 1 ) ) ) )
{
delay( 100 );
RUNTER = HIGH ;
}
if (( ( RUNTER ) == ( HIGH ) ))
{
RUNTER = LOW ;
gang = ( gang - 1 ) ;
}
if (( ( gang ) == ( 1 ) ))
{
Unterprogramm1();
digitalWrite(5 , HIGH);
}
if (( ( gang ) == ( 2 ) ))
{
Unterprogramm1();
digitalWrite(6 , HIGH);
}
if (( ( gang ) == ( 3 ) ))
{
Unterprogramm1();
digitalWrite(7 , HIGH);
}
if (( ( gang ) == ( 4 ) ))
{
Unterprogramm1();
digitalWrite(8 , HIGH);
}
if (( ( gang ) == ( 5 ) ))
{
Unterprogramm1();
digitalWrite(9 , HIGH);
}
if (( ( gang ) == ( 6 ) ))
{
Unterprogramm1();
digitalWrite(10 , HIGH);
}
if (( ( gang ) == ( 7 ) ))
{
Unterprogramm1();
digitalWrite(11 , HIGH);
}
Serial.print("gang");
Serial.print(gang);
Serial.print(" ");
Serial.println();
}
void Unterprogramm1()
{
digitalWrite(5 , LOW);
digitalWrite(6 , LOW);
digitalWrite(7 , LOW);
digitalWrite(8 , LOW);
digitalWrite(9 , LOW);
digitalWrite(10 , LOW);
digitalWrite(11 , LOW);
}
void Unterprogramm0()
{
digitalWrite(5 , HIGH);
delay( time1 );
digitalWrite(6 , HIGH);
delay( time1 );
digitalWrite(7 , HIGH);
delay( time1 );
digitalWrite(8 , HIGH);
delay( time1 );
digitalWrite(9 , HIGH);
delay( time1 );
digitalWrite(10 , HIGH);
delay( time1 );
digitalWrite(11 , HIGH);
delay( time1 );
digitalWrite(5 , LOW);
digitalWrite(6 , LOW);
digitalWrite(7 , LOW);
digitalWrite(8 , LOW);
digitalWrite(9 , LOW);
digitalWrite(10 , LOW);
digitalWrite(11 , LOW);
delay( time1 );
}

 

King of my heart

Let the King of my heart
Be the mountain where I run
The fountain I drink from
Oh, He is my song

Ronnie

schwäbischer tüftler und bastler, kraftsportler, ADHS power, 43 Jahre, 1 Frau, 5 Kinder und 1003 Ideen. 

ronnie berzins at mee