You are reading a single comment by @ptone and its replies. Click here to read the full conversation.
  • While I can maintain the state of the LED in the JS impl - I would like to be able to just read the register for the digital pin connected to an LED

    Arduino seems to support reading from and OUT pin
    https://stackoverflow.com/questions/6160­963/how-can-i-digitalread-a-pin-that-is-­in-pinmode-output

    But this does not work the same/expected way in Espruino:

    pinMode(5, 'output')
    =undefined
    digitalWrite(5,1)
    =undefined
    digitalRead(5)
    =0

    I can sort of get what I want by using pin auto mode and making sure that every read writes back itself like this:

    pinMode(5)
    digitalWrite(5,1)
    var x;
    x = digitalRead(5); digitalWrite(5,x)
    x
    =1

    But I was thinking there should be a way I should just be able to read the state?

    I'm guessing I could use peek* functions to get at the register directly? But that seems very un-espruino like from a dev-ux POV

    Any ideas on the right solution here?

About

Avatar for ptone @ptone started