Paso 4:
Subir este código a un sketch de Arduino:Código:
int ledPin [] = {2,3,4,5,6,9,10,11};
void setup() {}
Serial.Begin(9600);
establecer todos los pines de salida
para (int x = 0; x < 6; x ++) {}
pinMode (ledPin [x], salida); }
}
void loop()
{
int sensorValue = analogRead(0);
Serial.println (sensorValue, DEC);
Delay(500);
para (int i = 0; i < 6; i ++)
analogWrite (ledPin [i], LOW);
Si (sensorValue > 600 & & sensorValue < 800) {analogWrite (ledPin [0], 200);}
Si (sensorValue > 480 & & sensorValue < 750) {analogWrite (ledPin [1], 160);}
Si (sensorValue > 480 & & sensorValue < 650) {analogWrite (ledPin [2], 180);}
Si (sensorValue > 550 & & sensorValue < 750) {analogWrite (ledPin [3], 130);}
Si (sensorValue > 550 & & sensorValue < 750) {analogWrite (ledPin [4], 180);}
Si (sensorValue > 600 & & sensorValue < 850) {analogWrite (ledPin [5], 160);}
Si (sensorValue > 600 & & sensorValue < 900) {analogWrite (ledPin [6], 100);}
Si (sensorValue > 550 & & sensorValue < 900) {analogWrite (ledPin [7], 200);}
}