

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


// Project: // Author: // Module description: // ***********************************************************
#include <avr\io.h> // Most basic include files #include <avr\interrupt.h> // Add the necessary ones #include <avr\signal.h> // here
// Main program // int main(void) { unsigned char check1, check2, result; unsigned comb[] = {0x00,0x11,0x21,0x41,0x81,0x12,0x22,0x42,0x82,0x14,0x24,0x44,0x84,0x18,0x 28,0x48,0x88}; unsigned portcomb[] = {0x00,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x 0D,0x0E,0x0F}; int i;
while(1) { // for LEDs DDRB = 0x0F;
// checking for Coloumn: DDRA = 0x0F; PORTA = 0x0F; check1 = PINA;
// checking for Row: DDRA = 0xF0; PORTA = 0xF0; check2 = PINA;
// result: result = ((check1 & 0xF0) | (check2 & 0x0F));
for (i=0;i<17;i++) { if(result==comb[i]) { PORTB=~(portcomb[i]); } }
}
}