in c
#include <hidef.h> /* common defines and macros */
#include <mc9s12dp256.h> /* derivative information */
#include <stdio.h>
#include "lcd.h"
#pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
//scan row and return any key pressed
//returns null if no key pressed
//will only return one character pressed at a time
char keyScanner(int row);
void main( void )
{
char data[17] = {" "}; //string to be sent to lcd
char string[17]; //string to be sent to lcd
int arrayIndex = 0; //current index in string
int scanrow; //which row hcs12 is scanning
unsigned long delay; //used for delay in key debouncing
LCD_init(); /* Enable the LCD display */
//Enable keypad
DDRA = 0xf0; //upper 4 bits control which row to scan, lower 4 bits
are keypad
sprintf(string,"Type on the ");
writeLine(string, 0);
sprintf(string,"keypad. ");
writeLine(string, 1);
while(1) //loop forever
{
for(scanrow=0; scanrow < 4; scanrow++) //start scanning
rows
{
char key = keyScanner(scanrow); //get current key
if (key) //if key is pressed
{
for(delay=0; delay < 120000; delay++); //delay for
debouncing
if (key == keyScanner(scanrow)) //check to see if key is still
pressed
{
data[arrayIndex] = key; //set current index in string to current
key pressed
if (arrayIndex < 15) //make sure we are not exceeding limits of
lcd
{
arrayIndex++; //move to next index
}
else
{
arrayIndex = 0; //overflow, start index over
}
writeLine(data, 0); //write new data to lcd line 0
sprintf(string,"%c=%d in ASCII ", key, key);
writeLine(string, 1);
}
}
}
}
}
//scan row and return any key pressed
//returns null character if no key pressed
//will only return one character pressed at a time
char keyScanner(int row)
{
unsigned char rowCode[4] = {0x10, 0x20, 0x40, 0x80}; //lookup table
for rows to scan
unsigned char keyCode[4][4] = {{49, 50, 51, 65},
{52, 53, 54, 66},
{55, 56, 57, 67},
{42, 48, 35, 68}}; //lookup table for ascii value of key
PORTA = rowCode[row]; //set row to scan
if (PORTA & 0x01) //first key in row
{
return keyCode[row][0];
}
else if (PORTA & 0x02) //second key in row
{
return keyCode[row][1];
}
else if (PORTA & 0x04) //third key in row
{
return keyCode[row][2];
}
else if (PORTA & 0x08) //fourth key in row
{
return keyCode[row][3];
}
return '\0'; //no key pressed, return null character
}
18) Referring to the PIC16F877A Data Sheet and Parallax 27899 4 Matrix-Membrane-Keypad, please co...
please help answer question 4, a-f please
using the data below from chart 1
objectives from lab, thank you
DATA:CA y 3 Ay No3 Part I: Cell Potential of voltaic cells under standard conditions: cell CU CND2 #27 14.0m Give the half Half cell reaction at Combinations Oxidation Reduction E the anode and with [ion] takes place Theoretical takes place cathode. Write in M here here (V) above the arrow E c (V) if it is oxidation or reduction. |-0.340...