Question for Mike about code.
MovieMaker
Posts: 502
Hey, Mike!
· If you are watching, I have been trying to convert lines of PBASIC into C++ code for the robot I am currently working on. I have learned a lot, but apparently not enough. For my Boe-bot, I would write something like this for the subroutine:
Raise_Brows:
for i=1 to 40
PULSOUT browservo,600
next
Pause 500
RETURN
Now, I cannot find a PULSOUT command in my version of C.
Is there away around this with some other C command?
Thanks for your wonder help in the past.· Also, I welcome Anyone to answer this question, but I know that Mike will know the answer. Thank You All.
:-)
· If you are watching, I have been trying to convert lines of PBASIC into C++ code for the robot I am currently working on. I have learned a lot, but apparently not enough. For my Boe-bot, I would write something like this for the subroutine:
Raise_Brows:
for i=1 to 40
PULSOUT browservo,600
next
Pause 500
RETURN
Now, I cannot find a PULSOUT command in my version of C.
Is there away around this with some other C command?
Thanks for your wonder help in the past.· Also, I welcome Anyone to answer this question, but I know that Mike will know the answer. Thank You All.
:-)
Comments
You can't find a PULSOUT command in your version of C because there isn't any such thing in C or C++ unless someone (the vendor) has provided a library function to do it. For that matter, there's normally no timing capability in C either, so you can't have a PAUSE.
How you might do something like this depends on your C or C++ system and what you're running the program on (and you didn't supply any of that ... makes it really hard to help).
Are you planning a remake or the next chapter of "Short Circuit"?
Kwinn,
The raised brows are very cool. A johnny five robot is already available. I think as a finished product and as a kit. But, I like mine better. (it costs less.)
I plan in the future to possibly use the BasicStampII,PX24,PE,Propeller and two arduinos in one machine. But, I need to learn C.
Post Edited (MovieMaker) : 8/2/2009 2:34:01 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Post Edited (Franklin) : 8/2/2009 10:12:24 PM GMT
You'll find library routines "delayMicroseconds" and "digitalWrite" which you can use together to do what PULSOUT does and "delay" does what PAUSE does.
while(1 == 1) // loop forever
{
for(i = 0; i < servopulse; i++) // make pin high for the correct pulse length
{
servopin = 1;
}
for(i = 0; i < twentymstime; i++) // make pin low for 20ms
{
servopin = 0;
}
} // loop again to top
For the constants twentymstime, servopulse, and servopin you will need to put in the correct numbers to make it function. Also note I am fairly new to C, so this may not be the best way to get the job done.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PG
Pi, your language looks Exactly like mine. Also Arduino version 17 is going to include PULSOUT. Yeh!
Thank You guys sooo much!
Post Edited (MovieMaker) : 8/2/2009 6:18:19 PM GMT