while (1) { if (button) { while (button) { //when button is depressed, start timer timer++; if (timer == 250) { var = 1; } //if sufficient time has passed, the button press is valid } } if (var) { if (!button) { //when button is released, count the press (if valid) and reset the valid indicator pushcount++; var = 0; } }}//----------------------------------------------------------------------------// C main line//----------------------------------------------------------------------------#include < m8c.h > // part specific constants and macros#include "PSoCAPI.h" // PSoC API definitions for all User Modulesvoid main(){ int count = 0; int timer = 0; int var = 0; int pushcount = 0;// char theStr[] = "Alex Rov"; LED_1_Start(); LED_1_Switch(1); // Turn on LED LCD_2_Start(); // Initialize LCD LCD_2_Position(0,5); // Place LCD cursor at row 0, col 5. while(1) { // if (count == 6) {// LED_1_Invert(); // Flash LED at regular interval// }// count++; LCD_2_PrHexInt(pushcount); // Print pushcount on the LCD } while (1) { if (var == 1) { if ((SW1_Data_ADDR & SW1_MASK)==1) { //when button is released, count the press (if valid) and reset the valid indicator ++pushcount; var = 0; } if ((SW1_Data_ADDR & SW1_MASK)==0) { while ((SW1_Data_ADDR & SW1_MASK)==0) { //when button is depressed, start timer timer++; if (timer == 2) { var = 1; } //if sufficient time has passed, the button press is valid } } } }}