Program Delay

In windriver is there a way to program a button to activate lets say a jaguar to turn on a motor for short time then hav the same button activate a piston a second later

There exists a way to program your robot to do pretty much anything. You have to define the conditions you want things to operate in. For instance:

You have Switch A, and Switch B.

If Switch A is on, then pressing Switch B causes action X to happen.
If Switch A is off, then pressing Switch B causes action Y to happen.

You can also cause a switch to perform one action, such as turning a motor on, then activate a timer, and when the timer expires, do something else.

how would i make it activate the timer

You need to instantiate an object of the Timer class, and then call the Timer->Start(); function in your button code. Then in the routine that runs when the timer expires, you do something else.

Look up the WPILib Documentation on the Timer class.

Rikard, if I’m understanding your original post, you want to perform two actions with a single input, with the first action occurring immediately and the second occurring a second later. Instead using a timer (which would force you to continuoulsy check to see if a second has elapsed), you could use a Notifier class.

To use the Notifier class, you first create a function you want called after your elapsed time period (i.e. a function that would activate the piston in your case). The function takes a void pointer. You could use this by passing in a pointer to the solonoid you want to actuate, for example, and cast it back to a Solonoid pointer in the function.

Now to use the notifier class, when you construct it, give it the name of the function you want called as the TimerEventHandler argument and the pointer you want to pass to the function as the param argument. Then, when the user presses the button (or whatever your input is), call Notifier::StartSingle with the delay in seconds as the argument. In that amount of time, your function will automatically be called with the parameter you provided it.

I know this is kind of advanced programming, and if you’re confused, feel free to PM me, but I think it would be the best way to do it. Unlike a timer, the Notifier class will automatically call your function in the specified amount of time without you having to worry about it any more.