Arduino Pin Library  v4.2.0
An easy to use Arduino library for fast and simultaneous operations on Arduino I/O pins.
Pin Class Reference

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

#include <Pin.h>

Public Member Functions

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

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-Library-Benchmark.ino, Pin-PWM.ino, Pin-Timer.ino, and Pin-Toggle.ino.

Definition at line 39 of file Pin.h.

Constructor & Destructor Documentation

§ Pin() [1/3]

Pin::Pin ( )
inline

Default constructor.

Definition at line 46 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 61 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 83 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 233 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 185 of file Pin.h.

§ getInverseOffset()

uint8_t Pin::getInverseOffset ( )
inline

Get the inverse pin offset.

Returns
inverse pin offset

Definition at line 149 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 194 of file Pin.h.

§ getNumber()

uint8_t Pin::getNumber ( )
inline

Get the pin number.

Returns
pin number

Definition at line 131 of file Pin.h.

§ getOffset()

uint8_t Pin::getOffset ( )
inline

Get the pin offset.

Returns
pin offset

Definition at line 140 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 167 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 176 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 207 of file Pin.h.

§ getTimer()

uint8_t Pin::getTimer ( )
inline

Get the pin timer.

Returns
pin timer

Definition at line 158 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 220 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 101 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 110 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 448 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 248 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 409 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, Pin-Library-Benchmark.ino, and Pin-Toggle.ino.

Definition at line 365 of file Pin.h.

§ setInput()

void Pin::setInput ( )
inline

Set the pin mode to input.

Examples:
Pin-Analog.ino.

Definition at line 301 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 342 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 331 of file Pin.h.

§ setLow()

void Pin::setLow ( )
inline

Set the pin output to LOW.

Examples:
Pin-Array.ino, Pin-Group.ino, Pin-Library-Benchmark.ino, and Pin-Timer.ino.

Definition at line 375 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 269 of file Pin.h.

§ setOutput()

void Pin::setOutput ( )
inline

Set the pin mode to output.

Examples:
Pin-Array.ino, Pin-Custom.ino, Pin-Library-Benchmark.ino, Pin-PWM.ino, and Pin-Toggle.ino.

Definition at line 355 of file Pin.h.

§ setOutputHigh()

void Pin::setOutputHigh ( )
inline

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

Definition at line 385 of file Pin.h.

§ setOutputLow()

void Pin::setOutputLow ( )
inline

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

Definition at line 396 of file Pin.h.

§ setPullupOff()

void Pin::setPullupOff ( )
inline

Set the pin pullup resistor to off.

Definition at line 321 of file Pin.h.

§ setPullupOn()

void Pin::setPullupOn ( )
inline

Set the pin pullup resistor to on.

Definition at line 311 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 285 of file Pin.h.

§ toggleMode()

void Pin::toggleMode ( )
inline

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

Definition at line 421 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 431 of file Pin.h.


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