Why won´t this program work?
Hoffa
Posts: 46
I can´t understand why this program won´t work. The problem is that I can´t use the function setangle. Center, Left, and Right works fine, but if I assamble the program as written here nothing happens. I think that something happens when the lines·· "angle := 0 #> angle <# 180" or·"v := (MAXLEFT*90-(angle*PER90DEGREES))/90" are running, but I can´t find anything wrong with these lines.
Please help me.
<code>
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
··· servoPin = 11
··· MAXRIGHT =····· 520
··· MAXLEFT· =···· 2450
··· CENTERPULS = (MAXLEFT + MAXRIGHT)/2
··· PER90DEGREES=·· (CENTERPULS-MAXRIGHT)
······
OBJ
· servo : "Servo32"
PUB start | i
· dira[noparse][[/noparse]servoPin]~~
· SERVO.Start
· setangle(90)·····
PUB setangle (angle) | v
· angle := 0 #> angle <# 180
· v := (MAXLEFT*90-(angle*PER90DEGREES))/90
· turn(v)
PUB turn (pulses)
· SERVO.Set(servoPin, pulses)
PUB center
· turn(CENTERPULS)
PUB left
· turn(MAXLEFT)
pub right
· turn(MAXRIGHT)·
</code>·
Please help me.
<code>
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
··· servoPin = 11
··· MAXRIGHT =····· 520
··· MAXLEFT· =···· 2450
··· CENTERPULS = (MAXLEFT + MAXRIGHT)/2
··· PER90DEGREES=·· (CENTERPULS-MAXRIGHT)
······
OBJ
· servo : "Servo32"
PUB start | i
· dira[noparse][[/noparse]servoPin]~~
· SERVO.Start
· setangle(90)·····
PUB setangle (angle) | v
· angle := 0 #> angle <# 180
· v := (MAXLEFT*90-(angle*PER90DEGREES))/90
· turn(v)
PUB turn (pulses)
· SERVO.Set(servoPin, pulses)
PUB center
· turn(CENTERPULS)
PUB left
· turn(MAXLEFT)
pub right
· turn(MAXRIGHT)·
</code>·
Comments
You have to use square brackets ([noparse][[/noparse] ]) around your message tags rather than corner brackets (<>).