Arduino Helpers master
Utility library for Arduino
1.MAX7219-Blink.ino

1.MAX7219-Blink

This example demonstrates the use of MAX7219 LED outputs as if they were just normal IO pins, using digitalWrite.

Boards:
AVR, AVR USB, Nano Every, Nano 33 IoT, Nano 33 BLE, UNO R4, Pi Pico, Due, Teensy 3.x, ESP8266, ESP32

Connections

Behavior

This sketch will blink the first and the last LEDs once a second, in an alternating pattern.

Written by PieterP, 2020-03-24
https://github.com/tttapa/Arduino-Helpers

#include <Arduino_Helpers.h> // Include the Arduino Helpers library.
using namespace ExtIO; // Bring the ExtIO pin functions into your sketch
// Instantiate a MAX7219 with the SPI slave select pin as latch pin
// There's just 1 MAX7219 in the chain, if you have more of them daisy-chained
// together, you can increase the template argument (between angled brackets)
MAX7219<1> max7219 {SPI, SS};
const pin_t ledPin1 = max7219.pin(0); // first LED of the MAX7219
const pin_t ledPin2 = max7219.pin(63); // last LED of the MAX7219
void setup() {
max7219.begin(); // Initialize the shift registers
pinMode(ledPin1, OUTPUT); // You don't even need this line, since
pinMode(ledPin2, OUTPUT); // since the MAX7219's pins are always outputs
}
void loop() {
// Toggle the state of the LEDs every 1/2 second
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, LOW);
delay(500);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, HIGH);
delay(500);
}
constexpr PinStatus_t LOW
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
Dummy header file for Arduino builder.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
pin_t pin(pin_t pin) const
Get the extended IO pin number of a given physical pin of this extended IO element.
A class for LED outputs using the MAX7219 LED display driver.
Definition: MAX7219.hpp:31
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.
A namespace with alternatives to the standard Arduino IO functions that can be used with extended IO ...