AnsweredAssumed Answered

Reading from GPIO PC0 ?

Question asked by H.Rick on Dec 30, 2013
Latest reply on Jan 4, 2014 by Trevor
Guys,

How can I read a button from GPIO PC0 ?
I have created :

      RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOA, ENABLE);
//initialize PC0 and PC1 as button input    
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; // this sets up input to be used with external push up/pull down resistors.
  GPIO_Init(GPIOC, &GPIO_InitStructure);
.
..
..
..

uint8_t button1;
     button1 = GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_0);

         if (button1 == 0x00)
          {
             lcd_string("Button 1 is pressed..");
          }

any opinions ?
thanks

Outcomes