Encender y apagar leds con el mando a distancia.

No se como sería, porque tampoco esto, que entiendo me debería devolver algo, me está mandando nada hacia el Serial

int ledPin = 9;


void setup() {
  pinMode(ledPin, OUTPUT);      
}

void loop()
{
    digitalWrite(ledPin, HIGH);
    
    int pinState = digitalRead(ledPin);
    
    Serial.println(pinState);
    
    delay (100);
}

Acá algo explican de esto en inglés, pero no entendí bien :stuck_out_tongue:

http://playground.arduino.cc/Learning/AnalogPins

The analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output.

Al parecer debo establecerlo como INPUT antes de querer hacer la lectura, pero buscaré ejemplos de esto, que no quiero meter la pata :stuck_out_tongue: Imagino que será que se puede hacer dentro del loop esto, ahora me toca ver como, si es de la manera "obvia" o si hay que considerar algo primero.

CUIDADO

The Atmega168 datasheet also cautions against switching digital pins in close temporal proximity to making A/D readings (analogRead) on other analog pins. This can cause electrical noise and introduce jitter in the analog system. It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins.