Dry goods! 8051 single-chip reverse scanning keyboard

The keyboard scan uses the reverse method to read the key: firstly output the zero level from the high 4 bits of the P2 port, and read the keyboard state from the low 4 bits of the P2 port; then output the zero level from the low 4 bits of the P2 port, from the P2 port The upper 4 bits read the keyboard state and combine the results of the two readings to get the signature of the current key (see the TABLE table in the program). With this table you can program and convert them into sequential code. Use the currently read signatures to sequentially look up the table and use a unit to record the number of lookups. When the signature is found in the table, its location (ie, the number of lookups) is the corresponding order code. The corresponding keyboard check program is as follows:

Dry goods! 8051 single-chip reverse scanning keyboard

KEY: MOV P2, #0FH ; Use reverse method key

MOV A, P2

ANL A, #0FH

MOV B, A

MOV P2, #0F0H

MOV A, P2

ANL A, #0F0H

ORL A, B

CJNE A, #0FFH, KEY1

RET; no key press

KEY1: MOV B, A; There is a key press, save key code

MOV DPTR, #TABLE

MOV R3, #0FFH; Stored Sequence Code Unit Initialization

KEY2: INC R3

MOV A, R3

MOVC A, @A+DPTR

CJNE A, B, KEY3; Judge key code, find order code

MOV A, R3 ; If a key code is found, save the code

RET

KEY3: CJNE A, #0FFH, KEY2;

RET; Checked, key not found, no key processing

TABLE: DB 77H, 7BH, 0BBH ; Key signature table

DB 0DBH,7DH,0BDH

DB 0DDH,7EH,0BEH

DB 0DEH, 0B7H, 0D7H

DB 0EEH,0EDH,0EBH

DB 0E7H, 0C7H, 0FFH

Written in C language

#include

#include

#include

#include

#include

#includeCC.h

#define uchar unsigned char

#define uint unsigned int

keysCAN()

{

Uchar i,h=0xfe;

For(i=4,P1=h;i"0;i--) //scan

{

If((P1&0xf0)!=0xf0) // Is there a key press?

{

Uchar a;

For(a=255;a"0;a--) //Delay

{}

If((P1&0xf0)!=0xf0) //There is a key press

{

Uchar key,p;

p=P1;

For(key=0;key<<16;key++) //check table

{

Uchar code keytab[]={0xEE,0xDE,0xBE,0x7E, //keycode table

0xED, 0xDD, 0xBD, 0x7D,

0xEB, 0xDB, 0xBB, 0x7B,

0xE7, 0xD7, 0xB7, 0x77};

If(p==keytab[key]) // check return key number

{

P1=0xff;

Return(key);

}

}

}

}

h=_crol_(h,1);

P1=h;

}

P1=0xff;

Return(16); // didn't find return 16

}

Main()

{while(1)

{P0=keyscan();

While(1)

;

}

}

Disposable Vape Pen

Tobacco control has been a common global concern, while the traditional tobacco industry gradually, new tobacco has become the new strategic layout of tobacco giants. In this context, the emergence of e-cigarettes has further led to the replacement of traditional tobacco. At present, there are already a thousand different types of e-cigarettes, which have undergone several stages of development. The e-cigarette we are introducing today is the CBD pod systewm, a new type of e-cigarette. In this article we will combine the characteristics of the CBD with a brief analysis of it.


·Anti-anxiety

According to scientific studies,CBD can help depressed patients reduce their anxiety. The use of CBD can help maintain endogenous cannabinoids at a reasonable level, making the patient feel good and happy physically, and without any dependence.

·Anti-ageing

CBD is very powerful in anti-ageing. As a non-psychoactive component of the cannabis plant CBD inhibits the glutamate toxic response of cortical neurons and suppresses excessive oxidative stress, helping the body to achieve anti-ageing effects.

·Anti-inflammatory

CBD reduces the free radicals that cause neurodegenerative diseases and reduces swelling through its anti-inflammatory effects. In addition, CBD stimulates appetite and relieves pain.

China Disposble Vape Pen,E-Cigarette Cbd Vaporizer,Best Disposable Cbd Vape Pen,Disposable Cbd Vape

Shenzhen MASON VAP Technology Co., Ltd. , https://www.disposablevapepenfactory.com