programming issue, readadc and pin not working together.

BotB

Member
Hi, I'm always here to ask for help (cause I can't give advice) :p...

I'm sure there are posts relevent to this already online here but I'm not sure what to search to find them...

OK I'm building a program to controll serveral servos in an animatronic head I've made (Oooo fancy), now I know how to controll the servos via POTs and switches but I'm having an issue brining them together.

here's my code so far:

symbol jaw = 0
symbol right_cheek = 1
symbol left_cheek = 2
symbol right_eyebrow = 3
symbol left_eyebrow = 4
symbol left_eye_up_down = 5
symbol eyes_left_right = 6
symbol right_eye_up_down = 7
symbol analogport1 = 0
symbol analogport2 = 1
symbol analogport3 = 2
symbol analogport4 = 3
symbol analogport5 = 4
symbol analogvalue1 = w1
symbol analogvalue2 = w2
symbol analogvalue3 = w3
symbol analogvalue4 = w4
symbol analogvalue5 = w5

pause 1000

servo jaw,150
servo right_cheek,150
servo left_cheek,150
servo right_eyebrow,150
servo left_eyebrow,150
servo left_eye_up_down,150
servo right_eye_up_down,150

pause 1000

start:

if pin0 = 0 then servo left_eyebrow,150 Endif pin0 = 1
if pin0 = 0 then servo right_eyebrow,150 Endif pin0 = 1
if pin1 = 0 then servo left_cheek,150 Endif pin1 = 1
if pin1 = 0 then servo right_cheek,150 Endif pin0 = 1
if pin0 = 1 then servo left_eyebrow,75 Endif pin0 = 0
if pin0 = 1 then servo right_eyebrow,220 Endif pin0 = 0
if pin1 = 1 then servo left_cheek,80 Endif pin1 = 0
if pin1 = 1 then servo right_cheek,220 Endif pin0 = 0

readadc analogport1, analogvalue1
analogvalue1 = analogvalue1 *10/17+75
servopos left_eye_up_down, analogvalue1

readadc analogport1, analogvalue2
analogvalue2=170-analogvalue2
analogvalue2=analogvalue2 *10/17+75
servopos right_eye_up_down, analogvalue2

pause 1000

goto start


OK I've been having issues getting the readadc and pin commands to work together, they work fine if one set is deleted but when they are kept like the above code then the pin command works but not the readadc...

I doubt anybody can shine a bit of light on this for me? I've not done much programming at all (that may well show) so I'm learning as I go along.

Many thanks yet again and if you have any questions then please feel free to ask them and I'll get right back to you.
 

BotB

Member
OK I've figured te problem out, I knew it shouldn't have been a programming issue, I believe the POT I was using on the analogport was faulty, I switched ports and it all seems better now...

I was told to use 10k POTs for the analogports but should I use a resistor too? unless POTs have a tendency to break then I think there's somethins wrong as this is the second POT in 2 weeks.
 

BeanieBots

Moderator
POTs do wear out but only after a lot of rotations and/or vibration.
If a pot is wired wrong across a supply, then it will BURN OUT when the wiper is moved to one extreme. Maybe you have accidentally swapped the wiper and one of the ends around.
 

Dippy

Moderator
A) Are you sure the pots are 10K? (have you checked with multimeter???)
B) Did you get them from some anonymous Ebay supplier? i.e. are they cheap'n'Nasty?
C) post your current/latest schematic as the Forum Crystal Ball isn't back from repair shop.
(C/W values and component types).
D) Whether or not pots are used depends on your app, and the 'range' you wish to measure.
E) Are you happy to calculate voltages and stuff when there is a combo of pots and res??
 
Top