Single chip microcomputer STM32L151CCU6
1206RGB (single)
The button scan result and the actual button pressed follow a specific relationship. Here are some examples of how the scan results map to the buttons:
// K100XE7K180XB7
// K110XEBK190XBB
// K120XEDK200XBD
// K130XEEK210XBE
// K140XD7K220X77
// K150XDBK230X7B
// K160XDDK240X7D
// K170XDEK250X7E
#include // Includes internal resources of the microcontroller
__CONFIG(0x1832); // Configuration word: watchdog off, power-on delay on, power-down detection off, low-voltage programming off, encryption, 4M crystal HS oscillator
int result; // Variable to store the scan result
void delay(); // Declaration of delay function
void init(); // Declaration of I/O port initialization function
void scan(); // Declaration of key scanning function
void display(int x); // Declaration of display function
//---------------------------------------------------
// Main program
void main() {
while(1) { // Infinite loop
init(); // Call initialization function
scan(); // Call button scan function
display(result); // Call display function with the result
}
}
//---------------------------------------------------
// Initialization function
void init() {
ADCON1 = 0x07; // Set A port as general I/O
TRISA = 0x0F; // Set upper 2 bits of A port as output, lower 4 bits as input
TRISC = 0xF0; // Set upper 4 bits of C port as input, lower 4 bits as output
TRISD = 0x00; // Set D port as output
PORTA = 0xFF;
PORTD = 0xFF; // Clear all displays first
}
//---------------------------------------------------
// Button scan program
void scan() {
PORTC = 0xF7; // Set C3 to low, others high
asm("nop"); // Delay for stability
result = PORTC; // Read back the value from PORTC
result &= 0xF0; // Clear lower 4 bits
if (result != 0xF0) { // If not all 1s, a key is pressed
result |= 0x07; // Add lower 4 bits to identify the key
} else { // Otherwise, check next row
PORTC = 0xFB; // Set C2 to low
asm("nop");
result = PORTC;
result &= 0xF0;
if (result != 0xF0) {
result |= 0x0B;
} else {
PORTC = 0xFD; // Set C1 to low
asm("nop");
result = PORTC;
result &= 0xF0;
if (result != 0xF0) {
result |= 0x0D;
} else {
PORTC = 0xFE; // Set C0 to low
asm("nop");
result = PORTC;
result &= 0xF0;
if (result != 0xF0) {
result |= 0x0E;
} else {
result = 0xFF; // No key pressed
}
}
}
}
}
//---------------------------------------------------
// Display program
void display(int x) {
switch(result) {
case 0xE7: // K10
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0xC0; PORTA = 0x1F; delay(); break;
case 0xEB: // K11
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0xF9; PORTA = 0x1F; delay(); break;
case 0xED: // K12
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0xA4; PORTA = 0x1F; delay(); break;
case 0xEE: // K13
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0xB0; PORTA = 0x1F; delay(); break;
case 0xD7: // K14
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0x99; PORTA = 0x1F; delay(); break;
case 0xDB: // K15
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0x92; PORTA = 0x1F; delay(); break;
case 0xDD: // K16
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0x82; PORTA = 0x1F; delay(); break;
case 0xDE: // K17
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0xF8; PORTA = 0x1F; delay(); break;
case 0xB7: // K18
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0x80; PORTA = 0x1F; delay(); break;
case 0xBB: // K19
PORTD = 0xF9; PORTA = 0x2F; delay();
PORTD = 0x90; PORTA = 0x1F; delay(); break;
case 0xBD: // K20
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0xC0; PORTA = 0x1F; delay(); break;
case 0xBE: // K21
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0xF9; PORTA = 0x1F; delay(); break;
case 0x77: // K22
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0xA4; PORTA = 0x1F; delay(); break;
case 0x7B: // K23
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0xB0; PORTA = 0x1F; delay(); break;
case 0x7D: // K24
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0x99; PORTA = 0x1F; delay(); break;
case 0x7E: // K25
PORTD = 0xA4; PORTA = 0x2F; delay();
PORTD = 0x92; PORTA = 0x1F; delay(); break;
case 0xFF: // No button pressed
PORTD = 0x8E; PORTA = 0x2F; delay();
PORTD = 0x8E; PORTA = 0x1F; delay(); break;
}
}
//---------------------------------------------------
// Delay function
void delay() {
int i; // Define a variable for counting
for(i = 0x100; i--;); // Simple delay loop
}
LED DJ Booth Display
Portable DJ Booth Display is the irregular display with seamless splicing, which can actualize music and video synchronously. Video DJ Booth Display realizes high brightness, large viewing angle, high resolution and high contrast ratio.
Priva LED DJ Booth Screens are biased towards users with special needs. Currently, they are mainly used in entertainment venues, outdoor media, exhibition halls and other environments.
Characteristics
1. Light weight , high heat dissipation, low power consumption
2. Compatible multi-source input such as DVD ,DVI, VGI
3. Type of weather conditions:snow & wind loading , humidity, lightning protection
LED DJ Booth Display, Portable DJ Booth, VAV LED DJ Booth Display, Diamond DJ Booth Display
Shenzhen Priva Tech Co., Ltd. , https://www.privaled.com