Arduino Pin Library v4.2.2
An easy to use Arduino library for fast and simultaneous operations on Arduino I/O pins.
Loading...
Searching...
No Matches
Pin Class Reference

Class for fast operations on Arduino I/O pins. More...

#include <Pin.h>

Public Member Functions

 Pin ()
 Default constructor.
 
 Pin (uint8_t number)
 Arduino supported board constructor.
 
 Pin (uint8_t number, uint8_t offset, uint8_t timer, volatile uint8_t *PIN, volatile uint8_t *PORT, volatile uint8_t *DDR)
 Custom board constructor.
 
 operator bool () const
 Get the value of the pin from the PIN register.
 
Pinoperator= (uint8_t state)
 Set the pin state.
 
uint8_t getNumber ()
 Get the pin number.
 
uint8_t getOffset ()
 Get the pin offset.
 
uint8_t getInverseOffset ()
 Get the inverse pin offset.
 
uint8_t getTimer ()
 Get the pin timer.
 
volatile uint8_t * getPIN ()
 Get a pointer to the PIN register.
 
volatile uint8_t * getPORT ()
 Get a pointer to the PORT register.
 
volatile uint8_t * getDDR ()
 Get a pointer to the DDR register.
 
uint8_t getMode ()
 Get the mode of the pin from the DDR register.
 
uint8_t getState ()
 Get the state of the pin from the PORT register.
 
uint8_t getValue ()
 Get the value of the pin from the PIN register.
 
uint16_t getAnalogValue ()
 Get the analog value of the pin.
 
void set (uint8_t mode, uint8_t state)
 Set the pin mode and pin state.
 
void setMode (uint8_t mode)
 Set the pin mode.
 
void setState (uint8_t state)
 Set the pin state.
 
void setInput ()
 Set the pin mode to input.
 
void setPullupOn ()
 Set the pin pullup resistor to on.
 
void setPullupOff ()
 Set the pin pullup resistor to off.
 
void setInputPullupOn ()
 Set the pin mode to input and the pin pullup resistor to on.
 
void setInputPullupOff ()
 Set the pin mode to input and the pin pullup resistor to off.
 
void setOutput ()
 Set the pin mode to output.
 
void setHigh ()
 Set the pin output to HIGH.
 
void setLow ()
 Set the pin output to LOW.
 
void setOutputHigh ()
 Set the pin mode to output and the pin output to HIGH.
 
void setOutputLow ()
 Set the pin mode to output and the pin output to LOW.
 
void setDutyCycle (int value)
 Set the PWM duty cycle.
 
void toggleMode ()
 Toggle the pin mode (OUTPUT -> INPUT, INPUT -> OUTPUT)
 
void toggleState ()
 Toggle the pin state (HIGH -> LOW, LOW -> HIGH)
 
volatile unsigned int rcTimer (volatile unsigned int count)
 Set the pin mode to input and decrement a counter until the pin goes HIGH or the counter reaches 0 then set the pin mode to output and return the counter value.
 

Detailed Description

Class for fast operations on Arduino I/O pins.

Author
Alec Fenichel
Examples
Pin-Analog.ino, Pin-Array.ino, Pin-Custom.ino, Pin-Group.ino, Pin-PWM.ino, Pin-Timer.ino, and Pin-Toggle.ino.

Definition at line 40 of file Pin.h.

Constructor & Destructor Documentation

◆ Pin() [1/3]

Pin::Pin ( )
inline

Default constructor.

Definition at line 45 of file Pin.h.

◆ Pin() [2/3]

Pin::Pin ( uint8_t  number)
inline

Arduino supported board constructor.

Parameters
numberpin number written on board

Definition at line 60 of file Pin.h.

◆ Pin() [3/3]

Pin::Pin ( uint8_t  number,
uint8_t  offset,
uint8_t  timer,
volatile uint8_t *  PIN,
volatile uint8_t *  PORT,
volatile uint8_t *  DDR 
)
inline

Custom board constructor.

getAnalogValue() and setDutyCycle(int value) not supported

Parameters
numberpin number written on board
offsetbit mask used to access pin in registers
timertimer for pin
PINinput register for pin
PORTdata register for pin
DDRdata direction register for pin

Definition at line 82 of file Pin.h.

Member Function Documentation

◆ getAnalogValue()

uint16_t Pin::getAnalogValue ( )
inline

Get the analog value of the pin.

Returns
analog value of the pin (0-1023)
Examples
Pin-Analog.ino.

Definition at line 226 of file Pin.h.

◆ getDDR()

volatile uint8_t * Pin::getDDR ( )
inline

Get a pointer to the DDR register.

Returns
pointer to the DDR register

Definition at line 178 of file Pin.h.

◆ getInverseOffset()

uint8_t Pin::getInverseOffset ( )
inline

Get the inverse pin offset.

Returns
inverse pin offset

Definition at line 142 of file Pin.h.

◆ getMode()

uint8_t Pin::getMode ( )
inline

Get the mode of the pin from the DDR register.

Returns
mode of the pin (OUTPUT, INPUT)

Definition at line 187 of file Pin.h.

◆ getNumber()

uint8_t Pin::getNumber ( )
inline

Get the pin number.

Returns
pin number

Definition at line 124 of file Pin.h.

◆ getOffset()

