More digital outputs

Hi,
I need 12 digital outputs for my project with Photon,
potentionaly I can use 2 Photon, but it sounds not good for me, because of synchronization,

My question is, is possible to have 12 digital outputs with Photon? (like use analog as digital output?)

Thanks so much
Peter

Yes, you can use the analog outputs as digital outputs.

The documentation for the digitalWrite and digitalRead functions says you can and I’ve used A0 and A1 as digital outputs myself.

https://docs.particle.io/reference/firmware/photon/#input-output

Note: All GPIO pins (D0…D7, A0…A7, DAC, WKP, RX, TX) can be used as long they are not used otherwise (e.g. as Serial1 RX/TX).

What drwheetos said is true. And, if you need even more inputs or outputs in the future, you can use an I2C GPIO Expander, [SparkFun sells one] (https://www.sparkfun.com/products/13601) that adds 16 additional input or output pins only using the I2C interface (D0/D1) on the Photon.

1 Like

To use the I2C GPIO Expander from SparkFun I have to modify the code or I can write the code as I would do with an arduino ?

You can use the Arduino library for that one. I normally use the MCP23008 or MCP23017 chips directly now and this library:

The link is for the instructions; the library is also in the community libraries as MCP23008-RK.

2 Likes