Download presentation
1
Asst. Prof. Dr. Alper SISMAN
Practice Asst. Prof. Dr. Alper SISMAN
2
Keypad/7-Segment Display
Matrix Keypad GND output keypad Serial output keypad Dipswitches 7-Segment Display Ex. Circuit (HW details resistors etc.)
3
7-Segment display Write all decimal numbers on the 7-segment.
Design a simple counter (0-9) that counts the seconds.
4
Alphanumeric LCD Display
5
Frequently used LCD commands
6
LCD Init.
7
Use LCD in 4-bit mode #include "STM32F4xx.h" #define RS 32;
#define EN 8; #define databits GPIOD->ODR void SystemInit(){ (*((int*)0xE000ED88))|=0x0F00000; // Floating Point donanimini aktiflestir. RCC->AHB1ENR |= 0x F; // GPIOD->MODER = 0x ; GPIOD->OTYPER = 0x F; //GPIOD->PUPDR = 0x ; GPIOD->OSPEEDR= 0xFFFFFFFF GPIOB->MODER = 0x ; GPIOB->OTYPER = 0x ; //GPIOB->PUPDR = 0x ; GPIOB->OSPEEDR= 0xFFFFFFFF; }
8
void cmd(unsigned char c)
{ GPIOB->BSRRH = RS; delayyus(50); GPIOD->ODR = (c >> 4); LCD_STROBE(); databits = (c); } void delayyus(int delay0) { delay0-delay0*4; while (delay0--) {} } void LCD_STROBE(void) { GPIOB->BSRRL = EN; delayyus(1); //1us bekle GPIOB->BSRRH = EN; } void clear(void) { cmd(0x01); delayyus(2000); } void data (unsigned char c) { GPIOB->BSRRL = RS; delayyus(50); //50us bekle databits = (c >> 4); LCD_STROBE(); databits = (c); LCD_STROBE();} void string1(const char *q) { while(*q) data(*q++); }}
9
void lcd_init() { delayy1s(60000); cmd(0x38); delayy1s(4000); delayy1s(400); cmd(0x28); cmd(0x0c); clear(); cmd(0x6); } int main (){ delayyus(50000); lcd_init(); while(1) { cmd(0x80); string1("HELLO WORLD"); cmd(0xc0); string1("IT IS WORKING"); }
10
Matrix Keypad
11
Homework Write a C code that gets the pushed button if the matrix keypad is used in previous slide. The ASCII code of the pushed button should be written on a seven-segment display. Design the HW and Firmware
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.