AVR code help

Status
Not open for further replies.

rocket100

Member
I am using great cow basic to program my AVRs it uses freeBasic, It works fine. But I don't know a whole lot about freeBasic so I ran into a problem, I need to run two pieces of code at the same time, for example, have a light sensor reading and a servo turning, or something like that. If anyone knows the answer please let me know!
Thanks in advanced!
 
You don't need to know anything about FreeBasic, unless you decide to re-compile the GCBasic source code.

A servo needs to only update every 20ms, so long as that happens, looping inline code should be fine. If delay routines, synchronous comms, state machines, or timing critical operations are required, then interrupts could/should be utilized. Also, many operations can run in the background like comparators, pwm, timers etc. so that little impact is noticed in code timing.
 
The simple answer is you can't run them at the same time, you can however as nickel suggested time them so they run one after another but don't overlap.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…