Analog I/O as Digital

Hi, is it possible to use one or more of the Analog I/O’s as Digital I/O?
If I read the datasheet of the STM32 it should be possible (correct me if i am wrong).

Thanks,
Henk.

Since you can also do that on an Arduino, I would say it should be implemented. Let’s see what the Spark Team has to say.

@nika8991 Yes indeed, they can be used as standard digital I/O

how would I do this? just pinMode(A2, OUTPUT) and digitalWrite(A2, HIGH)?

Yup. When it doubt, try it!

http://spark.github.io/docs/#/hardware/pins-and-i-o-digital-pins

Each pin on the Core can either be configured as input (with or without pull-up or pull-down) or as output (push-pull or open-drain) using the pinMode() function.

1 Like

I test both analogWrite() and digitalWrite() works fine :smile:

int LED = A0;

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

void loop() {
//digitalWrite(LED, HIGH);
analogWrite(LED, 255);
delay(500);
//digitalWrite(LED, LOW);
analogWrite(LED, 0);
delay(500);
}