// basic stuff to start working in AVRstudio #include #include //function prototypes(not needed in the arduini IDE) void getKeyPress(void); void keyData(int keyWord); void shiftout(unsigned char myDataOut); void pinMode(int position, int value); int keyRow,columnData,ledRow,resulte,reset_loop,time_to_check = 0;; unsigned char matrix_data[]={0,0,0,0}; unsigned char word_1=0,word_2=0; int main(void){ DDRB = 0x0F;//pins PB0-PB3 outputs and pins PB4-PB7 inputs DDRD = 0xFF;//pins PD0-PD6 are all outputs while(1){// keeps the program running all the time for(ledRow=0;ledRow<4;ledRow++){// this is the loop for scanning the LED display time_to_check ++;//counts the time until the next key press check(to prevent flickering of the matrix) PORTD = 1<> 8) & 0x00FF; break; case 0b00010100://subtraction resulte = word_1 - word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00011000://division resulte = word_1 / word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00010001://addition resulte = word_1 + word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00100010://modulo resulte = word_1 % word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00100100://XOR resulte = word_1 ^ word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00101000://OR resulte = word_1 | word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b00100001://AND resulte = word_1 & word_2; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b10000001://NOT resulte = ~resulte; matrix_data[1] = resulte & 0x00FF; matrix_data[0] = (resulte >> 8) & 0x00FF; break; case 0b01000001://DEL ALL word_1 = 0; word_2 = 0; resulte =0; for(reset_loop=0;reset_loop<4;reset_loop++) matrix_data[reset_loop] = 0; break; default:// do nothing at all if more then 1 button is pressed break; } } void shiftout(unsigned char myDataOut) { // the function for sending the data to the shift register int i; int pinState=0; pinMode(4,0); pinMode(6,0); for (i=7; i>=0; i--) { pinMode(6,0); if ( myDataOut & (1<