#include "Button.h"
#include "Main.h"
// #include "Config.h"
uint8_t data;
uint8_t mask = 0;
uint8_t* p_data;
uint8_t LED_PIN[] = {5, 6, 7};
byte incomming;
uint8_t count = 0;
byte state = 0b111;
Button button;
void key_scan() {
digitalWrite(latchPin, LOW);
digitalWrite(latchPin, HIGH);
// Serial.print("Bits: ");
for (int i = 0; i < numBits; i++) {
data <<= 1;
if (digitalRead(dataPin) == HIGH)
{
data |= 0x01;
}
digitalWrite(clockPin, HIGH); // Shift out the next bit
digitalWrite(clockPin, LOW);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(dataPin, INPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
DDRA = 0b00000111;
PORTA = 0b00000000;
}
void loop() {
// put your main code here, to run repeatedly:
key_scan();
// *p_data = &data;
button.get_state(&data);
// Serial.println(button.state());
if (button.state() == 2)
{
mask ^= ~data;
// Serial.println(data, BIN);
PORTA = mask;
mask = 0;
// Serial.println(PORTA, BIN);
}
else PORTA &= 0;
// if(state != data)
// {
// state = data;
// if(button.state() == 2)
// {
// Serial.println(count);
// count ++;
// PORTA |= ~data;
// }
// // else Serial.println("release!");
// }
// else PORTA &= 0;
// // Serial.println(count);
// delay(1000);
}