Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I would like to know how to implement a simple passcode to my C program for the

ID: 3770251 • Letter: I

Question


I would like to know how to implement a simple passcode to my C program for the pic microcontroller let's say a combination of three keys when thay are pressed with a certain order something happens otherwise nothing happens "no need for details" Thanks Info: I'm using PIC16F877A on BK300+ board and MPLAB XC8 compiler
I would like to know how to implement a simple passcode to my C program for the pic microcontroller let's say a combination of three keys when thay are pressed with a certain order something happens otherwise nothing happens "no need for details" Thanks Info: I'm using PIC16F877A on BK300+ board and MPLAB XC8 compiler
I would like to know how to implement a simple passcode to my C program for the pic microcontroller let's say a combination of three keys when thay are pressed with a certain order something happens otherwise nothing happens "no need for details" Thanks Info: I'm using PIC16F877A on BK300+ board and MPLAB XC8 compiler
I would like to know how to implement a simple passcode to my C program for the pic microcontroller let's say a combination of three keys when thay are pressed with a certain order something happens otherwise nothing happens "no need for details" Thanks Info: I'm using PIC16F877A on BK300+ board and MPLAB XC8 compiler
I would like to know how to implement a simple passcode to my C program for the pic microcontroller let's say a combination of three keys when thay are pressed with a certain order something happens otherwise nothing happens "no need for details" Thanks Info:

Explanation / Answer

program example_16 ' Program name
dim kp, curX, curY as byte
dim keypadPORT as byte at PORTD ' This variable must be defined in all projects using Keypad Lib.
                                ' It define the port used for keypad connection

dim LCD_RS as sbit at RB4_bit   ' Lcd module connections
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit ' End Lcd module connections

main:               ' Start of program
curX=1              ' For keeping a record of the 2x16 LCD cursor position
curY=1
ANSEL = 0           ' Configure analog pins as digital I/O
ANSELH = 0
TRISB = 0
PORTB = 0xFF
Keypad_Init()       ' Initialize keypad on PORTC
Lcd_Init()          ' Initialize LCD on PORTB,
Lcd_Cmd(_LCD_CLEAR) ' Clear display

while true          ' Wait for some key to be pressed and released
kp = 0
while kp = 0
    kp = Keypad_Key_Click()
    Delay_ms(10)
wend

select case kp     ' Prepare value for output
    case 1 kp = "1"
    case 2 kp = "2"
    case 3 kp = "3"
    case 4 kp = "A"
    case 5 kp = "4"
    case 6 kp = "5"
    case 7 kp = "6"
    case 8 kp = "B"
    case 9 kp = "7"
    case 10 kp = "8"
    case 11 kp = "9"
    case 12 kp = "C"
    case 13 kp = "*"
    case 14 kp = "0"
    case 15 kp = "#"
    case 16 kp = "D"
end select

if (curY > 16) then ' Change cursor position
    if (curX = 1) then
      Lcd_Cmd(_LCD_SECOND_ROW)
      curX = 2
      curY = 1
    else
      Lcd_Cmd(_LCD_FIRST_ROW)
      curX = 1
      curY = 1
    end if
end if

Lcd_Chr_CP(kp) ' Display on LCD
Inc(curY)
wend

end. ' End of program