Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
Dim AnalogData as word 'where you store the analog dataTrisA = %00001000 'Set PortA 3 for inputTrisB = %00000000 'Set all of PortB to Outputwhile TRUE 'start of the main loopAnalogData=Adc_Read(3) 'coverts analog data into digital, and stores in AnalogData variableIf AnalogData = 0 Then '0v Checks to see if it is 0v.PortB = %00000000 'All lights offEnd IfIf AnalogData > 918 Then '~5vPortB = %11111111 'All lights onAnalogData = 0 'Sets variable to 0, so the lights don't changeEnd IfIf AnalogData > 816 Then '~4.5vPortB = %11111110 'All light on, except PortB 0AnalogData = 0End IfIf AnalogData > 714 Then '~4vPortB = %11111100 'All lights except PortB 0 & 1AnalogData = 0End IfIf AnalogData > 612 Then '~3.5vPortB = %11111000AnalogData = 0End IfIf AnalogData > 510 Then '~3vPortB = %11110000AnalogData = 0End IfIf AnalogData > 408 Then '~2.5vPortB = %11100000AnalogData = 0End IfIf AnalogData > 306 Then '~2vPortB = %11000000AnalogData = 0End IfIf AnalogData > 204 Then '~1.5vPortB = %10000000AnalogData = 0End IfIf AnalogData > 95 Then '~1PortB = %00000000AnalogData = 0End IfIf AnalogData > 0 Then 'Makes sure we don't turn off all the lights at the endIf AnalogData < 95 Then 'Less then 1 VPortB = %00000000AnalogData = 0End IfEnd Ifwend 'While End (goes back to the top, and starts over)