SlideShare a Scribd company logo
1 of 18
Download to read offline
Combine the keypad and LCD codes in compliance to the following requirements: your last
name to appear on LCD row 1, your last name to appear on row 2, and on row 3 ‘Key pressed:’
with ‘ ‘,0,1,2,A,3,4,5,6,B,7,8,9,C,*,0,#,D in row 3 column 14.
// Displaying messages on the 3 x 16 LCD
// PORT C7 - PORT C4 output (LCD data bus); PORT C2 – PORT C0 output (LCD control
signals)
// PORTB7 output (LCD Chip Select Bit – active Low)
// Includes LCD initialization routine
#include /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
//globals - 4-bit initialization sequence for LCD - data: PC7,6,5,4 E: PC2 R/W~: PC1 RS: PC0
const unsigned char cInit_commands[20] =
{0x30,0x30,0x30,0x20,0x20,0x90,0x10,0x50,0x70,0x80,0x50,0xE0,
0x60,0xA0,0x00,0xE0,0x00,0x10,0x00,0x60};
const unsigned char cMessage[3][17] =
{ {'D','a','v','e''},
{' ',' ','s','m','i','t','h' '},
{' ',' ',' ','T'';}};//data in Program Flash
const unsigned char cE = 0x04;
const unsigned char cRS = 0x01;
unsigned char cValues;
int p;
//function prototypes
void initLCD(void);
void initPorts(void);
void LCDputs(char*);
void LCDputch(char);
void cmdwrt(unsigned char);
void datawrt(char);
void position(int,int);
void delay1u(void);
void delay100u(void);
void delay2m(void);
void delays(int);
/************main************/
void main()
{
initPorts( ); // port initializations
initLCD( ); // LCD inititialization
cValues = 'C';
// datawrt('6'); // demonstrates single character write
// position(1,0);
// LCDputs(" "); // blank row 1
// position(2,0);
// LCDputs(" "); // blank row 2
// position(3,0);
// LCDputs(" "); // blank row 3
for(;;)
{
for (p=0;p<3;p++)
{
position(p+1,0);
LCDputs(cMessage[p]); //passes message address
}
delays(20000); //wait a long time
} /* forever loop */
}
/*********functions*********/
void initPorts( )
{
unsigned char cValue;
DDRB = 0x80; //LCD CSB active low
DDRC = 0xFF; // PC7-PC4 - 4-bit LCD data bus, PC2 - E, PC1 - R/W~, PC0 - RS: all
outputs
cValue = PORTB;
PORTB = cValue | 0x00; // LCD CSB (PORT B7) enabled with a logic low
}
// sends initialization commands one-by-one
void initLCD( )
{
unsigned char i;
for (i=0;i<=19;i++)
{
cmdwrt(cInit_commands[i]);
}
}
// sends a control word to LCD bus
void cmdwrt(unsigned char cCtrlword)
{
PORTC = cCtrlword; // output command onto LCD data pins
PORTC = cCtrlword + cE; // generate enable pulse to latch it (xxxx x100)
delay1u( ); // hold it for 1us
PORTC = cCtrlword; // end enable pulse (xxxx x000)
delay2m(); // allow 2ms to latch command inside LCD
PORTC = 0x00;
delay2m(); // allow 2ms to latch command inside LCD
}
void position(int iRow_value, int iCol_value)
{
int iPos_h, iPos_l, iValue;
if(iRow_value == 1) iValue = (0x80+0x00);
if(iRow_value == 2) iValue = (0x80+0x10);
if(iRow_value == 3) iValue = (0x80+0x20);
iPos_h=((iValue + iCol_value) & 0xF0);
iPos_l=((iValue + iCol_value) & 0x0F) << 4;
cmdwrt(iPos_h);
cmdwrt(iPos_l);
}
//Sends a string of characters to the LCD;...
void LCDputs(char *sptr)
{
while(*sptr)
{ //...the string must end in a 0x00 (null character)
datawrt(*sptr); // sptr is a pointer to the characters in the string
++sptr;
}
}
//Sends a single character to the LCD;...
void LCDputch(char cValues)
{
datawrt(cValues); // single character value
}
// sends the character passed in by caller to LCD
void datawrt(char cAscii)
{
char cAscii_high, cAscii_low;
cAscii_high = (cAscii & 0xF0);
cAscii_low = (cAscii & 0x0F) << 4; // Shift left by 4 bits
PORTC = cAscii_high; // output ASCII character upper nibble onto LCD data
pins
PORTC = cAscii_high + cRS + cE; // generate enable pulse to latch it (0xxx x101)
delay1u( ); // hold it for 1us
PORTC = cAscii_high + cRS; // end enable pulse (0xxx x001)
delay1u( ); // hold it for 1us
PORTC = cAscii_low; // output ASCII character lower nibble onto LCD data
pins
PORTC = cAscii_low + cRS + cE; // generate enable pulse to latch it (0xxx x101)
delay1u( ); // hold it for 1us
PORTC = cAscii_low + cRS; // end enable pulse (0xxx x001)
delay100u( ); // allow 100us to latch data inside LCD
}
void delay1u( )
{
unsigned int i;
for(i=0;i<=0x0f;i++)
{ /* adjust condition field for delay time */
asm("nop");
}
}
void delay100u( )
{
unsigned int i,j;
for(i=0;i<=0x02;i++)
{ /* adjust condition field for delay time */
for(j=0;j<=0xff;j++)
{
asm("nop");
}
}
}
void delay2m( )
{
unsigned int i,j;
for (i=0;i<=0x20;i++)
{ /* adjust condition field for delay time */
for (j=0;j<=0xff;j++)
{
asm("nop");
}
}
}
void delays(int k )
{
unsigned int i,j;
for (i=0;i<=k;i++)
{ /* adjust condition field for delay time */
for (j=0;j<=0xff;j++)
{
asm("nop");
}
}
} /********* end of file ***********************/
THEN add this set of code to it.
// 4x4 keypad driver (uses software polling)
// PORT A7 - PORT A4 input from keypad rows; PORT A3 – PORT A0 output to keypad
columns
// Activates one column at a time and read rows
// Identifies closed key and displays the results on the PORT T7 – PORT T4 LEDs
#include /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include
// globals
const unsigned char cCol[5] = // One dimension array for enables each Column
{
0x00, // All Columns logic High
0x01, // Only Column 1 logic High
0x02, // Only Column 2 logic High
0x04, // Only Column 3 logic High
0x08 // Only Column 4 logic High
}; // End of the row array
const unsigned char cResult[17] = // One dimension array for results of 0 thru F- Logic low turns
LED on
{
0xF0, // no key pressed or more than one key pressed – all LEDs off
0xE0, // Row 1, Col 1 key pressed – LED4 off LED3 off LED2 off LED1 on
0xD0, // Row 1, Col 2 key pressed – LED4 off LED3 off LED2 on LED1 off
0xC0, // Row 1, Col 3 key pressed – LED4 off LED3 off LED2 on LED1 on
0xB0, // Row 1, Col 4 key pressed – LED4 off LED3 on LED2 off LED1 off
0xA0, // Row 2, Col 1 key pressed – LED4 off LED3 on LED2 off LED1 on
0x90, // Row 2, Col 2 key pressed – LED4 off LED3 on LED2 on LED1 off
0x80, // Row 2, Col 3 key pressed – LED4 off LED3 on LED2 on LED1 on
0x70, // Row 2, Col 4 key pressed – LED4 on LED3 off LED2 off LED1 off
0x60, // Row 3, Col 1 key pressed – LED4 on LED3 off LED2 off LED1 on
0x50, // Row 3, Col 2 key pressed – LED4 on LED3 off LED2 on LED1 off
0x40, // Row 3, Col 3 key pressed – LED4 on LED3 off LED2 on LED1 on
0x30, // Row 3, Col 4 key pressed – LED4 on LED3 on LED2 off LED1 off
0x20, // Row 4, Col 1 key pressed – LED4 on LED3 on LED2 off LED1 on
0x10, // Row 4, Col 2 key pressed – LED4 on LED3 on LED2 on LED1 off
0x00, // Row 4, Col 3 key pressed – LED4 off LED3 on LED2 off LED1 on
0xF0, // Row 2, Col 1 key pressed – LED4 off LED3 off LED2 off LED1 off
}; // End of the row array
unsigned char cRow[5]; // One dimension array pointing to the active Row
unsigned char cValue; // Variable used in reading PORT A
unsigned int i, j, k, m, n; // Counter variables
/************main************/
void main(void)
{
DDRA = 0x0F; // Upper nibble Rows: input, Lower nibble Columns:
output
//PUCR = 0x01; // This command would eEnable Port A pull up resistors -
DDRT = 0xF0; // Upper nibble LEDs: output – logic low turns LED on
while(1) // Infinite while loop
{
for(i = 0; i < 5; i++)
{
cRow[i] = 0xF0; // Initialize all row results to open condition
}
// Key press detector loop
i = 0;
cValue = PORTA & 0xF0; // Read current value on upper nibble
PORTA = cValue | cCol[i]; // Output logic High to all columns
while ( cRow[i] == 0xF0 ) // Stay in loop until key pressed
{
cRow[i] = PORTA & 0xF0; // Use mask to focus on upper nibble
}
// Key press identification loop
for(i = 1; i < 5; i++)
{
cValue = PORTA & 0xF0; // Read current value on upper nibble
PORTA = cValue | cCol[i]; // Output logic High to Column i where “|” is or
operator
for (j = 0; j <= 200; j++) // Delay loop – allows time for the Column output to
reach keypad
{
asm("nop"); // No operation assembly instruction
}
cRow[i] = PORTA & 0xF0; // Read all row results for Column i
}
// Key press assignment loop
n = 0; // Set n value to 0 – used as the identifier for the Row
and Column
for(i = 1; i < 5; i++)
{
switch (cRow[i])
{
case 0x00: // No key pressed for Column i
n += 0;
break;
case 0x10: // Column i Row 1 key pressed
n += 0 + i;
break;
case 0x20: // Column i Row 2 key pressed
n += 4 + i;
break;
case 0x40: // Column i Row 3 key pressed
n += 8 + i;
break;
case 0x80: // Column i + 1 Row 4 key pressed
n += 12 + i;
break;
default: // more than one key pressed
n += 17;
break;
} // end of switch – case
} // end for loop
if (n >= 17) n = 0; // More than one key pressed
// Display result on LEDs
PTT = cResult[n];
m = 0;
// This routine is provided only because there are only 4 LEDs to display the results
for (i = 0; i <= 10; i++) // LED delay routine
{
for (j = 0; j <= 300; j++)
{
for (k = 0; k <= 255; k++)
{
asm (“nop”);
} // end of k count loop
} // end of j count loop
if (n == 16) // Row 4 Col 4 will be indicated by flashing all 4 LEDs
{
if (m == 0)
{
m++;
PTT = 0x00; // Row 4 Col 4 all 4 LEDs turned on
}
else
{
m = 0;
PTT = cResult[n]; // Row 4 Col 4 all 4 LEDs turned off
}
} // End of if (n == 16)
} // end of i count loop
} // end of Infinite while loop
} // end of main function
Solution
#include <hidef.h>
/* common macros defines in program */
#include "derivative.h"
/* derivative specific definitions in program */
//globals - 4-bit initialization sequence for LCD - data: PC7,6,5,4 E: PC2 R/W~: PC1 RS: PC0
in program
const unsigned char cInit_command[20] =
{0x30,0x30,0x30,0x20,0x20,0x90,0x10,0x50,0x70,0x80,0x50,0xE0,
0x60,0xA0,0x00,0xE0,0x00,0x10,0x00,0x60};
const unsigned char cMSG[3][17] =
{ {'j','e','C','r','c',' ','U','n','i','v','e','r','c','i','t','y'},
{' ',' ','e','n','g','i','n','e','e','r','i','n','g',' ',' },
{ ','t','e','c','h','n','o','l','o','g','i','e ',' s',' '}};//flash data in Program
const unsigned char cENG = 0x04;
const unsigned char cRAS = 0x01;
unsigned char cVAL;
int p;
//function prototypes in program
void initLCD(void);
void initPort(void);
void LCDput(char*);
void LCDputch(char);
void cmdwrot(unsigned char);
void datawrot(char);
void positions(int,int);
void delay1um(void);
void delay100um(void);
void delay2mu(void);
void delay(int);
//main function in program/
void main()
{
initPorts( );
// port initializations in program
initLCD( );
// LCD inititialization in program
cVAL = 'C';
// datawrot('6');
// demonstrates single character write in program
// positions(1,0);
// LCDput("
"); // blank row 1
// positions(2,0);
// LCDput("
"); // blank row 2 // position(3,0) in program;
// LCDput("
"); // blank row 3
for(;;)
{
for (p=0;p<3;p++)
{
positions(p+1,0);
LCDput(cMSG[p]); //passes message address in program
}
delays(20000);
//wait a long time in program
} /* forever loop in program */
}
/*********functions file*********/
void initPort( )
{
unsigned char cVAL;
DDRB = 0x80; //LCD CSB active low in program
DDRC = 0xFF; // PC7-PC4 - 4-bit LCD data bus, PC2 - E, PC1 - R/W~, PC0 - RS: all outputs
in program
cValue = PORTB;
PORTB = cValue | 0x00; // LCD CSB (PORT B7) enabled with a logic low in program
}
// sends initialization commands one-by-one in program
void initLCD( )
{
unsigned char i;
for (i=0;i<=19;i++)
{
cmdwrt(cInit_commands[i]);
}
}
// sends a control word to LCD bus in program
void cmdwrot(unsigned char cCtrlword)
{
PORTC = cCtrlword;
// output command onto LCD data pins in program
PORTC = cCtrlword + cE;
// generate enable pulse to latch it (xxxx x100)in program
delay1uM( );
// hold it for 1us in program
PORTC = cCtrlword;
// end enable pulse (xxxx x000)
delay2mU();
// allow 2ms to latch command inside LCD in program
PORTC = 0x00;
delay2mU();
// allow 2ms to latch command inside LCD in program
}
void position(int iRow_value, int iCol_value)
{
int iPos_h, iPos_l, iVAL;
if(iRow_value == 1) iVAL = (0x80+0x00);
if(iRow_value == 2) iVAL = (0x80+0x10);
if(iRow_value == 3) iVAL = (0x80+0x20); iPos_h=((iValue + iCol_value) & 0xF0);
iPos_l=((iVAL + iCol_value) & 0x0F) << 4;
cmdwrt(iPos_h);
cmdwrt(iPos_l);
}
//Sends a string of characters to the LCD;... in program
void LCDputs(char *sptr)
{
while(*sptr)
{ //...the string must end in a 0x00 (null character) in program
datawrt(*sptr); // sptr is a pointer to the characters in the string in program
++sptr;
}
}
//Sends a single character to the LCD in program;...
void LCDputchs(char cVAL)
{
datawrt(cVAL); // single character value in program
}
// sends the character passed in by caller to LCD in program
void datawrt(char cAscii)
{
char cAscii_high, cAscii_low;
cAscii_high = (cAscii & 0xF0);
cAscii_low = (cAscii & 0x0F) << 4; // Shift left by 4 bitsin program
PORTC = cAscii_high;
// output ASCII character upper nibble onto LCD data pins
PORTC = cAscii_high + cRAS + cENG; // generate enable pulse to latch it (0xxx x101) in
program
delay1u( );
// hold it for 1us
PORTC = cAscii_high + cRAS;
// end enable pulse (0xxx x001) in program
delay1u( );
// hold it for 1us
PORTC = cAscii_low;
// output ASCII character lower nibble onto LCD data pins
PORTC = cAscii_low + cRAS + cENG; // generate enable pulse to latch it (0xxx x101) in
program
delay1u( );
// hold it for 1us
PORTC = cAscii_low + cRAS;
// end enable pulse (0xxx x001) in program
delay100u( );
// allow 100us to latch data inside LCD
}
void delay1um( )
{
unsigned int i;
for(i=0;i<=0x0f;i++)
{ /* adjust condition field for delay time in program*/
asm("nop");
}
}
void delay100um( ) {
unsigned int i,j;
for(i=0;i<=0x02;i++)
{
/* adjust condition field for delay time in program*/
for(j=0;j<=0xff;j++)
{
asm("nop");
}
}
}
void delay2mu( )
{
unsigned int i,j;
for (i=0;i<=0x20;i++)
{ /* adjust condition field for delay time in program */
for (j=0;j<=0xff;j++)
{
asm("nop");
}
}
}
void delay(int k )
{
unsigned int i,j;
for (i=0;i<=k;i++)
{ /* adjust condition field for delay time in program*/
for (j=0;j<=0xff;j++)
{
asm("nop");
}
}
}
//end of main file /
//or second solution this question/
#include "Keypad.h"
#include
#include
LiquidCrystal lcds(12, 11, 5, 4, 3, 2);
const byte ROW = 4; //four rows
const byte COL= 4; //four columns
char keys[ROW][COL] =
{
{
'1','2','3','A' }
,
{
'4','5','6','B' }
,
{
'7','8','9','C' }
,
{
'*','0','#','D' }
};
byte rowPins[ROW] = {
5, 4, 3, 2}; //connect to the row pinouts of the keypad in program
byte colPins[COL] = {
9, 8, 7, 6}; //connect to the column pinouts of the keypad in program
Keypad keypads = Keypad( makeKeymap(keys), rowPins, colPins, ROW, COL );
char PIN[6]={
'1','2','A','D','5','6'}; // our secret (!) number in program
char attempt[6]={
'0','0','0','0','0','0'}; // used for comparison in program
int z=0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("PIN have Lock ");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN here...");
}
void correctPIN() // do this if correct PIN entered in program
{
lcd.print("* Correct PIN here *");
delay(1000);
lcd.clear();
lcd.print(" for Enter PIN ...");
}
void incorrectPIN() // do this if incorrect PIN entered
{
lcd.print(" * Try again ..... *");
delay(1000);
lcd.clear();
lcd.print(" Enter PIN here...");
}
void checkPIN()
{
int correct=0;
int i;
for ( i = 0; i < 6 ; i++ )
{
if (attempt[i]==PIN[i])
{
correct++;
}
}
if (correct==6)
{
correctsPIN();
}
else
{
incorrectsPIN();
}
for (int zz=0; zz<6; zz++)
{
attempts[zz]='0';
}
}
void readKeypad()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
attempt[z]=keys;
z++;
switch(keys)
{
case '*':
z=0;
break;
case '#':
z=0;
delay(100); // for extra debounce in program
lcd.clear();
checkPIN();
break;
}
}
}
void loops()
{
readKeypads();
}

More Related Content

Similar to Combine the keypad and LCD codes in compliance to the following requ.pdf

What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counterMafaz Ahmed
 
Gsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerGsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerYonas Andualem
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 CardOmar Sanchez
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Svet Ivantchev
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuenteBlackD10
 
Arduino and Robotics
Arduino and RoboticsArduino and Robotics
Arduino and RoboticsMebin P M
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACnanocdac
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docxajoy21
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IOT Academy
 

Similar to Combine the keypad and LCD codes in compliance to the following requ.pdf (20)

Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
Basic standard calculator
Basic standard calculatorBasic standard calculator
Basic standard calculator
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counter
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Gsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerGsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontroller
 
Direct analog
Direct analogDirect analog
Direct analog
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
Hex keypad
Hex keypadHex keypad
Hex keypad
 
Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
 
REPORT
REPORTREPORT
REPORT
 
Arduino and Robotics
Arduino and RoboticsArduino and Robotics
Arduino and Robotics
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
knowledge in daily life.ppt
knowledge in daily life.pptknowledge in daily life.ppt
knowledge in daily life.ppt
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
The IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programmingThe IoT Academy IoT Training Arduino Part 3 programming
The IoT Academy IoT Training Arduino Part 3 programming
 

More from forwardcom41

Hello!Can someone help me to answer Task4 and Task7Complete T.pdf
Hello!Can someone help me to answer Task4 and Task7Complete T.pdfHello!Can someone help me to answer Task4 and Task7Complete T.pdf
Hello!Can someone help me to answer Task4 and Task7Complete T.pdfforwardcom41
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfforwardcom41
 
Given technology today, would it be more feasible than in the pa.pdf
Given technology today, would it be more feasible than in the pa.pdfGiven technology today, would it be more feasible than in the pa.pdf
Given technology today, would it be more feasible than in the pa.pdfforwardcom41
 
Explain the difference between a contaminated culture and a mix c.pdf
Explain the difference between a contaminated culture and a mix c.pdfExplain the difference between a contaminated culture and a mix c.pdf
Explain the difference between a contaminated culture and a mix c.pdfforwardcom41
 
Explain in detail how OFDM helps mitigates multipath fading effects..pdf
Explain in detail how OFDM helps mitigates multipath fading effects..pdfExplain in detail how OFDM helps mitigates multipath fading effects..pdf
Explain in detail how OFDM helps mitigates multipath fading effects..pdfforwardcom41
 
Complete a scientific inquiry research using three credible sources..pdf
Complete a scientific inquiry research using three credible sources..pdfComplete a scientific inquiry research using three credible sources..pdf
Complete a scientific inquiry research using three credible sources..pdfforwardcom41
 
Describe and illustrate the use of a bank reconciliation in controll.pdf
Describe and illustrate the use of a bank reconciliation in controll.pdfDescribe and illustrate the use of a bank reconciliation in controll.pdf
Describe and illustrate the use of a bank reconciliation in controll.pdfforwardcom41
 
Why is it important for a trainer (trainers) to understand the commu.pdf
Why is it important for a trainer (trainers) to understand the commu.pdfWhy is it important for a trainer (trainers) to understand the commu.pdf
Why is it important for a trainer (trainers) to understand the commu.pdfforwardcom41
 
What are the various portals an enterprise can use What is the func.pdf
What are the various portals an enterprise can use What is the func.pdfWhat are the various portals an enterprise can use What is the func.pdf
What are the various portals an enterprise can use What is the func.pdfforwardcom41
 
What is the nature of thermal energy What is heat at the atomic lev.pdf
What is the nature of thermal energy What is heat at the atomic lev.pdfWhat is the nature of thermal energy What is heat at the atomic lev.pdf
What is the nature of thermal energy What is heat at the atomic lev.pdfforwardcom41
 
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdf
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdfw Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdf
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdfforwardcom41
 
Which of the following is not one of the ethical standards included .pdf
Which of the following is not one of the ethical standards included .pdfWhich of the following is not one of the ethical standards included .pdf
Which of the following is not one of the ethical standards included .pdfforwardcom41
 
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdf
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdfUsing the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdf
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdfforwardcom41
 
why we need mixed methodology for researchSolutionMixed metho.pdf
why we need mixed methodology for researchSolutionMixed metho.pdfwhy we need mixed methodology for researchSolutionMixed metho.pdf
why we need mixed methodology for researchSolutionMixed metho.pdfforwardcom41
 
What property doesnt apply to fluids Newtons second, cons of ene.pdf
What property doesnt apply to fluids Newtons second, cons of ene.pdfWhat property doesnt apply to fluids Newtons second, cons of ene.pdf
What property doesnt apply to fluids Newtons second, cons of ene.pdfforwardcom41
 
What is the threat to culture by a read-only world, and how do t.pdf
What is the threat to culture by a read-only world, and how do t.pdfWhat is the threat to culture by a read-only world, and how do t.pdf
What is the threat to culture by a read-only world, and how do t.pdfforwardcom41
 
What is one hypothesis to explain why there are more endemic bird sp.pdf
What is one hypothesis to explain why there are more endemic bird sp.pdfWhat is one hypothesis to explain why there are more endemic bird sp.pdf
What is one hypothesis to explain why there are more endemic bird sp.pdfforwardcom41
 
What are the ethical tensions in advertisingWho are the responsib.pdf
What are the ethical tensions in advertisingWho are the responsib.pdfWhat are the ethical tensions in advertisingWho are the responsib.pdf
What are the ethical tensions in advertisingWho are the responsib.pdfforwardcom41
 
Use the following information to answer the next Question. The graph.pdf
Use the following information to answer the next Question.  The graph.pdfUse the following information to answer the next Question.  The graph.pdf
Use the following information to answer the next Question. The graph.pdfforwardcom41
 
These are the answer I got but are not fully correct and ineffic.pdf
These are the answer I got but are not fully correct and ineffic.pdfThese are the answer I got but are not fully correct and ineffic.pdf
These are the answer I got but are not fully correct and ineffic.pdfforwardcom41
 

More from forwardcom41 (20)

Hello!Can someone help me to answer Task4 and Task7Complete T.pdf
Hello!Can someone help me to answer Task4 and Task7Complete T.pdfHello!Can someone help me to answer Task4 and Task7Complete T.pdf
Hello!Can someone help me to answer Task4 and Task7Complete T.pdf
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
 
Given technology today, would it be more feasible than in the pa.pdf
Given technology today, would it be more feasible than in the pa.pdfGiven technology today, would it be more feasible than in the pa.pdf
Given technology today, would it be more feasible than in the pa.pdf
 
Explain the difference between a contaminated culture and a mix c.pdf
Explain the difference between a contaminated culture and a mix c.pdfExplain the difference between a contaminated culture and a mix c.pdf
Explain the difference between a contaminated culture and a mix c.pdf
 
Explain in detail how OFDM helps mitigates multipath fading effects..pdf
Explain in detail how OFDM helps mitigates multipath fading effects..pdfExplain in detail how OFDM helps mitigates multipath fading effects..pdf
Explain in detail how OFDM helps mitigates multipath fading effects..pdf
 
Complete a scientific inquiry research using three credible sources..pdf
Complete a scientific inquiry research using three credible sources..pdfComplete a scientific inquiry research using three credible sources..pdf
Complete a scientific inquiry research using three credible sources..pdf
 
Describe and illustrate the use of a bank reconciliation in controll.pdf
Describe and illustrate the use of a bank reconciliation in controll.pdfDescribe and illustrate the use of a bank reconciliation in controll.pdf
Describe and illustrate the use of a bank reconciliation in controll.pdf
 
Why is it important for a trainer (trainers) to understand the commu.pdf
Why is it important for a trainer (trainers) to understand the commu.pdfWhy is it important for a trainer (trainers) to understand the commu.pdf
Why is it important for a trainer (trainers) to understand the commu.pdf
 
What are the various portals an enterprise can use What is the func.pdf
What are the various portals an enterprise can use What is the func.pdfWhat are the various portals an enterprise can use What is the func.pdf
What are the various portals an enterprise can use What is the func.pdf
 
What is the nature of thermal energy What is heat at the atomic lev.pdf
What is the nature of thermal energy What is heat at the atomic lev.pdfWhat is the nature of thermal energy What is heat at the atomic lev.pdf
What is the nature of thermal energy What is heat at the atomic lev.pdf
 
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdf
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdfw Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdf
w Hstory Bookmarks Window Help Apple Bing Google Taho0 NewaDetals MIN.pdf
 
Which of the following is not one of the ethical standards included .pdf
Which of the following is not one of the ethical standards included .pdfWhich of the following is not one of the ethical standards included .pdf
Which of the following is not one of the ethical standards included .pdf
 
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdf
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdfUsing the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdf
Using the guidance from ASC 855-10-55-1 and 855-10-55-2 Answer the f.pdf
 
why we need mixed methodology for researchSolutionMixed metho.pdf
why we need mixed methodology for researchSolutionMixed metho.pdfwhy we need mixed methodology for researchSolutionMixed metho.pdf
why we need mixed methodology for researchSolutionMixed metho.pdf
 
What property doesnt apply to fluids Newtons second, cons of ene.pdf
What property doesnt apply to fluids Newtons second, cons of ene.pdfWhat property doesnt apply to fluids Newtons second, cons of ene.pdf
What property doesnt apply to fluids Newtons second, cons of ene.pdf
 
What is the threat to culture by a read-only world, and how do t.pdf
What is the threat to culture by a read-only world, and how do t.pdfWhat is the threat to culture by a read-only world, and how do t.pdf
What is the threat to culture by a read-only world, and how do t.pdf
 
What is one hypothesis to explain why there are more endemic bird sp.pdf
What is one hypothesis to explain why there are more endemic bird sp.pdfWhat is one hypothesis to explain why there are more endemic bird sp.pdf
What is one hypothesis to explain why there are more endemic bird sp.pdf
 
What are the ethical tensions in advertisingWho are the responsib.pdf
What are the ethical tensions in advertisingWho are the responsib.pdfWhat are the ethical tensions in advertisingWho are the responsib.pdf
What are the ethical tensions in advertisingWho are the responsib.pdf
 
Use the following information to answer the next Question. The graph.pdf
Use the following information to answer the next Question.  The graph.pdfUse the following information to answer the next Question.  The graph.pdf
Use the following information to answer the next Question. The graph.pdf
 
These are the answer I got but are not fully correct and ineffic.pdf
These are the answer I got but are not fully correct and ineffic.pdfThese are the answer I got but are not fully correct and ineffic.pdf
These are the answer I got but are not fully correct and ineffic.pdf
 

Recently uploaded

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

Combine the keypad and LCD codes in compliance to the following requ.pdf

  • 1. Combine the keypad and LCD codes in compliance to the following requirements: your last name to appear on LCD row 1, your last name to appear on row 2, and on row 3 ‘Key pressed:’ with ‘ ‘,0,1,2,A,3,4,5,6,B,7,8,9,C,*,0,#,D in row 3 column 14. // Displaying messages on the 3 x 16 LCD // PORT C7 - PORT C4 output (LCD data bus); PORT C2 – PORT C0 output (LCD control signals) // PORTB7 output (LCD Chip Select Bit – active Low) // Includes LCD initialization routine #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ //globals - 4-bit initialization sequence for LCD - data: PC7,6,5,4 E: PC2 R/W~: PC1 RS: PC0 const unsigned char cInit_commands[20] = {0x30,0x30,0x30,0x20,0x20,0x90,0x10,0x50,0x70,0x80,0x50,0xE0, 0x60,0xA0,0x00,0xE0,0x00,0x10,0x00,0x60}; const unsigned char cMessage[3][17] = { {'D','a','v','e''}, {' ',' ','s','m','i','t','h' '}, {' ',' ',' ','T'';}};//data in Program Flash const unsigned char cE = 0x04; const unsigned char cRS = 0x01; unsigned char cValues; int p; //function prototypes void initLCD(void); void initPorts(void); void LCDputs(char*); void LCDputch(char); void cmdwrt(unsigned char); void datawrt(char); void position(int,int); void delay1u(void); void delay100u(void); void delay2m(void); void delays(int); /************main************/
  • 2. void main() { initPorts( ); // port initializations initLCD( ); // LCD inititialization cValues = 'C'; // datawrt('6'); // demonstrates single character write // position(1,0); // LCDputs(" "); // blank row 1 // position(2,0); // LCDputs(" "); // blank row 2 // position(3,0); // LCDputs(" "); // blank row 3 for(;;) { for (p=0;p<3;p++) { position(p+1,0); LCDputs(cMessage[p]); //passes message address } delays(20000); //wait a long time } /* forever loop */ } /*********functions*********/ void initPorts( ) { unsigned char cValue; DDRB = 0x80; //LCD CSB active low DDRC = 0xFF; // PC7-PC4 - 4-bit LCD data bus, PC2 - E, PC1 - R/W~, PC0 - RS: all outputs cValue = PORTB; PORTB = cValue | 0x00; // LCD CSB (PORT B7) enabled with a logic low } // sends initialization commands one-by-one void initLCD( ) { unsigned char i;
  • 3. for (i=0;i<=19;i++) { cmdwrt(cInit_commands[i]); } } // sends a control word to LCD bus void cmdwrt(unsigned char cCtrlword) { PORTC = cCtrlword; // output command onto LCD data pins PORTC = cCtrlword + cE; // generate enable pulse to latch it (xxxx x100) delay1u( ); // hold it for 1us PORTC = cCtrlword; // end enable pulse (xxxx x000) delay2m(); // allow 2ms to latch command inside LCD PORTC = 0x00; delay2m(); // allow 2ms to latch command inside LCD } void position(int iRow_value, int iCol_value) { int iPos_h, iPos_l, iValue; if(iRow_value == 1) iValue = (0x80+0x00); if(iRow_value == 2) iValue = (0x80+0x10); if(iRow_value == 3) iValue = (0x80+0x20); iPos_h=((iValue + iCol_value) & 0xF0); iPos_l=((iValue + iCol_value) & 0x0F) << 4; cmdwrt(iPos_h); cmdwrt(iPos_l); } //Sends a string of characters to the LCD;... void LCDputs(char *sptr) { while(*sptr) { //...the string must end in a 0x00 (null character) datawrt(*sptr); // sptr is a pointer to the characters in the string ++sptr; } }
  • 4. //Sends a single character to the LCD;... void LCDputch(char cValues) { datawrt(cValues); // single character value } // sends the character passed in by caller to LCD void datawrt(char cAscii) { char cAscii_high, cAscii_low; cAscii_high = (cAscii & 0xF0); cAscii_low = (cAscii & 0x0F) << 4; // Shift left by 4 bits PORTC = cAscii_high; // output ASCII character upper nibble onto LCD data pins PORTC = cAscii_high + cRS + cE; // generate enable pulse to latch it (0xxx x101) delay1u( ); // hold it for 1us PORTC = cAscii_high + cRS; // end enable pulse (0xxx x001) delay1u( ); // hold it for 1us PORTC = cAscii_low; // output ASCII character lower nibble onto LCD data pins PORTC = cAscii_low + cRS + cE; // generate enable pulse to latch it (0xxx x101) delay1u( ); // hold it for 1us PORTC = cAscii_low + cRS; // end enable pulse (0xxx x001) delay100u( ); // allow 100us to latch data inside LCD } void delay1u( ) { unsigned int i; for(i=0;i<=0x0f;i++) { /* adjust condition field for delay time */ asm("nop"); } } void delay100u( ) { unsigned int i,j; for(i=0;i<=0x02;i++)
  • 5. { /* adjust condition field for delay time */ for(j=0;j<=0xff;j++) { asm("nop"); } } } void delay2m( ) { unsigned int i,j; for (i=0;i<=0x20;i++) { /* adjust condition field for delay time */ for (j=0;j<=0xff;j++) { asm("nop"); } } } void delays(int k ) { unsigned int i,j; for (i=0;i<=k;i++) { /* adjust condition field for delay time */ for (j=0;j<=0xff;j++) { asm("nop"); } } } /********* end of file ***********************/ THEN add this set of code to it. // 4x4 keypad driver (uses software polling) // PORT A7 - PORT A4 input from keypad rows; PORT A3 – PORT A0 output to keypad columns // Activates one column at a time and read rows // Identifies closed key and displays the results on the PORT T7 – PORT T4 LEDs
  • 6. #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ #include // globals const unsigned char cCol[5] = // One dimension array for enables each Column { 0x00, // All Columns logic High 0x01, // Only Column 1 logic High 0x02, // Only Column 2 logic High 0x04, // Only Column 3 logic High 0x08 // Only Column 4 logic High }; // End of the row array const unsigned char cResult[17] = // One dimension array for results of 0 thru F- Logic low turns LED on { 0xF0, // no key pressed or more than one key pressed – all LEDs off 0xE0, // Row 1, Col 1 key pressed – LED4 off LED3 off LED2 off LED1 on 0xD0, // Row 1, Col 2 key pressed – LED4 off LED3 off LED2 on LED1 off 0xC0, // Row 1, Col 3 key pressed – LED4 off LED3 off LED2 on LED1 on 0xB0, // Row 1, Col 4 key pressed – LED4 off LED3 on LED2 off LED1 off 0xA0, // Row 2, Col 1 key pressed – LED4 off LED3 on LED2 off LED1 on 0x90, // Row 2, Col 2 key pressed – LED4 off LED3 on LED2 on LED1 off 0x80, // Row 2, Col 3 key pressed – LED4 off LED3 on LED2 on LED1 on 0x70, // Row 2, Col 4 key pressed – LED4 on LED3 off LED2 off LED1 off 0x60, // Row 3, Col 1 key pressed – LED4 on LED3 off LED2 off LED1 on 0x50, // Row 3, Col 2 key pressed – LED4 on LED3 off LED2 on LED1 off 0x40, // Row 3, Col 3 key pressed – LED4 on LED3 off LED2 on LED1 on 0x30, // Row 3, Col 4 key pressed – LED4 on LED3 on LED2 off LED1 off 0x20, // Row 4, Col 1 key pressed – LED4 on LED3 on LED2 off LED1 on 0x10, // Row 4, Col 2 key pressed – LED4 on LED3 on LED2 on LED1 off 0x00, // Row 4, Col 3 key pressed – LED4 off LED3 on LED2 off LED1 on 0xF0, // Row 2, Col 1 key pressed – LED4 off LED3 off LED2 off LED1 off }; // End of the row array unsigned char cRow[5]; // One dimension array pointing to the active Row unsigned char cValue; // Variable used in reading PORT A
  • 7. unsigned int i, j, k, m, n; // Counter variables /************main************/ void main(void) { DDRA = 0x0F; // Upper nibble Rows: input, Lower nibble Columns: output //PUCR = 0x01; // This command would eEnable Port A pull up resistors - DDRT = 0xF0; // Upper nibble LEDs: output – logic low turns LED on while(1) // Infinite while loop { for(i = 0; i < 5; i++) { cRow[i] = 0xF0; // Initialize all row results to open condition } // Key press detector loop i = 0; cValue = PORTA & 0xF0; // Read current value on upper nibble PORTA = cValue | cCol[i]; // Output logic High to all columns while ( cRow[i] == 0xF0 ) // Stay in loop until key pressed { cRow[i] = PORTA & 0xF0; // Use mask to focus on upper nibble } // Key press identification loop for(i = 1; i < 5; i++) { cValue = PORTA & 0xF0; // Read current value on upper nibble PORTA = cValue | cCol[i]; // Output logic High to Column i where “|” is or operator for (j = 0; j <= 200; j++) // Delay loop – allows time for the Column output to reach keypad { asm("nop"); // No operation assembly instruction } cRow[i] = PORTA & 0xF0; // Read all row results for Column i }
  • 8. // Key press assignment loop n = 0; // Set n value to 0 – used as the identifier for the Row and Column for(i = 1; i < 5; i++) { switch (cRow[i]) { case 0x00: // No key pressed for Column i n += 0; break; case 0x10: // Column i Row 1 key pressed n += 0 + i; break; case 0x20: // Column i Row 2 key pressed n += 4 + i; break; case 0x40: // Column i Row 3 key pressed n += 8 + i; break; case 0x80: // Column i + 1 Row 4 key pressed n += 12 + i; break; default: // more than one key pressed n += 17; break; } // end of switch – case } // end for loop if (n >= 17) n = 0; // More than one key pressed // Display result on LEDs PTT = cResult[n]; m = 0; // This routine is provided only because there are only 4 LEDs to display the results for (i = 0; i <= 10; i++) // LED delay routine { for (j = 0; j <= 300; j++) {
  • 9. for (k = 0; k <= 255; k++) { asm (“nop”); } // end of k count loop } // end of j count loop if (n == 16) // Row 4 Col 4 will be indicated by flashing all 4 LEDs { if (m == 0) { m++; PTT = 0x00; // Row 4 Col 4 all 4 LEDs turned on } else { m = 0; PTT = cResult[n]; // Row 4 Col 4 all 4 LEDs turned off } } // End of if (n == 16) } // end of i count loop } // end of Infinite while loop } // end of main function Solution #include <hidef.h> /* common macros defines in program */ #include "derivative.h" /* derivative specific definitions in program */ //globals - 4-bit initialization sequence for LCD - data: PC7,6,5,4 E: PC2 R/W~: PC1 RS: PC0 in program const unsigned char cInit_command[20] = {0x30,0x30,0x30,0x20,0x20,0x90,0x10,0x50,0x70,0x80,0x50,0xE0, 0x60,0xA0,0x00,0xE0,0x00,0x10,0x00,0x60}; const unsigned char cMSG[3][17] = { {'j','e','C','r','c',' ','U','n','i','v','e','r','c','i','t','y'}, {' ',' ','e','n','g','i','n','e','e','r','i','n','g',' ',' },
  • 10. { ','t','e','c','h','n','o','l','o','g','i','e ',' s',' '}};//flash data in Program const unsigned char cENG = 0x04; const unsigned char cRAS = 0x01; unsigned char cVAL; int p; //function prototypes in program void initLCD(void); void initPort(void); void LCDput(char*); void LCDputch(char); void cmdwrot(unsigned char); void datawrot(char); void positions(int,int); void delay1um(void); void delay100um(void); void delay2mu(void); void delay(int); //main function in program/ void main() { initPorts( ); // port initializations in program initLCD( ); // LCD inititialization in program cVAL = 'C'; // datawrot('6'); // demonstrates single character write in program // positions(1,0); // LCDput(" "); // blank row 1 // positions(2,0); // LCDput(" "); // blank row 2 // position(3,0) in program; // LCDput(" "); // blank row 3 for(;;)
  • 11. { for (p=0;p<3;p++) { positions(p+1,0); LCDput(cMSG[p]); //passes message address in program } delays(20000); //wait a long time in program } /* forever loop in program */ } /*********functions file*********/ void initPort( ) { unsigned char cVAL; DDRB = 0x80; //LCD CSB active low in program DDRC = 0xFF; // PC7-PC4 - 4-bit LCD data bus, PC2 - E, PC1 - R/W~, PC0 - RS: all outputs in program cValue = PORTB; PORTB = cValue | 0x00; // LCD CSB (PORT B7) enabled with a logic low in program } // sends initialization commands one-by-one in program void initLCD( ) { unsigned char i; for (i=0;i<=19;i++) { cmdwrt(cInit_commands[i]); } } // sends a control word to LCD bus in program void cmdwrot(unsigned char cCtrlword) { PORTC = cCtrlword; // output command onto LCD data pins in program PORTC = cCtrlword + cE; // generate enable pulse to latch it (xxxx x100)in program
  • 12. delay1uM( ); // hold it for 1us in program PORTC = cCtrlword; // end enable pulse (xxxx x000) delay2mU(); // allow 2ms to latch command inside LCD in program PORTC = 0x00; delay2mU(); // allow 2ms to latch command inside LCD in program } void position(int iRow_value, int iCol_value) { int iPos_h, iPos_l, iVAL; if(iRow_value == 1) iVAL = (0x80+0x00); if(iRow_value == 2) iVAL = (0x80+0x10); if(iRow_value == 3) iVAL = (0x80+0x20); iPos_h=((iValue + iCol_value) & 0xF0); iPos_l=((iVAL + iCol_value) & 0x0F) << 4; cmdwrt(iPos_h); cmdwrt(iPos_l); } //Sends a string of characters to the LCD;... in program void LCDputs(char *sptr) { while(*sptr) { //...the string must end in a 0x00 (null character) in program datawrt(*sptr); // sptr is a pointer to the characters in the string in program ++sptr; } } //Sends a single character to the LCD in program;... void LCDputchs(char cVAL) { datawrt(cVAL); // single character value in program } // sends the character passed in by caller to LCD in program void datawrt(char cAscii)
  • 13. { char cAscii_high, cAscii_low; cAscii_high = (cAscii & 0xF0); cAscii_low = (cAscii & 0x0F) << 4; // Shift left by 4 bitsin program PORTC = cAscii_high; // output ASCII character upper nibble onto LCD data pins PORTC = cAscii_high + cRAS + cENG; // generate enable pulse to latch it (0xxx x101) in program delay1u( ); // hold it for 1us PORTC = cAscii_high + cRAS; // end enable pulse (0xxx x001) in program delay1u( ); // hold it for 1us PORTC = cAscii_low; // output ASCII character lower nibble onto LCD data pins PORTC = cAscii_low + cRAS + cENG; // generate enable pulse to latch it (0xxx x101) in program delay1u( ); // hold it for 1us PORTC = cAscii_low + cRAS; // end enable pulse (0xxx x001) in program delay100u( ); // allow 100us to latch data inside LCD } void delay1um( ) { unsigned int i; for(i=0;i<=0x0f;i++) { /* adjust condition field for delay time in program*/ asm("nop"); } } void delay100um( ) { unsigned int i,j; for(i=0;i<=0x02;i++)
  • 14. { /* adjust condition field for delay time in program*/ for(j=0;j<=0xff;j++) { asm("nop"); } } } void delay2mu( ) { unsigned int i,j; for (i=0;i<=0x20;i++) { /* adjust condition field for delay time in program */ for (j=0;j<=0xff;j++) { asm("nop"); } } } void delay(int k ) { unsigned int i,j; for (i=0;i<=k;i++) { /* adjust condition field for delay time in program*/ for (j=0;j<=0xff;j++) { asm("nop"); } } } //end of main file / //or second solution this question/ #include "Keypad.h" #include #include
  • 15. LiquidCrystal lcds(12, 11, 5, 4, 3, 2); const byte ROW = 4; //four rows const byte COL= 4; //four columns char keys[ROW][COL] = { { '1','2','3','A' } , { '4','5','6','B' } , { '7','8','9','C' } , { '*','0','#','D' } }; byte rowPins[ROW] = { 5, 4, 3, 2}; //connect to the row pinouts of the keypad in program byte colPins[COL] = { 9, 8, 7, 6}; //connect to the column pinouts of the keypad in program Keypad keypads = Keypad( makeKeymap(keys), rowPins, colPins, ROW, COL ); char PIN[6]={ '1','2','A','D','5','6'}; // our secret (!) number in program char attempt[6]={ '0','0','0','0','0','0'}; // used for comparison in program int z=0; void setup() { Serial.begin(9600); lcd.begin(16, 2); lcd.print("PIN have Lock ");
  • 16. delay(1000); lcd.clear(); lcd.print(" Enter PIN here..."); } void correctPIN() // do this if correct PIN entered in program { lcd.print("* Correct PIN here *"); delay(1000); lcd.clear(); lcd.print(" for Enter PIN ..."); } void incorrectPIN() // do this if incorrect PIN entered { lcd.print(" * Try again ..... *"); delay(1000); lcd.clear(); lcd.print(" Enter PIN here..."); } void checkPIN() { int correct=0; int i; for ( i = 0; i < 6 ; i++ ) { if (attempt[i]==PIN[i]) { correct++; } } if (correct==6) { correctsPIN();
  • 17. } else { incorrectsPIN(); } for (int zz=0; zz<6; zz++) { attempts[zz]='0'; } } void readKeypad() { char key = keypad.getKey(); if (key != NO_KEY) { attempt[z]=keys; z++; switch(keys) { case '*': z=0; break; case '#': z=0; delay(100); // for extra debounce in program lcd.clear(); checkPIN(); break; } } } void loops() {