script problem please help for ir buggy

chucky315

New Member
hey
im a student doing systems in year 12 and im having a problem with the script for my project. im doing a ir buggy and my script works on a 14 m chip but not a 14m2 could you please take a look at my script and see how i can fix this problem.

chuck:infrain2
if infra = 1 then gostraight
if infra = 6 then beeps
if infra = 7 then gobackwards
if infra = 4 then turnoff

goto chuck


beeps:
'exam cam tune'
tune B.0, 25, ($50)

pause 1500

tune B.0, 25, ($50)

pause 1500

tune B.0, 25, ($50)

pause 1500

tune B.0, 25, ($50)

pause 1500

tune B.0, 25, ($50)

goto chuck

gostraight:
let pins =%010000
pause 1000
let pins =%000110
goto chuck

gobackwards:
let pins =%010000
pause 1000
let pins =%101000
goto chuck

turnoff:
let pins =%010000
pause 1000
let pins =%000000
goto chuck



thanks
chucky315
 

premelec

Senior Member
I notice that infrain2 is no longer considered a good command... [see manual #2] and irin is recommended - this might work better. When you run the code in the editor simulator do you get any errors? [when you run it as 14M vs 14M2 is one ok and other not?] What editor version are you using?

I tried it in my editor and seems ok - have you got the chip plugged in right way around? :)
 
Last edited:

chucky315

New Member
The program simulates on picaxe programming editor but there is no out puts going out from the b0 to b6 so when I connect it to the L293D the motors won't move. I had I feeling the problem was the infrain and I was trying irin but it comes up with a syntax error and I'm not sure whyaand how to fix it.
 

hippy

Technical Support
Staff member
You probably need a "dirsB=$FF" command at the top of the program to make the B pins outputs on the 14M2. They are automatically outputs on the 14M but start as inputs on the 14M2.

It would also be recommended to change the "let pins=" to "let pinsB=" for consistency.
 

chucky315

New Member
You probably need a "dirsB=$FF" command at the top of the program to make the B pins outputs on the 14M2. They are automatically outputs on the 14M but start as inputs on the 14M2.

It would also be recommended to change the "let pins=" to "let pinsB=" for consistency.
thank you so much hippy the program simulated like it should when i added dirsB=$FF. would you please be able to explain to me how dirsB=$FF made the B pins the outputs just so i can have a better understanding on picaxe scripting.

thanks so much chucky315 :D
 

premelec

Senior Member
hippy already said what the difference is between the M and M2 units... do you know what $FF is in binary? [$FF = %xxxxxxxx ...] - glad it's working!
 
Top