|
Re: Trouble programming Digital I/O toggle switches in C++
if you arent sure that the program is reading the toggle switch then i suggest:
printf("toggleswitch = %f \n",Switch1);
now if you go into the console it should give you a read out of the toggle switch if the program is actually recognizing it (while the code is running).
the code up above is assuming that you defined the switch as a float, which it looks like you should have because if you're reading a voltage it's on an analog input. if im wrong and for some reason the switch needs to be an int, change that %f to a %d. for the record, the structure for print statements goes:
printf("whateveryouwanttocallyourvariable = %f \n", variablename);
as i said before, %f changes to %d if the variable you're printing is an int rather than a float, bools also fall under %d
|