Hello
I am trying to assign a function to each S2 and S3 push buttons. ( port 3.5 & 3.6 ) I want to get a display that the button S2 is pressed when it is pressed. But i always get the message " S2 not Pressed". any ideas??
I did the following ( just the important things). These come inside the void main (void).
unsigned short Read_value2; //******************************* // Buttons 5 and 6 on Port 3 //******************************* SCU_APBPeriphClockConfig(__GPIO3,ENABLE); SCU_APBPeriphReset(__GPIO3,DISABLE); GPIO_StructInit(&GPIO_InitStruct); GPIO_InitStruct.GPIO_Pin= GPIO_Pin_5 | GPIO_Pin_6; GPIO_InitStruct.GPIO_Direction=GPIO_PinInput; GPIO_InitStruct.GPIO_Type=GPIO_Type_PushPull; GPIO_InitStruct.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable; GPIO_Init(GPIO3,&GPIO_InitStruct); Read_value2= GPIO_Read(GPIO3); if ((Read_value2 && 0x20) == 0x00)// checking whether the push button is pressed { lcd_clear(); lcd_print (" S2 Pressed "); } else { lcd_clear(); lcd_print (" S2 Not pressed "); }
Also known as Finite State Machines (FSM), or Finite State Automata (Note that "Automata" is the plural of "Automaton")
Try these terms in your favourite internet search engine...