Mct Q&a

1283 words 6 pages
(G) On Keypad & Sensor :
1. How many I/O interface pins between keypad (4x4) and PIC18f4520?
- Keypad (4x4) has 8 I/O interface pins.
- In this example schematic that has RB0 to R07 connected to the 8 I/O pins on to the Keypad (4x4)

- PIC18f4520 has 36 I/O pins that grouped into 5 ports
- It should require 8 pins to connect a 4x4 keypad.

2. How to detect if a key is depressed?
E.g. Of flowchart when things are input.
E.g. Of flowchart when things are input.
End

End

Wait for Key Release
Wait for Key Release
Swap I/O back to original setup
Swap I/O back to original setup
Combine ‘R’ and ‘T’ and put into global variable
Combine ‘R’ and ‘T’ and put into global variable
Read another input (Keypad) and put into
…show more content…

- Fed the signal directly into the 13 Analog channels [AN0 to AN4 share same pins as RA0 – RA3 & RA5] [AN5, AN6& AN7 share same pins as RE0, RE1 &RE2] [AN8 – AN12 share same pins RB0 – RB4] [PORTs A, B&E can also be used for analog inputs.]
3- Configuring ports for digital I/O
Discovery: Steps
1) identify the port to be used.
2) If Port A, B or E is used, configure them as digital I/O pins by->Setting ADCON1: 0b0000111;
3) Configure the direction of each I/O pin -> using TRISx (E.g. Port A use TRISA input=1 out=0.
4- Teaching the microcontroller if an I/O pin is to be used for input or output. Discovery:
Read Only Memory (ROM) can be used to save the program permanently to be executed from future.
Random Access Memory (RAM) can be used for temporary storing data and intermediate results created and used during the operation of the microcontrollers.
5- Structure of a C program
Discovery:
1) Documentation
-Comment lines; naming the program.
2) Pre-process Statements
-# symbol is pre-processor directive.
3) Global Declarations main ()
{
in sum=0; float y;
}
main ()
{
in sum=0; float y;
}
-Variables are declared before main () function as known as Global variables.
4) The main () function
-Only one main.
5) Braces
-Opening { } closing.
6) Local Declarations
- all variables are used in main () function should be declared in

Related