variable delay in PIC16F877A

Thread Starter

almeihan

Joined May 13, 2022
1
i have a code in (PIC16F877A) i made a delay for one sec and i need to make a traffic light so the delay between each of them is deferent so for example for red i need delay 5 sec but i do not want to call delay five time like this ,call delay,call delay,call delay,call delay, what is the best way to make 5 sec delay in this situation .

Moderators note : changed font size, as large fonts are like screaming.
 

Papabravo

Joined Feb 24, 2006
18,084
Easiest way is to modify the existing function so you can pass it a value and it will implement a delay of that value. What language the code is written in is irrelevant, since you can implement this strategy in any coding paradigm that you happen to have.
 

MrSalts

Joined Apr 2, 2020
1,532
If you are using assembly, the strategy is different than listed above, but "different" is in the eye of the beholder. It's not much different but I'm guessing different enough because you are asking here. As was asked above, which language are you using.
 

MrChips

Joined Oct 2, 2009
25,920
Function call is
call delay

Parameters can be passed via a register, variable, or on the stack.
For a simple function call, pass the parameter via a CPU register.
 
Top