|
-
October 4th, 2008, 08:08 AM
#1
Traffic Lights c#
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.
-
October 4th, 2008, 01:26 PM
#2
Re: Traffic Lights c#
Look at the Timer class.....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 4th, 2008, 04:51 PM
#3
Re: Traffic Lights c#
-
October 4th, 2008, 05:15 PM
#4
Re: Traffic Lights c#
 Originally Posted by johnboy14
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.
In case that is too difficult:http://msdn.microsoft.com/en-us/libr...rms.timer.aspx
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 5th, 2008, 11:34 AM
#5
Re: Traffic Lights c#
LOL You guys crack me up!
-
October 5th, 2008, 11:41 AM
#6
Re: Traffic Lights c#
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.
-
October 5th, 2008, 11:51 AM
#7
Re: Traffic Lights c#
 Originally Posted by johnboy14
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.
-
October 5th, 2008, 12:03 PM
#8
Re: Traffic Lights c#
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.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 5th, 2008, 12:06 PM
#9
Re: Traffic Lights c#
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.
-
October 5th, 2008, 12:08 PM
#10
Re: Traffic Lights c#
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?
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 5th, 2008, 12:10 PM
#11
Re: Traffic Lights c#
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.
Last edited by johnboy14; October 5th, 2008 at 12:14 PM.
-
October 5th, 2008, 12:43 PM
#12
Re: Traffic Lights c#
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
Last edited by johnboy14; October 5th, 2008 at 12:48 PM.
-
October 5th, 2008, 01:03 PM
#13
Re: Traffic Lights c#
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?
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
October 5th, 2008, 01:09 PM
#14
-
October 5th, 2008, 01:36 PM
#15
Re: Traffic Lights c#
I want it to just run in a loop. until the button is pressed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|