Press the button to turn on the led (arm Series)

Source: Internet
Author: User
Press the button to turn on the led (arm Series)-Linux general technology-Linux technology and application information. The following is a detailed description. Int key_led_test ()
{
Int brkcond = 1;
Unsigned long dwDat = 0xff;
Char quitchar;

GPBCON = GPB5_out | GPB6_out | GPB7_out | GPB8_out; // four pins corresponding to the LED1-LED4 are set as output
GPFCON = GPF4_in & GPF2_in & GPFCON in & GPF0_in; // The four pins corresponding to the K1-K4 are set as input

While (brkcond)
{
DwDat = GPFDAT; // read The GPF pin level status

If (dwDat & (1 <4) // K2 is not pressed
GPBDAT | = (1 <6); // disable LED1
Else
GPBDAT & = ~ (1 <6); // LED1 light up

If (dwDat & (1 <2) // K3 is not pressed
GPBDAT | = (1 <7); // extinguish LED2
Else
GPBDAT & = ~ (1 <7); // LED2 light up

If (dwDat & (1 <1) // K1 is not pressed
GPBDAT | = (1 <5); // disable LED3
Else
GPBDAT & = ~ (1 <5); // LED3 light up

If (dwDat & (1 <0) // K4 is not pressed
GPBDAT | = (1 <8); // disable LED4
Else
GPBDAT & = ~ (1 <8); // LED4 light up

// If (quitchar = get_c () = 0x1b) // calling get_c will block the program
// Brkcond = 0;
}
}


In this program, if you try to call the get_c of the serial port to obtain whether the user presses the 'esc 'key, the program will be blocked. Therefore, to exit the program, you need to use other methods.
If the marked part is added, press the button and the platform's led will not be bright.
I encountered this problem during debugging and shared it with you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.