Paso 5: Programar el Arduino
const int switchpin = 1;
const int lowestPin = 2;
const int highestPin = 4; Si desea agregar circuitos adicionales intermitente o LED analógico, se puede añadir entre lowestPin y / / highestPin.
luz int = 0;
brillo de int = 0;
switchstate int = 0;
void setup() {}
pinMode (switchpin, entrada);
pinMode (photopin, entrada);
para (int thisPin = lowestPin; thisPin < = highestPin; thisPin ++) {}
pinMode (thisPin, salida);
}
}
el código comentado puede ser línea para apagar la función fade vestido a digital de en-o dependiente fuera / / brillo.
void loop() {}
switchstate = digitalRead(switchpin);
switchstate = alta;
Si (switchstate == HIGH) {}
luz = analogRead(photopin);
brillo = 255 - (luz/4); fotorresistencia: 40k - 200k
Si (luz > 100) {brillo = alto;}
Else {brillo = bajo;}
para (int thisPin = lowestPin; thisPin < = highestPin; thisPin ++) {}
analogWrite (thisPin, brillo);
}
}
}