Author |
Message |
rss14
|
Posted: Thu Jun 05, 2008 3:49 pm Post subject: Is it possible to have code running in the backround? |
|
|
I need a loop to continuously be running in the background, while the program plays. Is that possible? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
SNIPERDUDE
|
Posted: Thu Jun 05, 2008 3:57 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
look it up in the Turing Walkthrough about procedures |
|
|
|
|
|
rss14
|
Posted: Thu Jun 05, 2008 4:00 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
Thank you for the link. |
|
|
|
|
|
rss14
|
Posted: Thu Jun 05, 2008 5:08 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
I read the tutorial, but I am a bit confused.
My program uses parallelput to give output to LEDs in order to resemble a traffic intersection.
However, I need to add a crossing light, and a switch.
When parallelget(64) = 1, then I put that into a variable:
loop
switchpressed := parallelget
if ((switchpressed div 128) mod 2) = 1 then
switchstandby = true
end if
end loop
However, the program just continues this loop, which i want running in the backround, and ignores the rest of the code (which parralelputs the LEDs (also a loop) ) |
|
|
|
|
|
rss14
|
Posted: Thu Jun 05, 2008 5:51 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
procedure buttonpressed
switchpressed := parallelget
if ((switchpressed div 128) mod 2) = 1 then
switchstandby := true
end if
end buttonpressed
loop
buttonpressed
parallelput (33)
cancross := false
delay (5000)
buttonpressed
parallelput (9)
cancross := false
delay (2000)
buttonpressed
if switchstandby = true then
parallelput (82)
else
parallelput (18)
end if
cancross := true
delay (5000)
buttonpressed
parallelput (6)
cancross := false
delay (2000)
end loop
This is my revised code. . . however, the LED only turns on if I hold the button, so when buttonpressed runs, it find the button to be 1 . . . I can't find a way to have button pressed run for an infinite amount of time, without disturbing the loop of the traffic lights. . . |
|
|
|
|
|
rss14
|
Posted: Thu Jun 05, 2008 7:56 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
Nvm, i got help from a friend.
I made a process so the thing will run in the background. |
|
|
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 8:22 pm Post subject: Re: RE:Is it possible to have code running in the backround? |
|
|
rss14 @ Thu Jun 05, 2008 7:56 pm wrote: Nvm, i got help from a friend.
Not much of "help" if it's the wrong solution.
A single frame of your loop takes 14 seconds to complete. So it all works, for the most part, correctly. Just very slowly. Take out the delays. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Insectoid
|
Posted: Thu Jun 05, 2008 8:35 pm Post subject: RE:Is it possible to have code running in the backround? |
|
|
Just so I can learn, what does parallelput do? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Thu Jun 05, 2008 8:52 pm Post subject: Re: RE:Is it possible to have code running in the backround? |
|
|
insectoid @ Thu Jun 05, 2008 8:35 pm wrote: what does parallelput do?
the bit-pattern encoding the integer argument sets the high/low pins on the parallel port. It requires some pretty old hardware and some cut-up cables, but it's an easy way to hooked up to electronic components such as 5v motors and LEDs. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Insectoid
|
Posted: Fri Jun 06, 2008 9:22 am Post subject: RE:Is it possible to have code running in the backround? |
|
|
Oh, so that's what I'm going to be using with my LED binary conversion project I guess... |
|
|
|
|
|
|