ArduinoCore-primo icon indicating copy to clipboard operation
ArduinoCore-primo copied to clipboard

Digital read of digital output pins

Open BrunDog opened this issue 7 years ago • 0 comments

All Arduino / open source variants I have tested (ATMEGA328, ATMEGA2560, ATSAM3X8E, SAMD, Curie, ESP8266, ATSAMD21, ESP32) will properly report an output pin's state via digitalRead();. The nrf52 based Primo does not correctly report unless the pin has been declared an input first. Example:

boolean oneshot = false;

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  Serial.println(digitalRead(LED_BUILTIN));
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
  Serial.println(digitalRead(LED_BUILTIN));
  if ((millis() > 15000) && !oneshot)
  {
    pinMode(LED_BUILTIN, INPUT);
    delay(200);
    pinMode(LED_BUILTIN, OUTPUT);
    oneshot = true;
  }
}

BrunDog avatar Aug 31 '17 19:08 BrunDog