Can Opener - ME 507
LimitSwitch Class Reference

Class which reads from a limit switch. More...

#include <limitSwitch.h>

Public Member Functions

 LimitSwitch (uint8_t switchID, uint8_t inPin)
 Constructor for the LimitSwitch class. More...
 
bool readSwitch (void)
 Reads the condition of the limit switch. More...
 

Protected Attributes

uint8_t switchID
 ID of switch.
 
uint8_t inPin
 Input pin on board

 
bool triggered
 Triggered status.
 

Detailed Description

Class which reads from a limit switch.

This class reads a limit switch and determines which state it is in. Note that limit switches can be wired pretty differently from switch to switch, so it is up to the user to determine which boolean value corresponds with each switch state

Constructor & Destructor Documentation

◆ LimitSwitch()

LimitSwitch::LimitSwitch ( uint8_t  switchID,
uint8_t  inPin 
)

Constructor for the LimitSwitch class.

This constructor sets an ID for the switch and sets which pin the limit switch is connected to.

Parameters
switchIDThe ID of this object
inPinThe pin the limit switch is connected to.

Member Function Documentation

◆ readSwitch()

bool LimitSwitch::readSwitch ( void  )

Reads the condition of the limit switch.

Returns true if the inPin is set high. This doesn't necessarily mean depressed or not, because it relies on how the limit switch is wired

Returns
The state of the switch: Changes from false->true or true->false when the switch is pressed depending on wiring.

The documentation for this class was generated from the following files: