You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1013 B
C++
49 lines
1013 B
C++
int amber = 6;
|
|
int evil = 12;
|
|
int sensorinput = 3;
|
|
void setup()
|
|
{
|
|
pinMode(amber, OUTPUT);
|
|
pinMode(sensorinput, INPUT);
|
|
pinMode(evil, OUTPUT);
|
|
Serial.begin(9600);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
digitalWrite(evil, LOW);
|
|
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
|
|
// sets the value (range from 0 to 255):
|
|
int var = digitalRead(sensorinput);
|
|
Serial.println(var);
|
|
if (var == 0) {
|
|
digitalWrite(evil, LOW);
|
|
analogWrite(amber, fadeValue);
|
|
delay(30);
|
|
}
|
|
else {
|
|
analogWrite(amber, 0);
|
|
digitalWrite(evil, HIGH);
|
|
delay(30);
|
|
int var = digitalRead(sensorinput);
|
|
}
|
|
}
|
|
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
|
|
// sets the value (range from 0 to 255):
|
|
int var = digitalRead(sensorinput);
|
|
Serial.println(var);
|
|
if (var == 0) {
|
|
digitalWrite(evil, LOW);
|
|
analogWrite(amber, fadeValue);
|
|
delay(30);
|
|
}
|
|
else {
|
|
analogWrite(amber, 0);
|
|
digitalWrite(evil, HIGH);
|
|
delay(30);
|
|
int var = digitalRead(sensorinput);
|
|
}
|
|
}
|
|
|
|
}
|