0% found this document useful (0 votes)
28 views

Code of A Programming

The code displays "TEAM 5" on an LCD screen when a button is pressed. It uses a counter variable to track the number of button presses. When the counter reaches 1, it displays "TEAM 5". When the counter reaches 2, it clears the display and resets the counter back to 0. This prevents the text from redisplaying if the button is pressed multiple times rapidly due to debouncing.

Uploaded by

Elle Lawliet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Code of A Programming

The code displays "TEAM 5" on an LCD screen when a button is pressed. It uses a counter variable to track the number of button presses. When the counter reaches 1, it displays "TEAM 5". When the counter reaches 2, it clears the display and resets the counter back to 0. This prevents the text from redisplaying if the button is pressed multiple times rapidly due to debouncing.

Uploaded by

Elle Lawliet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include "project.

h"
int counter = 0;

int main(void)

{
CyGlobalIntEnable; /* Enable global interrupts. */

LCD_Char_Start();
LCD_Char_Enable();

LCD_Char_ClearDisplay();

for(;;)
{
if(SW_Read() == 1)
{
CyDelay(500);
counter++;
}

if(counter == 1)
{
LCD_Char_Position(0u, 3u);
LCD_Char_PrintString("TEAM 5");
}

else if (counter == 2)
{
counter = 0;
LCD_Char_ClearDisplay();
}

}
}

/* [] END OF FILE */
CONCLUSION

The button of an electronic device usually works as an electrical switch, that is to

say inside it has two contacts, when one is pressed, the inverse function of the one

that is currently being performed will be activated, if it is an NA device (normally

open) will be closed, if it is an NC device (normally closed) it will be opened.

Push buttons or switches, there are tons of them in your home. A switch is a simple

device with two positions, ON and AP (On and Off).

That we can highlight in the procedure that is followed to perform the code that

prevents rebounds. If we look closely at the behavior of the program,

it was necessary to implement a “cydelay” to avoid that rebound that the

mechanical switch present in these cases when touching the plates this was the

delay that was put to the program was so that the program can avoid rebounding

this makes it through reading of the state the “deley“ gives the program time to

know exactly the status of the button

You might also like