Visual Basic: Factoring Time in Light Alternation

  • Thread starter Thread starter nick227
  • Start date Start date
  • Tags Tags
    Visual
Click For Summary
SUMMARY

This discussion focuses on implementing timed light alternation using Visual Basic (VB) and Java. The VB Timer control is highlighted as a key tool for managing time intervals, allowing users to set an interval property to trigger actions at specified times. In Java, the approach involves using time functions to compare the current time with a stored time to execute actions. Both methods enable users to alternate lights or display messages for defined durations, such as 5 or 10 seconds.

PREREQUISITES
  • Understanding of Visual Basic programming and its Timer control.
  • Familiarity with Java programming and time functions.
  • Basic knowledge of loops and conditional statements in programming.
  • Experience with hardware interfacing, specifically using parallel ports.
NEXT STEPS
  • Explore the properties and usage of the VB Timer control in detail.
  • Learn about Java's System.currentTimeMillis() for time management.
  • Research event-driven programming concepts in VB and Java.
  • Investigate hardware interfacing techniques for controlling LEDs via parallel ports.
USEFUL FOR

This discussion is beneficial for beginner programmers, hobbyists working with hardware projects, and developers interested in time-based event handling in Visual Basic and Java.

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.)
 

Similar threads

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