View Single Post
  #6   Spotlight this post!  
Unread 02-04-2009, 22:43
reversed_rocker's Avatar
reversed_rocker reversed_rocker is offline
Alumni
AKA: Ken Condon
FRC #0706 (Cyberhawks)
Team Role: College Student
 
Join Date: Nov 2008
Rookie Year: 2008
Location: Hartland
Posts: 69
reversed_rocker is on a distinguished road
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
Reply With Quote