how to put delays in procedures
Author |
Message |
leafs911
|
Posted: Wed Jan 16, 2008 8:37 pm Post subject: how to put delays in procedures |
|
|
hi
i am trying make the LEDs blink.....i tired puting delay (number) and it did not work.
i hope to get a reply tonight as this is due tomorrow.
thanks
Turing: |
%=============================================================%
% Author: Behram Shah Bashir %
% Course: ICE3M %
% Project: ISU %
% Descrition: This code runs a program which controls a car.%
%=============================================================%
%=======================Setting Up GUI========================%
import GUI
View.Set ("graphics:360;255,nobuttonbar")
%=========================Procedure===========================%
procedure Left
locate (12, 5)
put "Turing Left"
parallelput (5)
end Left
procedure Right
locate (12, 5)
put "Turing Right"
parallelput (10)
end Right
procedure Forward
locate (12, 5)
put "Moving Forward"
parallelput (15)
end Forward
procedure Stop
locate (12, 5)
put "Stopped"
parallelput (192)
end Stop
procedure Exit
GUI.Quit
loop
exit when GUI.ProcessEvent
end loop
Window.Hide (defWinID )
end Exit
procedure Horn
Music.Sound (230, 20)
locate (12, 5)
put "Honking"
end Horn
procedure hlights
locate (12, 5)
put "Headlights On"
parallelput (48)
end hlights
procedure lturn %******this is were i want the delay****%
locate (12, 5)
put "Indicating a left turn"
parallelput (80)
end lturn
procedure rturn %******this is were i want the delay****%
locate (12, 5)
put "Indicating a right turn"
parallelput (160)
end rturn
procedure Elight %******this is were i want the delay****%
locate (12, 5)
put "Emergency indicators on"
parallelput (240)
end Elight
%=================Creating Buttons & Procedures====================%
var chars : array char of boolean
var bl : int := GUI.CreateButton (10, 210, 100, "Left", Left )
var bf : int := GUI.CreateButton (130, 225, 100, "Forward", Forward )
var br : int := GUI.CreateButton (250, 210, 100, "Right", Right )
var bs : int := GUI.CreateButton (130, 170, 100, "Stop", Stop )
var bcw : int := GUI.CreateButton (130, 10, 100, "Exit", Exit )
var bh : int := GUI.CreateButton (70, 135, 100, "Honk", Horn )
var bhl : int := GUI.CreateButton (190, 135, 100, "Headlights", hlights )
var bil : int := GUI.CreateButton (10, 185, 100, "Left Signal", lturn )
var bir : int := GUI.CreateButton (250, 185, 100, "Right Signal", rturn )
var bhi : int := GUI.CreateButton (130, 105, 100, "Emergency", Elight )
%===========================Core Code===============================%
loop
Input.KeyDown (chars )
locate (4, 1)
if chars (KEY_UP_ARROW) then
Forward
end if
if chars (KEY_RIGHT_ARROW) then
Right
rturn
end if
if chars (KEY_LEFT_ARROW) then
Left
lturn
end if
if chars (KEY_DOWN_ARROW) then
Stop
end if
if chars ('h') then
Horn
end if
if chars ('l') then
hlights
end if
if chars ('e') then
Elight
end if
exit when GUI.ProcessEvent
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
HeavenAgain
|
Posted: Wed Jan 16, 2008 8:43 pm Post subject: RE:how to put delays in procedures |
|
|
hehe, to make a LED blink, you gotta know how the "blink" work, when something blink, it gotta be on, and then off, and during the on time, there have to be a delay, and during the off time, there have to be another delay, so it is visible for the human eyes to see
and then all you need is a for loop of how many times you want it to blink
i hope it helps |
|
|
|
|
|
OneOffDriveByPoster
|
Posted: Wed Jan 16, 2008 8:46 pm Post subject: Re: how to put delays in procedures |
|
|
I think you have to parallelput something else after the delay and then delay again to make it "blink". |
|
|
|
|
|
leafs911
|
Posted: Wed Jan 16, 2008 8:47 pm Post subject: RE:how to put delays in procedures |
|
|
so the for loop would that be in inside the procedures right?
well ill try putting it in the procedures.
thanks for the quick reply...i really appreciate it. |
|
|
|
|
|
HeavenAgain
|
Posted: Wed Jan 16, 2008 8:49 pm Post subject: RE:how to put delays in procedures |
|
|
not quite "something else", if you have 1010, and the 2nd bit is the LED, and you still want to keep the 4th bit on, so you parallelput 1000 to make ONLY the LED go off, and then 1010 to turn it back on again, so you dont lose any "information" there
yes, i would put that for loop in the procedure, however when you call to that procedure there will be a "lag", because you have to wait for the blinking procedure to finish running the for loop
try use process instead, and see what happens, this way it wont interrupt your whole program |
|
|
|
|
|
|
|