input pulldown

This commit is contained in:
andrea
2023-11-04 12:47:46 +01:00
parent e303779acd
commit b1e4cf5bd3

View File

@@ -44,13 +44,13 @@ void setup() {
// stard LED matrix // stard LED matrix
matrix.begin(); matrix.begin();
// btn up // btn up
pinMode(13, INPUT); pinMode(13, INPUT_PULLUP);
// btn right // btn right
pinMode(12, INPUT); pinMode(12, INPUT_PULLUP);
// btn bottom // btn bottom
pinMode(11, INPUT); pinMode(11, INPUT_PULLUP);
// btn left // btn left
pinMode(10, INPUT); pinMode(10, INPUT_PULLUP);
} }
void add_tail_block() { void add_tail_block() {
@@ -126,10 +126,10 @@ void change_direction() {
// left // left
int l= digitalRead(10); int l= digitalRead(10);
if (u == HIGH && direction != 'b') direction= 'u'; if (u == LOW && direction != 'b') direction= 'u';
else if (r == HIGH && direction != 'l') direction= 'r'; else if (r == LOW && direction != 'l') direction= 'r';
else if (b == HIGH && direction != 'u') direction= 'b'; else if (b == LOW && direction != 'u') direction= 'b';
else if (l == HIGH && direction != 'r') direction= 'l'; else if (l == LOW && direction != 'r') direction= 'l';
} }
void loop() { void loop() {