Created
September 20, 2018 06:46
-
-
Save leighleighleigh/5445b830058de915d81efb77afbda193 to your computer and use it in GitHub Desktop.
An example of using a GPIO input register to read pin inputs on NodeMCU (esp8266 based) board.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Our super ultra fast input register | |
#define GPIO_IN READ_PERI_REG(0x60000318) | |
#define CHAN0 D1 | |
#define CHAN1 D2 | |
#define CHAN2 D3 | |
#define CHAN3 D4 | |
#define CHAN4 D5 | |
void setup() | |
{ | |
Serial.begin(115200); | |
pinMode(D1, INPUT_PULLUP); | |
pinMode(D2, INPUT_PULLUP); | |
pinMode(D3, INPUT_PULLUP); | |
pinMode(D4, INPUT_PULLUP); | |
pinMode(D5, INPUT_PULLUP); | |
} | |
void loop() | |
{ | |
delay(1000); | |
uint16_t pins = GPIO_IN; | |
Serial.println(pins, BIN); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment