Add one rotary encoder

This commit is contained in:
GHOSCHT 2021-01-01 23:10:04 +01:00
parent 8b247b058d
commit 8bfb44e2e8

View file

@ -2,12 +2,13 @@
#include <Wire.h> #include <Wire.h>
const int SLAVE_ADDR = 9; const int SLAVE_ADDR = 9;
const int CLK_PIN = 5; const int CLK_PIN = 6;
const int DATA_PIN = 6; const int DATA_PIN = 5;
//int prevPlus; //int prevPlus;
const int bjtCount = 4; const int bjtCount = 4;
const int btnPin[bjtCount] = {7, 8, 9, 10}; const int btnPin[bjtCount] = {7, 8, 9, 10};
int prevPlus = 0;
byte btnState[bjtCount]; byte btnState[bjtCount];
byte lastbtnState[bjtCount]; byte lastbtnState[bjtCount];
@ -35,34 +36,34 @@ void transmit(String plus)
void loop() void loop()
{ {
// static uint16_t state = 0; static uint16_t state = 0;
// delayMicroseconds(100); delayMicroseconds(100);
// state = (state << 1) | digitalRead(CLK_PIN) | 0xe000; state = (state << 1) | digitalRead(CLK_PIN) | 0xe000;
// if (state == 0xf000) if (state == 0xf000)
// { {
// state = 0x0000; state = 0x0000;
// if (digitalRead(DATA_PIN)) if (digitalRead(DATA_PIN))
// { {
// if (prevPlus == 1) if (prevPlus == 1)
// { {
// Serial.println("+"); Serial.println("+");
// transmit(1); transmit("2i");
// } }
// prevPlus = 1; prevPlus = 1;
// } }
// else else
// { {
// if (prevPlus == 0) if (prevPlus == 0)
// { {
// Serial.println("-"); Serial.println("-");
// transmit(0); transmit("2d");
// } }
// prevPlus = 0; prevPlus = 0;
// } }
// } }
for (int i = 0; i < bjtCount; i++) for (int i = 0; i < bjtCount; i++)
{ {