// Program button.c
//
#include <wiringPi.h>
#include <stdio.h>
// One side of the button is placed on GPIO 0
// The other side is on 5V
#define BtnPin 0
int
main(
){
wiringPiSetup();
pinMode(BtnPin,INPUT);
for(;;)
{
if(0==digitalRead(BtnPin))
{
printf("\nButton is NOT Pressed\n");
}
if(1==digitalRead(BtnPin))
{
printf("\nButton is Pressed\n");
}
}
return(0);
}

No comments:
Post a Comment