kk logo

bahnuebergang programm bauen basteln

 

#include (servo.h) --> die beiden Klammen durch Eckige Klammern ersetzen!!!

int taster = 0 ;
int zaeler = 0 ;
int faktor = 0 ;
Servo servo_pin_11;
int a;

void Unterprogramm();

void setup()
{
pinMode( 2 , INPUT);
servo_pin_11.attach(11);
Serial.begin(9600);
pinMode( 4 , OUTPUT);
pinMode( 3 , OUTPUT);
taster = 0 ;

zaeler = 0 ;

faktor = 3 ;

servo_pin_11.write( zaeler );

delay( 1000 );

servo_pin_11.detach();

Serial.print("bereit");
Serial.println();

}

void loop()
{
if (( digitalRead(2) && ( ( taster ) == ( 0 ) ) ))
{
Serial.print("taster links gedrueckt");
Serial.println();
servo_pin_11.attach(11);
digitalWrite( 4 , HIGH );
for (a=1; a<= ( 180 ); ++a )
{
servo_pin_11.write( zaeler );
zaeler = ( zaeler + 1 ) ;
delay( 10 );
Unterprogramm();
Serial.print(zaeler);
Serial.println();
}
digitalWrite( 3 , LOW );
digitalWrite( 4 , LOW );
servo_pin_11.detach();
taster = 1 ;
zaeler = 180 ;
Serial.print("ende");
Serial.println();
}
if (( digitalRead(2) && ( ( taster ) == ( 1 ) ) ))
{
Serial.print("taster rechts gedrueckt");
Serial.println();
servo_pin_11.attach(11);
digitalWrite( 4 , HIGH );
for (a=1; a<= ( 180 ); ++a )
{
servo_pin_11.write( zaeler );
zaeler = ( zaeler - 1 ) ;
delay( 10 );
Unterprogramm();
Serial.print(zaeler);
Serial.println();
}
digitalWrite( 3 , LOW );
digitalWrite( 4 , LOW );
servo_pin_11.detach();
taster = 0 ;
zaeler = 0 ;
Serial.print("ende");
Serial.println();
}
}

void Unterprogramm()
{
if (( ( zaeler ) == ( ( 10 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 20 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 30 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 40 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 50 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 60 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 70 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 80 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 90 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 100 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 110 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 120 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 130 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 140 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 150 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 160 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
if (( ( zaeler ) == ( ( 170 * faktor ) ) ))
{
digitalWrite( 3 , HIGH );
digitalWrite( 4 , LOW );
}
if (( ( zaeler ) == ( ( 180 * faktor ) ) ))
{
digitalWrite( 4 , HIGH );
digitalWrite( 3 , LOW );
}
}

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