add Pimp-Your-Pumpkin projects code

master
shark 6 years ago
parent 4c2ff902af
commit a9b9236b00

@ -0,0 +1,48 @@
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);
}
}
}
Loading…
Cancel
Save