Dual CAN Bus Interface For Arduino Due: Controlling the LEDs
The following explains how to control the LEDs on our jCOM.CAN.DUE and jCOM.CAN.DUE-X boards. The experienced Arduino programmer may frown since all necessary information is available (LED1 = GPIO 14; LED2 = GPIO 15).
Consequently, this post is for the novice Arduino programmer or those who are primarily interested in embedded Controller Area Network programming.
Just as a reminder, the image below shows the jCOM.CAN.DUE board and its components, including the LEDs, where the Power LED is not controlled by a GPIO but directly by the actual power supply.
- J1 - CAN Port 0
- J2 - CAN Port 1
- J3 - External Power Supply 7 - 36 VDC (only on the jCOM.CAN-.DUE-X board)
- JP1 - Jumper Termination Resistor CAN Port 0
- JP2 - Jumper Termination Resistor CAN Port 1
- PWR - Power LED
- LED1 - LED Connected to Arduino Due GPIO 14
- LED2 - LED Connected to Arduino Due GPIO 15
Controlling GPIOs on the Arduino is supported directly through the Arduino's programming environment, using the pinMode and digitalWrite commands as demonstrated in the code below:
The sketch initializes GPIOs 14 and 15 as outputs. In the setup() loop, we use a timer of 500 msec, meaning the program toggles the status of each LED every 500 milliseconds.
Controller Area Network (CAN) is a serial network technology that was originally designed for the automotive industry, especially for European cars, but has also become a popular bus in industrial automation as well as other applications.
The CAN bus is primarily used in embedded systems, and as its name implies, is a network technology that provides fast communication among microcontrollers up to real-time requirements, eliminating the need for the much more expensive and complex technology of a Dual-Ported RAM. This book provides complete information on all CAN features and aspects combined with a high level of readability.