Skip to main content
Version: 4.0.0-beta.3

Piston

Constructors​

Piston()​

Creates a new Piston object.

input_port ADI port the solenoid is plugged into.
default_state the level the solenoid's pin starts at. get() and set() are relative to it: get() is false at startup, and set(true) moves the piston to the opposite of default_state.

Piston(int input_port, bool default_state = false);

Piston()​

Creates a new Piston object where the solenoid is plugged into a 3 wire expander.

input_port ADI port the solenoid is plugged into.
expander_smart_port smart port the 3 wire expander is plugged into.
default_state the level the solenoid's pin starts at. get() and set() are relative to it: get() is false at startup, and set(true) moves the piston to the opposite of default_state.

Piston(int input_port, int expander_smart_port, bool default_state = false);

Setters​

set()​

Sets the piston to fire.

input boolean to fire the piston.

void set(bool input);

button_toggle()​

Toggles the piston back and forward with a single button during opcontrol.

toggle an input button.

void button_toggle(int toggle);

Also accepts a pros::controller_digital_e_t directly.

void button_toggle(pros::controller_digital_e_t toggle);

buttons()​

Sets the piston to go in and out with 2 buttons during opcontrol.

active the button to activate the piston.
deactive the button to retract the piston.

void buttons(int active, int deactive);

Also accepts pros::controller_digital_e_t directly.

void buttons(pros::controller_digital_e_t active, pros::controller_digital_e_t deactive);

Getter​

get()​

Gets the state of the piston.

bool get();