PDA

View Full Version : reading the value of a pot



studysession
- 1st February 2009, 02:00
Hi -

I am still plugging away trying to learn more PICBasic Pro. Figure I have couple of the Parallax Basic Stamp books. So I am trying to do those same labs but using the PIC16F84A instead of the BS2 and PICBasic Pro as the language instead of the Parallax Basic language.

One of the labs from "What's a Microcontroller?" is to read the value of a potentiomemter. So I made the exact same schematic from the Basic Stamp book but using my PIC16F84A. (Attached is an image showing my electronics.)

Than I used the following source code. Problem is the only value that ever gets stored in the variable "time" is the state I specify on the command line. Could anyone point me in the correct direction to properly reading the value of a pot with PICBasic Pro?

Thanks -



include "MODEDEFS.BAS"

lcd1 var porta.0
potport var portb.0
time var word

main

HIGH potport
pause 10
rctime potport, 1, time
serout lcd1, t9600, [$fe,1," time = ", #time]

goto main

aratti
- 1st February 2009, 09:45
include "MODEDEFS.BAS"

lcd1 var porta.0
potport var portb.0
time var word

main

LOW potport
pause 10
rctime potport, 0, time
serout lcd1, t9600, [$fe,1," time = ", #time]

goto main

Port should be low not high.

Al.