KEYPAD WITH 7 SEGMENT USING CLOUDX MICROCONTROLLER
by DwealthJossy in Circuits > Microcontrollers
1035 Views, 3 Favorites, 0 Comments
KEYPAD WITH 7 SEGMENT USING CLOUDX MICROCONTROLLER
For this project, we will accept numeric input from a Matrix Keypad and then display it on a seven-segment display Module. Since the 8 LEDs are labeled A to G and DP (for the decimal point), if you want to display the number 6, then you would apply current to segments A, C,D,E F and G. Therefore 6 equals 0b01111101(DP,G,F,E,D,C,B,A) in binary and 0x7D in Hexadecimal.
MATERIALS
- CLOUDX MICROCONTROLLER
- CLOUDX SOFTCARD
- 7 SEGMENT
- JUMPER WIRE
- V3 CORD
- 4x3 KEYPARD
- 330 ohm
- 10K resistor
YOU CAN ORDER YOUR COMPONENT HERE
SET-UP YOUR HARDWARE
Follow this step:
connect the:
Pin A of the segment to pin1 of the CloudX
Pin B of the segment to pin2 of the CloudX
Pin DP of the segment to pin3 of the CloudX
Pin C of the segment to pin4 of the CloudX
Pin D of the segment to pin5 of the CloudX
Pin E of the segment to pin6 of the CloudX
Pin F of the segment to pin7 of the CloudX
Pin G of the segment to pin9 of the CloudX
connect the common cathode pin to GND
The pinA of the keypad row pin was connected to 10k resistor and to pin12 of the microcontroller.
The pinB of the keypad row pin was connected to 10k resistor and to pin13 of the microcontroller.
The pinC of the keypad row pin was connected to 10k resistor and to pin14 of the microcontroller.
The pinD of the keypad row pin was connected to 10k resistor and to pin15 of the microcontroller.
And the end of the resistor was connected together to GND.
The pin1 of the keypad Row pin was connected to pin10 of the microcontroller.
The pin2 of the keypad Row pin was connected to pin11 of the microcontroller.
The pin3 of the keypad Row pin was connected to pin12 of the microcontroller.
CODING
Copy this code to your CloudX IDE.
#include <CloudX\M633.h>
#include <CloudX\Keypad.h> #include <CloudX\Segment.h> #define NumberOfRows 4 #define NumberOfColumns 3 char KeypadCharacters[NumberOfRows][NumberOfColumns] = { '1','2','3', '4','5','6', '7','8','9', '*','0','#' }; //layout of the Keypad’s Keys char RowPins[NumberOfRows] = {12, 13, 14, 15}; char ColumnsPins[NumberOfColumns] = {9, 10, 11}; char Keys; //Instead of creating ten separate char variables, we create an array to group them unsigned char seg[] = {0x3F,0x06,0x5B,0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F}; setup(){ //setup here Keypad_setting (PULLDOWNROW, RowPins, ColumnsPins, NumberOfRows, NumberOfColumns, KeypadCharacters); // initialize Keypad with these data //Segment_setting(CCathode,NumberOfDigit,segmentScanPins,segmentDataPins); portMode(1,OUTPUT); // setup digital I/O port 1 as OUTPUT portWrite(1, OFF_ALL); // clear/turn off port 1 loop(){ //Program here
Keys = getKey(); // check for Key Press on Keypad if(Keys!=0) portWrite(1, seg[Keys - 48]); // write Key Pressed on 7-segment
} }
SHARE WITH US
Share with us your Achievement here