CrcLib: How to access IO pins
This page presents how to access the CrcDuino IO pins using CrcLib.
Pins
Physical pins of the CrcDuino are accessible using the following symbolic constants (aliases/names, familiarly called defines). They are already defined by CrcLib using a #define
preprocessor directive, which allow programmers to give meaningful names to parts of their code.
For more information about the hardware aspect of the I/O pins, refer to the CrcDuino Hardware Details page.
We encourage programmers to use their own #define
preprocessor directive at the top of their .ino file
to give pins a name in their program that reflects its effective use (instead of the generic CRC_xxx_x
), for example:
#define RIGHT_FEEDER_MOTOR CRC_PWM_5
#define ARM_EXTENDED_LIMIT_SWITCH CRC_DIG_1
In these cases, whenever the compiler stumbles upon the text string “RIGHT_FEEDER_MOTOR”, it will be replaced in the code by “CRC_PWM_5”. Whenever it reads “ARM_EXTENDED_LIMIT_SWITCH”, it will be replaced by “CRC_DIG_1”.
Digital Pins
These pins read or outputs digital signals.
CRC_DIG_1
CRC_DIG_2
CRC_DIG_3
CRC_DIG_4
CRC_DIG_5
CRC_DIG_6
CRC_DIG_7
CRC_DIG_8
CRC_DIG_9
CRC_DIG_10
CRC_DIG_11
CRC_DIG_12
The numbers for the pins match the one written on the board.
These pins are used with the SetDigitalPinMode()
, GetDigitalInput()
or SetDigitalOutput()
CrcLib function.
PWM Pins
These pins output Servo type PWM signals.
CRC_PWM_1
CRC_PWM_2
CRC_PWM_3
CRC_PWM_4
CRC_PWM_5
CRC_PWM_6
CRC_PWM_7
CRC_PWM_8
CRC_PWM_9
CRC_PWM_10
CRC_PWM_11
CRC_PWM_12
The numbers for the pins match the one written on the board.
These pins are used with the InitializePwmOutput()
, SetPwmOutput()
, MoveTank()
, MoveArcade()
or MoveHolomonic()
CrcLib function.
Analog Pins
These pins read and quantify analog voltage signals.
CRC_ANA_1
CRC_ANA_2
CRC_ANA_3
CRC_ANA_4
The numbers for the pins match the one written on the board.
These pins are used with the GetAnalogInput()
CrcLib function.
Communication Pins
These pins are used to communicate with the outside world using various communication protocols.
SPI Port
CRC_SPI_MISO
CRC_SPI_MOSI
CRC_SPI_SCK
CRC_SPI_SS
These pins can be used with the Arduino standard SPI library.
I2C Port
CRC_I2C_SDA
(physically aligned w/ the “MISO” mark)CRC_I2C_SCL
(physically aligned w/ the “MOSI” mark)
These pins can be used with the Arduino standard Wire library for I2C networking.
SERIAL Port
CRC_SERIAL_TXD1
(physically aligned w/ the “MISO” mark)CRC_SERIAL_RXD1
(physically aligned w/ the “MOSI” mark)
These pins can be used with the native Arduino Serial communication functions.
Encoder Pins
These pins are meant to be used to read digital signals coming from a quadrature encoder.
ENCO Port
CRC_ENCO_A
(physically aligned w/ the “MISO” mark)CRC_ENCO_B
(physically aligned w/ the “MOSI” mark)
Physically inaccessible pins
CRC_LM35D
: Reserved for receiving temperature data from the board temperature sensor, if installed. Most CrcDuino boards don't have a LM35D temperature sensor installed. If there's no component soldered in the 3 holes right below the 0270 inscription next to the buzzer, it means your board is not equipped with a temperature sensor.CRC_VBATT
: Reserved for reading the board power source voltage. It's highly recommended to use the GetBatteryVoltage() function instead of directly reading from this pin using the native Arduino function digitalRead().