FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Limit Switch Program

Highlighted

Hello! I've been trying to program a limit switch for my robot for awhile in order to clasp a pole when pressed. How can I call a motor when the limit switch is pressed for a specified period of time? How would one program this in the Begin, Teleop, and Finish? Thanks!

0 Kudos
Message 1 of 2
(288 Views)
Highlighted

use Begin to initialize everything

auto_claw_init.png

Use Teleop or Periodic Tasks to code the action - since this would be easier to code as "waiting" for the condition, this might be better for periodic tasks (so the drive code in teleop is unaffected by the loop).

auto_claw_loop.png

If you need more control than the flat sequence gives you (which is likely), consider building a State Machine (so you can code each part of it, waiting, pressed, closing, etc in discreet parts and move from one to the next or start over easily)

 

In Finish, close all the IO you opened in Begin.

 

 

 

If you have any questions about this (or LabVIEW for FRC in general), please feel free to PM me.

0 Kudos
Message 2 of 2
(250 Views)