lpc1768 buton kontrol

Başlatan berkay_91, 08 Mart 2016, 09:44:22

berkay_91

programı yükledikten sonra sadece led yanıyor butona bassamda basmasamda ışık sönmüyor... kodlarda sorun mu var?

#include "lpc17xx.h"
#include "type.h"
#define SwitchPinNumber 3
#define LedPinNumber    1
int main()
{
    uint32_t switchStatus;
    SystemInit();                    //Clock and PLL configuration
   
    LPC_PINCON->PINSEL2 = 0x000000; //Configure the Pins for GPIO;
    LPC_PINCON->PINSEL0 = 0x000000; //Configure the Pins for GPIO;
    LPC_GPIO2->FIODIR |= (1<<LedPinNumber); // Configure the LED pin as output 
    LPC_GPIO0->FIODIR |=(0<<SwitchPinNumber); // SwitchPin as input
    LPC_GPIO2->FIOCLR = 0x000000FF; /* turn off all the LEDs */
 
  while(1)
    {
     /* Turn On all the leds and wait for one second */
       switchStatus = (LPC_GPIO0->FIOPIN>>SwitchPinNumber) & 0x01// Read the switch status
       
       if(switchStatus == 1)                        //Turn ON/OFF LEDs depending on switch status
       { 
         LPC_GPIO2->FIOPIN = (1<<LedPinNumber);
       }
       else
       {
            LPC_GPIO2->FIOPIN = (0<<LedPinNumber);
       }     
    }
}