Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#include <SPI.h>
#define CHIP_SELECT_PIN 10
void setup() {
// Setup SPI communication for the MAX7221.
pinMode(CHIP_SELECT_PIN, OUTPUT);
SPI.begin();
// Test for 1 second.
send(0x0F, 0x01);
delay(1000);
send(0x0F, 0x00);
// Turn off decoding.
send(0x09, 0x00);
// Set scan limiter to display all registers.
send(0x0B, 0x07);
// Set display intensity (0-F).
send(0x0A, 0x04);
// Turn on display.
send(0x0C, 0x01);
// Clear all the display registers.
send(0x01, 0x00);
send(0x02, 0x00);
send(0x03, 0x00);
send(0x04, 0x00);
send(0x05, 0x00);
send(0x06, 0x00);
send(0x07, 0x00);
send(0x08, 0x00);
}
void loop() {
send(0x01, random(256));
send(0x02, random(256));
send(0x03, random(256));
send(0x04, random(256));
send(0x05, random(256));
send(0x06, random(256));
send(0x07, random(256));
send(0x08, random(256));
delay(1000);
}
void send(byte address, byte value) {
digitalWrite(CHIP_SELECT_PIN, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CHIP_SELECT_PIN, HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.