#include <Arduino.h>
#include"Segment.h"
#include"ShiftReg.h"
#define LATCH 5
#define DATA 4
#define CLOCK 6
#define ARRAY_SIZE_DECIMAL 10
#define BUTTON1 0
#define BUTTON2 1
volatile byte oldPortValue = 0x00;
byte digits[ARRAY_SIZE_DECIMAL] = {0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xF6 };
int main()
{
#ifdef __DEBUG__
dbg_start();
#endif
DDRB &= ~(1<<BUTTON1);
DDRB &= ~(1<<BUTTON2);
PORTB |= (1 << BUTTON1) | (1<<BUTTON2); //pull up enabled
init_shift(DATA,CLOCK,LATCH);
PCICR |= (1<<PCIE0); // set PCIE2 to enable PCMSK2
PCMSK0 |= (1<<PCINT0) | (1<<PCINT1); // enable interrupt for PCINT22 and 23
sei();
while(1)
{
}
}
ISR(PCINT0_vect)
{
byte changeBits;
byte currentPortValue = PINB;
changeBits = currentPortValue ^ oldPortValue;
oldPortValue = currentPortValue;
//PCINT22 changed
if(changeBits & (1<<BUTTON1))
{
//toggle the LED
displyValue(0xFC);
}
//PCINT23 changed
if(changeBits & (1<<BUTTON2))
{
//toggle the LED
displyValue(0x60);
}
}