Hi,
New here and very new to pic basic. I used to know (in another life) how to program in Basic and it was pretty straight forward. I am now involved in a micrprocessor-controlled animatronics and I am completely dumbfounded by PIC Basic.
I have the PIC Basic code needed for the servos but when I try to compile it, I get errors galore on things that, to me, look correct. I thought it might be the word processor screwing it up but I get the same thing even in text format. Here is the first part of the code:
b8 = 50 'b8 for servo sweep
start:
GOSUB sweep
GOSUB RAN
FOR B5 = 1 TO B4 ' 200 IS TIME BETWEEN SERVO POSITIONS
PULSOUT 0,B1 'SERVO ON RB0
PULSOUT 1,150 'tilt servo rb1
PULSOUT 2,100 'center up down
PAUSE 18 'NEED THIS IN HERE
NEXT B5
GOSUB sweep
PAUSE 1500
So I get syntax error for:
for b5 = 1 to b4
also for:
pulsout 0, B1
But no tthe next line, only a Bad Expression error.
Then back to syntax for the fourth line on and for the 3rd line after that.
I know I am missing something very basic (pun intended).
This code is apparently proven as good, so ........
I can't see all your code. What is b4? a variable? What is its value?
From the manual: "dog VAR BYTE" will make a variable with the name dog and it is 8 bits in size. (bit, word, and long might not work)
b5=1 to 7 works, b5=1 to 0 night not work. If your variable is 0 or 1 you might have trouble.
[quote]pulsout 0, B1[/quote]
Same thing. what value for B1? Is it bit/word/long?
INCLUDE "modedefs.bas"
OSCCON =$60 'clock speed
DEFINE OSC 4
b8 VAR BYTE
start:
GOSUB sweep
GOSUB RAN
FOR B5 = 1 TO B4 ' 200 IS TIME BETWEEN SERVO POSITIONS
PULSOUT 0,B1 'SERVO ON RB0
PULSOUT 1,150 'tilt servo rb1
PULSOUT 2,100 'center up down
PAUSE 18 'NEED THIS IN HERE
NEXT B5
GOSUB sweep
PAUSE 1500