Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Digital read of digital output pins #58

@BrunDog

Description

@BrunDog

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;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions