kk logo

 

 

heisser draht fuer 2 zwei spieler bauanleitung

 

 

Code 

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

 

#include <Adafruit_NeoPixel.h>

int start = 0 ;
int startlinks = 0 ;
int startrechts = 0 ;
int a;
int fehlerlinks = 0 ;
int fehlerrechts = 0 ;
int helligkeit = 0 ;
Adafruit_NeoPixel strip_pin5 = Adafruit_NeoPixel(8,5, NEO_RGB + NEO_KHZ800);

void Unterprogramm9();
void Unterprogramm();
void Unterprogramm12();
void Unterprogramm1();
void Unterprogramm2();
void Unterprogramm3();
void Unterprogramm8();

void setup()
{
pinMode( 3 , INPUT);
pinMode( 2 , INPUT);
pinMode( 10 , INPUT);
pinMode( 9 , INPUT);
pinMode( 11 , INPUT);
pinMode( 12 , INPUT);
pinMode( 7 , OUTPUT);
digitalWrite(12, HIGH);
digitalWrite(11, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
strip_pin5.begin();
strip_pin5.show();
Unterprogramm();

Unterprogramm8();

}

void loop()
{
if (( ( !( digitalRead(10) ) || !( digitalRead(12) ) ) && ( ( start ) == ( 0 ) ) ))
{
Unterprogramm8();
start = 1 ;
startlinks = 1 ;
startrechts = 1 ;
digitalWrite( 7 , HIGH );
for (a=1; a<= ( 3 ); ++a )
{
tone(6, 500, 500);
delay( 1000 );
}
tone(6, 800, 1000);
delay( 1000 );
digitalWrite( 7 , LOW );
}
Unterprogramm1();
Unterprogramm2();
Unterprogramm3();
}

void Unterprogramm12()
{
digitalWrite( 7 , HIGH );
tone(6, 900, 3000);
delay( 3000 );
digitalWrite( 7 , LOW );
}

void Unterprogramm9()
{
fehlerlinks = 5 ;
startrechts = 5 ;
startlinks = 5 ;
fehlerrechts = 5 ;
start = 0 ;
}

void Unterprogramm()
{
fehlerlinks = 5 ;
startrechts = 0 ;
startlinks = 0 ;
fehlerrechts = 5 ;
helligkeit = 180 ;
start = 0 ;
}

void Unterprogramm3()
{
if (( !( digitalRead(2) ) && ( ( fehlerrechts ) == ( 0 ) ) ))
{
Unterprogramm9();
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(0,0 ,0 ,120 );
strip_pin5.setPixelColor(1,0 ,0 ,120 );
strip_pin5.setPixelColor(2,0 ,0 ,120 );
strip_pin5.setPixelColor(5,0 ,120 ,0 );
strip_pin5.setPixelColor(6,0 ,120 ,0 );
strip_pin5.setPixelColor(7,0 ,120 ,0 );
strip_pin5.show();
Unterprogramm12();
}
if (( !( digitalRead(3) ) && ( ( fehlerlinks ) == ( 0 ) ) ))
{
Unterprogramm9();
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(5,0 ,0 ,120 );
strip_pin5.setPixelColor(6,0 ,0 ,120 );
strip_pin5.setPixelColor(7,0 ,0 ,120 );
strip_pin5.setPixelColor(0,0 ,120 ,0 );
strip_pin5.setPixelColor(1,0 ,120 ,0 );
strip_pin5.setPixelColor(2,0 ,120 ,0 );
strip_pin5.show();
Unterprogramm12();
}
}

void Unterprogramm1()
{
if (( !( digitalRead(10) ) && ( ( startrechts ) == ( 1 ) ) ))
{
fehlerrechts = 0 ;
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(0,120 ,0 ,0 );
strip_pin5.setPixelColor(1,120 ,0 ,0 );
strip_pin5.setPixelColor(2,120 ,0 ,0 );
strip_pin5.show();
}
if (( !( digitalRead(12) ) && ( ( startlinks ) == ( 1 ) ) ))
{
fehlerlinks = 0 ;
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(5,120 ,0 ,0 );
strip_pin5.setPixelColor(6,120 ,0 ,0 );
strip_pin5.setPixelColor(7,120 ,0 ,0 );
strip_pin5.show();
}
}

void Unterprogramm2()
{
if (( ( ( startrechts ) == ( 1 ) ) && !( digitalRead(9) ) ))
{
fehlerrechts = 1 ;
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(0,0 ,120 ,0 );
strip_pin5.setPixelColor(1,0 ,120 ,0 );
strip_pin5.setPixelColor(2,0 ,120 ,0 );
strip_pin5.show();
}
if (( ( ( startlinks ) == ( 1 ) ) && !( digitalRead(11) ) ))
{
fehlerlinks = 1 ;
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(5,0 ,120 ,0 );
strip_pin5.setPixelColor(6,0 ,120 ,0 );
strip_pin5.setPixelColor(7,0 ,120 ,0 );
strip_pin5.show();
}
}

void Unterprogramm8()
{
strip_pin5.setBrightness(helligkeit);
strip_pin5.setPixelColor(0,0 ,0 ,0 );
strip_pin5.setPixelColor(1,0 ,0 ,0 );
strip_pin5.setPixelColor(2,0 ,0 ,0 );
strip_pin5.setPixelColor(3,0 ,0 ,70 );
strip_pin5.setPixelColor(4,0 ,0 ,70 );
strip_pin5.setPixelColor(5,0 ,0 ,0 );
strip_pin5.setPixelColor(6,0 ,0 ,0 );
strip_pin5.setPixelColor(7,0 ,0 ,0 );
strip_pin5.show();
}

by grace

By grace alone somehow I standWhere even angels fear to treadInvited by redeeming loveBefore the throne of God aboveHe pulls me close with nail-scarred handsInto His everlasting arms

Ronnie

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

ronnie berzins at mee