Paso 9: Cargar programa en Arduino
Ahora sube el siguiente programa a su Arduino:
#include
#include #include
#define dirección 0x48
Lcd de Adafruit_RGBLCDShield = Adafruit_RGBLCDShield();
const int leftSwitch = 8; //pushbutton izquierda const int rightSwitch = 2. //pushbutton derecho
int leftLED = 5; int rightLED = 3; int nightLED = 6; int ledvalue = 0;
int buttonStateLeft = 0; int buttonStateRight = 0;
lightSensor int = A0; int sensorValue = 0;
int auxDio = 11; //auxilary salida entrada int auxValue = 0; int auxAo = A0; ///analoug salida
void setup() {//initialize LED; pinMode (nightLED, salida); pinMode (leftLED, salida); pinMode (rightLED, salida); //initialize botones; pinMode (leftSwitch, entrada); pinMode (rightSwitch, entrada);
}
void loop() {}
Programa de instalación de LED de noche; PRUEBA de trabajo de LEDs con analogWrite (rightLED, 100); analogWrite (leftLED, 100);analogWrite(nightLED,100);
sensorValue = analogRead(lightSensor); if(sensorValue < 12) {analogWrite(nightLED,100);} si (sensorValue > 8) {analogWrite(nightLED,0);
} //setup intermitentes
buttonStateLeft=digitalRead(leftSwitch); comprobar si el pulsador está presionado. Si es así, buttonState es alta; if(buttonStateLeft==High) {//turn LED en; digitalWrite (leftLED, HIGH); digitalWrite (rightLED, LOW);} else {digitalWrite (leftLED, LOW); digitalWrite (rightLED, bajo);
}
buttonStateRight=digitalRead(rightSwitch); if(buttonStateRight==High) {digitalWrite(rightLED,HIGH); digitalWrite (leftLED, LOW);} else {digitalWrite (rightLED, bajo); digitalWrite (leftLED, LOW);}
}