void setup() {
// put your setup code here, to run once:
DDRF = 0b11111111; //LEO 1-8
DDRK = 0b11111111; //LED 9-16
DDRA = 0b00001111; //Digital Input (Switch)
Serial.begin(9600) ;
}
void loop (){
int button = PINA & 0b11110000 ;
Serial.println(button);
delay(500);
// 1111 คือ 16 , 32 , 64 , 128 ตามลำดับ
// 0 คือ LED on ; 1 คือ LED off
if(button == 0)
{
PORTF = 0b11111110 ;
PORTK = 0b11111111 ;
}
else if(button == 16 )
{
PORTF = 0b11111100;
}
else if(button == 32 )
{
PORTF = 0b11111000;
}
else if(button == 48)
{
PORTF = 0b11110000;
}
else if(button == 64 )
{
PORTF = 0b11100000;
}
else if(button == 80 )
{
PORTF = 0b11000000;
}
else if(button == 96 )
{
PORTF = 0b10000000;
}
else if(button == 112 )
{
PORTF = 0x00;
PORTK = 0b11111111;
}
else if(button == 128 )
{
PORTF = 0x00;
PORTK = 0b11111110;
}
else if(button == 144 )
{
PORTF = 0x00;
PORTK = 0b11111100;
}
else if(button == 160 )
{
PORTF = 0x00;
PORTK = 0b11111000;
}
else if(button == 176 )
{
PORTF = 0x00;
PORTK = 0b11110000;
}
else if(button == 192 )
{
PORTF = 0x00;
PORTK = 0b11100000;
}
else if(button == 208 )
{
PORTF = 0x00;
PORTK = 0b11000000;
}
else if(button == 224 )
{
PORTF = 0x00;
PORTK = 0b10000000;
}
else if(button == 240 )
{
PORTF = 0x00;
PORTK = 0x00;
}
}