11 years, 4 months ago.

printing out the status of a pushbutton

I have a pushbutton. 10K pullup to 3.3V. Pushing the button grounds it. at the top I have DigitalIn SpareSwitch(P0_20); in main I have isp.printf("Switch = %d\r\n",SpareSwitch);

but it always prints 27972 if I push the button or not. I'm assuming digital in does not print as a %d, how do I do it correctly?

1 Answer

11 years, 4 months ago.

Please try following program;

int button_status;
button_status = SpareSwitch;
isp.printf("Switch = %d\r\n",button_status);

Accepted Answer