Visual Basic: Factoring Time in Light Alternation

  • Thread starter Thread starter nick227
  • Start date Start date
  • Tags Tags
    Visual
Click For Summary
The discussion focuses on programming techniques for controlling LED lights via a computer's parallel port, specifically using Visual Basic (VB) and Java. The user seeks to alternate between three colors of lights and is interested in incorporating time delays for each color display. Key suggestions include utilizing the VB Timer control, which allows setting an interval for actions to occur, enabling the lights to change after a specified duration. For Java, the approach involves using time functions to track the current time and implementing a loop to trigger actions based on elapsed time. Both languages can achieve the desired functionality, with VB providing a more straightforward control mechanism compared to Java's manual time management.
nick227
Messages
35
Reaction score
0
Hey all. I am working on this program that will light LEDs from the parallel port of my computer. I think i have everything all set, but i want to do something cool. I was thinking of alternating lights between three colors. i am new to VB (and programming in general) and was wondering if there was a way to factor time into alternating the lights. Can i somehow make a method or some sort of loop that let's me run one set of lights for say 5 seconds or any amount of time then move on to the next set of lights? Basically, how do i factor in time?

Also, if i can do this with VB, can i do it with java? say i want to have a message appear for 10 seconds, then disappear and have another message appear for 10 seconds?
 
Technology news on Phys.org
nick227 said:
Hey all. I am working on this program that will light LEDs from the parallel port of my computer. I think i have everything all set, but i want to do something cool. I was thinking of alternating lights between three colors. i am new to VB (and programming in general) and was wondering if there was a way to factor time into alternating the lights. Can i somehow make a method or some sort of loop that let's me run one set of lights for say 5 seconds or any amount of time then move on to the next set of lights? Basically, how do i factor in time?
Certainly. Look at the VB Timer control. You drag it onto your page and set its properties (look at the interval property) and turn it on and it will fire each interval.

In Java, you won't have it all wrapped up in a control, but you will have access to Time functions. You'd store the current Time, and test it using a loop. When the old and current time are the appropraite number apart, you trigger your action. (You can do it the same way in VB too.)
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
1K
  • · Replies 16 ·
Replies
16
Views
2K
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
10
Views
5K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K