Or by 'pins swapping', do you mean declaring software or hardware spi/i2c but with a different pin for the clock signal so as to only have the device(s) with this clock pin connected to actually received data ?
I hadn't really considered that, but yes, that would work great.
For the SD card you have a chip select pin so that might give you something you can use as well?
I'm using the following code for my tests:
Sounds like a good plan with the resistors + analog. I'd say don't use an internal pulldown as it won't work with analogRead (iirc), and make sure that when pressed the voltage changes from 0v to above 1.7v to make sure you get a reliable setWatch.
Also remember that to get analogRead to work you may need to set the mode to analog - or just use pinMode(A0) to set the mode back to auto before using analogRead.
And to get reliable analog readings you may want a (small) capacitor between GND and A0.
You may also be able to put the battery charge status and/or toggle switch on exactly the same A0 pin as well. If your 5 voltages are 2v,2.25v,2.5v,2.75v and 3v then if the toggle switch varied the voltage by 0.05v you could detect that.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I hadn't really considered that, but yes, that would work great.
For the SD card you have a chip select pin so that might give you something you can use as well?
Sounds like a good plan with the resistors + analog. I'd say don't use an internal pulldown as it won't work with analogRead (iirc), and make sure that when pressed the voltage changes from 0v to above 1.7v to make sure you get a reliable setWatch.
Also remember that to get
analogRead
to work you may need to set the mode toanalog
- or just usepinMode(A0)
to set the mode back to auto before using analogRead.And to get reliable analog readings you may want a (small) capacitor between GND and A0.
You may also be able to put the battery charge status and/or toggle switch on exactly the same A0 pin as well. If your 5 voltages are 2v,2.25v,2.5v,2.75v and 3v then if the toggle switch varied the voltage by 0.05v you could detect that.