Skip to content

NewPing not working when using pins D5-D8 #1914

@vermut

Description

@vermut

Basic Infos

Hardware

Hardware: ESP-8266EX (WeMos D1 mini)
Core Version: 2.1.0

Description

NewPing not working when using pins D5-D8.

Settings in IDE

Module: WeMos D1 R2 mini
Flash Size: 4MB/3MB
CPU Frequency: 80Mhz
Upload Using: SERIAL

Sketch

#define PIN     D6     // Not working
// #define PIN     D3     // Working

uint32_t _triggerBit = digitalPinToBitMask(PIN); // Get the port register bitmask for the pin.
volatile uint32_t *_triggerOutput = portOutputRegister(digitalPinToPort(PIN)); // Get the output port register for the pin.
volatile uint32_t *_triggerMode = (uint32_t *) portModeRegister(digitalPinToPort(PIN)); // Get the port mode register for the pin.

void setup() {
  *_triggerMode |= _triggerBit; // Set trigger pin to output.
}

void loop() {
  *_triggerOutput &= ~_triggerBit; // Set the trigger pin low
  delay(1000);
  *_triggerOutput |= _triggerBit;  // Set trigger pin high
  delay(1000);              // wait for a second
}

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

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