I want to increase a value over time when using the joystick. The value would start out at zero and you would press the joystick forward, the longer you press it forward the larger the value gets and when you hold the joystick down the value gets smaller over time.
I’d have a feedback node/shift register storing the current value, and each iteration the value of the joystick adds to it. It’d probably be a good idea to make a separate loop in periodic tasks so that you get a constant rate.
What are you using this for?
I think you are looking for a “shift register”. It is a node that remembers the last thing that you wrote to it.
This can be found on the Programming -> Structures palette. It looks like an arrow in a rectangle. It can point in either direction (right click to change). New data goes into the tail of the arrow, old data comes out the tip of it.
In simplest terms, I’m trying to move a point on a graph using the joystick. I can get it to increase and decrease, i just need to make it so that it is not so rapid. Would i just put a wait timer in there or would that slow down the code?
A wait timer would slow down Teleop, but would work fine in Periodic Tasks.
Anything you can do in Teleop, you can also do in Periodic Tasks if you need explicit delays.
This isn’t part of the robot project. This is just a simulator
Would i just have the values writing in a separate while loop with a wait timer in it?
Lets say you hold the joystick full forward “forever”. What do you want the output to be? Should it keep going up, or settle to match the joystick’s position?
keep going up
A separate, independent while loop that constantly checks the joystick at the rate you decide upon would work.
Or if you want to be fancy, you could have it update the value every so often, while still running the loop.
Better still, have it update the value every iteration, but have something that reads the speed of the loop and divides the value of the joystick by a number proportional to that.
Or just add the timer…
You should have the program generate a maze, plot it on an XY graph, and then use the joystick to navigate the maze. That would be epic.
I like your ideas WizenedEE! but I’m just trying to simulate a robot drive (which is a lot easier than I originally thought!). That maze project sounds like some good practice :]