I am trying to create a set of traffic lights using visual c#, my problem is how to implement a timer between each light. I have 3 traffic lights and 2 pedestrian lights. Any help on the timer folks.
Printable View
I am trying to create a set of traffic lights using visual c#, my problem is how to implement a timer between each light. I have 3 traffic lights and 2 pedestrian lights. Any help on the timer folks.
Look at the Timer class..... :rolleyes: :rolleyes:
where's that Mr Vague
Did you ever consider a really radical approach of going to the MSDN site and typing in "Timer"...The very first hit is what you need.Quote:
Originally Posted by johnboy14
In case that is too difficult:http://msdn.microsoft.com/en-us/libr...rms.timer.aspx
LOL :D You guys crack me up! :D
very useful, I am new to c# so all and visual c# so I ain't quite up todate on all the sites and best places for different stuff. Thanks anyway.
maybe you should also try to use the little known search site called Google. a simple search for "c# timers" would have netted you plenty of results.Quote:
Originally Posted by johnboy14
msdn.microsoft.com is the official site for any Microsoft product related questions.
google.com is also a useful resource, but one needs to be careful since the results can come from "anyone". There is alot of incorrect material on the internet, and much of the .Net postings contain incorrect or sub-optimal information.
I usually recommmend starting with msdn then google if necessary. If you find something that looks good on google, you will have specific keywords that you can use to confirm the information back on msdn.
Would I declare the timer before the main or as soon as I enter the main.
You see I have a Button that activates the lights, I want it to wait 5 seconds then give me an amber light.
You "Declare" the timer by dragging it from the toolbox onto your form. You can initialize the duration in the properties window, or in code. You can start and stop the timer with the enabled property. You write an event handler which is triggered when the timer expires.
Did you download and step through the available samples?
bits of it, I am familar with declaring variables and methods etc. but I programmed a set of traffic lights with an AVR board once in C but low level stuff to be honest. I'll read through them,
p.s I was unaware that there was a timer on visual c#, so I could drag and drop. I can't seem to find it on my toobar though.
In all honesty I'm not sure how to start.
this below is my code for my start button, I set the timer to intervals of 5 seconds so am I free to place what what I want my lights to do now.
private void button1_Click(object sender, System.EventArgs e)
{
timer1.Enabled = true
Go back to design mode on your form. Select the timer. Select the Properties Windows. Switch to events view (looks like a lightning bolt). Double click on the event. This will add an empty routine to your code where you put the logic of what to do when the timer expires...
I will ask one more time...
Did you download and step through the available samples?
No I Did Not.
I want it to just run in a loop. until the button is pressed