### Author Topic: Measure Voltage  (Read 2506 times)

0 Members and 1 Guest are viewing this topic.

#### 123eric

• Beginner
• Posts: 5
##### Measure Voltage
« on: May 19, 2007, 02:10:45 PM »
I am trying to measure the voltage on a pin on my pic16f870 but am having some problems in doing so, and cant find what I am lookin for online. I have a variable resistor hooked up to a voltage divider so that I can vary the voltage from 0 to 2.5v. This is hooked up to pin RC3 on the microcontroller. So far this is what I have for my picbasic code.

loop:
peek 7, b0
let bit3=b1

if b1<50 then a
if b1<100 then b
if b1<150 then C
if b1<200 then d
if b1<255 then E
goto loop.

A b c d e will make lights blink at a different speed depending on the voltage. But they are not doing this.

Thanks for any help.

• Supreme Robot
• Posts: 11,658
##### Re: Measure Voltage
« Reply #1 on: May 20, 2007, 01:38:23 PM »
Try simplifying your code so that you can narrow down where the problem is.

Do something very simple, like:

if b1<50 then LED off
if b1>49 then LED on

This way you know its not your blinking speed code that isnt wrong.

Its also good to check it with a multimeter to make sure your wiring isnt wrong.

I am not familiar with picbasic code, but is this line correct?
let bit3=b1

at least in C, that line should be written as:
let b1=bit3

hope that helps . . .

#### JonHylands

• Expert Roboticist
• Supreme Robot
• Posts: 562