Closed ezu00261 closed 5 years ago
I'm trying to use dial switch on Maix Go. but 'digitalRead(PIN_KEY_UP)' result is -1.
code
#include <Arduino.h> void setup() { Serial.begin(115200); pinMode(PIN_KEY_UP, INPUT); pinMode(PIN_KEY_PRESS, INPUT); pinMode(PIN_KEY_DOWN, INPUT); } void loop() { Serial.print("UP: "); Serial.print(digitalRead(PIN_KEY_UP)); Serial.print(", PRESS: "); Serial.print(digitalRead(PIN_KEY_PRESS)); Serial.print(", DOWN: "); Serial.print(digitalRead(PIN_KEY_DOWN)); Serial.println(""); delay(1000); }
result
> Executing task: platformio device monitor < --- Miniterm on /dev/cu.usbserial-141301 115200,8,N,1 --- --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- UP: -1, PRESS: 1, DOWN: 1 UP: -1, PRESS: 1, DOWN: 1 UP: -1, PRESS: 1, DOWN: 1 UP: -1, PRESS: 1, DOWN: 1 UP: -1, PRESS: 1, DOWN: 1 UP: -1, PRESS: 1, DOWN: 1
and i tried next code. (comment out 'pinMode(PIN_KEY_DOWN)') 'digitalRead(PIN_KEY_UP)' result is ok.
#include <Arduino.h> void setup() { Serial.begin(115200); pinMode(PIN_KEY_UP, INPUT); pinMode(PIN_KEY_PRESS, INPUT); // pinMode(PIN_KEY_DOWN, INPUT); } void loop() { Serial.print("UP: "); Serial.print(digitalRead(PIN_KEY_UP)); Serial.print(", PRESS: "); Serial.print(digitalRead(PIN_KEY_PRESS)); // Serial.print(", DOWN: "); Serial.print(digitalRead(PIN_KEY_DOWN)); Serial.println(); delay(1000); }
> Executing task: platformio device monitor < --- Miniterm on /dev/cu.usbserial-141301 115200,8,N,1 --- --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- ␀␀␀␀␀␀␀UP: 1, PRESS: 1 UP: 1, PRESS: 1 UP: 1, PRESS: 1 UP: 1, PRESS: 1 UP: 1, PRESS: 1 UP: 1, PRESS: 1
i think so 'pinMode(PIN_KEY_DOWN, INPUT)' was override 'pinMode(PIN_KEY_UP)' setting.
I'm trying to use dial switch on Maix Go. but 'digitalRead(PIN_KEY_UP)' result is -1.
code
result
and i tried next code. (comment out 'pinMode(PIN_KEY_DOWN)') 'digitalRead(PIN_KEY_UP)' result is ok.
code
result
i think so 'pinMode(PIN_KEY_DOWN, INPUT)' was override 'pinMode(PIN_KEY_UP)' setting.