The old output section of the code looked like this:
nocolor: serout 0,N2400,("nocolor",13,10) high 4,5 goto main red: serout 0,N2400,("red",13,10) low 4 high 5 goto main blue: serout 0,N2400,("blue",13,10) high 4 low 5 goto main green: serout 0,N2400,("green",13,10) low 4,5 goto mainI modified it to look like this:
RED: pwmout 2, 99, 0 ; Set the Ouput to 0V goto main GREEN: pwmout 2, 99, 125 ' Set the Output to 1.5 V goto main BLUE: pwmout 2, 99, 250 ' Set the Outut to 3 V goto main NONE: pwmout 2,99,400 ' Set the Output to 5V goto mainThe vex brain's sensor ports don't recognize PWM inputs directly, but by adding a capacitor on the PWM signal line, we can change the signal into a (mostly) continuous voltage which the brain can interpret as analog signal. The duty cycle of the PWM signal determines voltage. My next step was to put it all on perfboard so it's nice and compact. After doing this, I'm done! I now have a sensor for our vex robot!
No comments:
Post a Comment