Sie sind auf Seite 1von 6

int senzor =A0;

int led_3_B = 10;


int led_R = 11;
int led_G = 12;
int led_B = 13;
int i=0;
int j=0;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
Serial.begin(9600);

pinMode(senzor, INPUT);

pinMode(led_3_B, OUTPUT);

pinMode(led_R, OUTPUT);
pinMode(led_G, OUTPUT);
pinMode(led_B, OUTPUT);


}

// the loop routine runs over and over again forever:
void loop() {
int s=analogRead(senzor);
Serial.println(senzor);


if(s<350){
void yellow();
void cyan();
void magenta();
}


if(s<750&&s>>350) {
void RGB_HIGH();
white();
}


if(s>749)
blue();}



void yellow(){
for(int i=0;i<255;i++)
for(int j=0;j<255;j++)

digitalWrite(led_R,i);
digitalWrite(led_G,j);
delay(50);

}


void cyan(){

for( i=0;i<255;i++)
for( j=0;j<255;j++)
digitalWrite(led_G,i);
digitalWrite(led_B,j);
delay(50);
}

void magenta(){

for( i=0;i<255;i++)
for( j=0;j<255;j++)

digitalWrite(led_B,i);
digitalWrite(led_R,j);

delay(50);
}

void white(){

digitalWrite(led_R,HIGH);
digitalWrite(led_G,HIGH);
digitalWrite(led_B,HIGH);

delay(1000);

digitalWrite(led_R,LOW);
digitalWrite(led_G,LOW);
digitalWrite(led_B,LOW);

delay(1000);

}




void RGB_HIGH(){
digitalWrite(led_R, HIGH); // turn the LED on (HIGH is the voltage level)
delay(90); // wait for a second
digitalWrite(led_R, LOW); // turn the LED on (HIGH is the voltage level)
delay(90);

digitalWrite(led_G, HIGH); // turn the LED on (HIGH is the voltage level)
delay(140); // wait for a second

digitalWrite(led_G, LOW); // turn the LED off by making the voltage LOW
delay(140);

digitalWrite(led_B, HIGH); // turn the LED on (HIGH is the voltage level)
delay(180); // wait for a second

digitalWrite(led_B, LOW); // turn the LED off by making the voltage LOW
delay(180); // wait for a second
}


void blue(){

digitalWrite(led_3_B, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(led_3_B, LOW); // turn the LED off by making the voltage LOW
delay(100);

}

Das könnte Ihnen auch gefallen