uint8_t Pin::getOffset ( )
inline

Get the pin offset.

Returns
pin offset

Definition at line 133 of file Pin.h.

◆ getPIN()

volatile uint8_t * Pin::getPIN ( )
inline

Get a pointer to the PIN register.

Returns
pointer to the PIN register

Definition at line 160 of file Pin.h.

◆ getPORT()

volatile uint8_t * Pin::getPORT ( )
inline

Get a pointer to the PORT register.

Returns
pointer to the PORT register

Definition at line 169 of file Pin.h.

◆ getState()

uint8_t Pin::getState ( )
inline

Get the state of the pin from the PORT register.

Returns
state of the pin (HIGH, LOW)

Definition at line 200 of file Pin.h.

◆ getTimer()

uint8_t Pin::getTimer ( )
inline

Get the pin timer.

Returns
pin timer

Definition at line 151 of file Pin.h.

◆ getValue()

uint8_t Pin::getValue ( )
inline

Get the value of the pin from the PIN register.

Returns
value of the pin (HIGH, LOW)

Definition at line 213 of file Pin.h.

◆ operator bool()

Pin::operator bool ( ) const
inline

Get the value of the pin from the PIN register.

Returns
true if the value of the pin is HIGH, false otherwise

Definition at line 97 of file Pin.h.

◆ operator=()

Pin & Pin::operator= ( uint8_t  state)
inline

Set the pin state.

Parameters
statethe state of the pin (HIGH, LOW)

Definition at line 106 of file Pin.h.

◆ rcTimer()

volatile unsigned int Pin::rcTimer ( volatile unsigned int  count)
inline

Set the pin mode to input and decrement a counter until the pin goes HIGH or the counter reaches 0 then set the pin mode to output and return the counter value.

Parameters
countthe initial value for the counter to start at (0-65535)
Returns
the value remaining on the counter when the pin state went to HIGH or 0 if the counter reached 0
Examples
Pin-Timer.ino.

Definition at line 424 of file Pin.h.

◆ set()

void Pin::set ( uint8_t  mode,
uint8_t  state 
)
inline

Set the pin mode and pin state.

Parameters
modethe mode of the pin (OUTPUT, INPUT)
statethe state of the pin (HIGH, LOW)

Definition at line 236 of file Pin.h.

◆ setDutyCycle()

void Pin::setDutyCycle ( int  value)
inline

Set the PWM duty cycle.

Parameters
valuethe duty cycle (0-255)
Examples
Pin-PWM.ino.

Definition at line 393 of file Pin.h.

◆ setHigh()

void Pin::setHigh ( )
inline

Set the pin output to HIGH.

Examples
Pin-Array.ino, Pin-Custom.ino, Pin-Group.ino, and Pin-Toggle.ino.

Definition at line 349 of file Pin.h.

◆ setInput()

void Pin::setInput ( )
inline

Set the pin mode to input.

Examples
Pin-Analog.ino.

Definition at line 287 of file Pin.h.

◆ setInputPullupOff()

void Pin::setInputPullupOff ( )
inline

Set the pin mode to input and the pin pullup resistor to off.

Definition at line 328 of file Pin.h.

◆ setInputPullupOn()

void Pin::setInputPullupOn ( )
inline

Set the pin mode to input and the pin pullup resistor to on.

Definition at line 317 of file Pin.h.

◆ setLow()

void Pin::setLow ( )
inline

Set the pin output to LOW.

Examples
Pin-Array.ino, Pin-Group.ino, and Pin-Timer.ino.

Definition at line 359 of file Pin.h.

◆ setMode()

void Pin::setMode ( uint8_t  mode)
inline

Set the pin mode.

Parameters
modethe mode of the pin (OUTPUT, INPUT)

Definition at line 257 of file Pin.h.

◆ setOutput()

void Pin::setOutput ( )
inline

Set the pin mode to output.

Examples
Pin-Array.ino, Pin-Custom.ino, Pin-PWM.ino, and Pin-Toggle.ino.

Definition at line 339 of file Pin.h.

◆ setOutputHigh()

void Pin::setOutputHigh ( )
inline

Set the pin mode to output and the pin output to HIGH.

Definition at line 369 of file Pin.h.

◆ setOutputLow()

void Pin::setOutputLow ( )
inline

Set the pin mode to output and the pin output to LOW.

Definition at line 380 of file Pin.h.

◆ setPullupOff()

void Pin::setPullupOff ( )
inline

Set the pin pullup resistor to off.

Definition at line 307 of file Pin.h.

◆ setPullupOn()

void Pin::setPullupOn ( )
inline

Set the pin pullup resistor to on.

Definition at line 297 of file Pin.h.

◆ setState()

void Pin::setState ( uint8_t  state)
inline

Set the pin state.

Parameters
statethe state of the pin (HIGH, LOW)

Definition at line 273 of file Pin.h.

◆ toggleMode()

void Pin::toggleMode ( )
inline

Toggle the pin mode (OUTPUT -> INPUT, INPUT -> OUTPUT)

Definition at line 400 of file Pin.h.

◆ toggleState()

void Pin::toggleState ( )
inline

Toggle the pin state (HIGH -> LOW, LOW -> HIGH)

Examples
Pin-Custom.ino, and Pin-Toggle.ino.

Definition at line 410 of file Pin.h.


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