We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › delay but not stopping the program
Page Index Toggle Pages: 1
delay but not stopping the program (Read 610 times)
delay but not stopping the program
Jan 19th, 2007, 4:07pm
 
How do you set something on (in my case a pin on an arduino board) for an amount of time (24ms) and then off for an amount of time(38ms) but not with using delay(), because while this loop is going to make a square wave On/Off another pin on the arduino board needs to give another timed pulse for example 22ms On an 40 ms Off

thx

pieter
Re: delay but not stopping the program
Reply #1 - Jan 19th, 2007, 8:05pm
 
you can use java's Timer class:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Timer.html
or the swing timer class:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/Timer.html
for the latter you'd need to add "import javax.swing.Timer" to the beginning of your sketch.
a longer tutorial can be seen here:
http://java.sun.com/products/jfc/tsc/articles/timer/
avoid the mentions of "swing" in particular, but it should clarify how things work with the swing timer.
Page Index Toggle Pages: 1