Hi there.
I'm new to arduino with very little knowledge about using it so I apologise in advance.
I'll try to provide as much information as I can.
I'm attempting to use the following 11 pin, 28 segment multiplexed bar graph, linked to a Max7219 IC and an arduino Uno in order to use the bar graph as a level gauge for a vintage analogue transmitter throttle stick, to display one segment at a time as the throttle stick is pushed up to full throttle where all segments plus a single LED will then be lit and turn off one at a time in reverse order on throttle down.
I have everything connected as follows:
The PWM signal from the receiver connected to pin A0 on the Arduino uno
The single LED connected to digital pin 8 and gnd on the arduino
⦁ Data In (DIN) pin 1 on MAX7219 to arduino digital pin 11,
⦁ Clock (CLK) pin 13 on MAX7219 to arduino digital pin 13
⦁ Chip Select (CS) pin 12 on MAX7219 to arduino digital pin 10.
⦁ max7219 V+ and iset connected to arduino 5v with a 10k resistor between iset and 5v
⦁ max7219 gnd pins 4 and 9 bridged then connected to arduino gnd
⦁ SEG A (pin 14) to L1
⦁ SEG B (pin 16) to L2
⦁ SEG C (pin 20) to L3
⦁ SEG D (pin 23) to L4
⦁ DIG 0 (pin 2) to C1
⦁ DIG 1 (pin 11) to C2
⦁ DIG 2 (pin 6) to C3
⦁ DIG 3 (pin 7) to C4
⦁ DIG 4 (pin 3) to C5
⦁ DIG 5 (pin 10) to C6
⦁ DIG 6 (pin 5) to C7
So far with the following code, I've managed to get to the point where all bar graph segments and single LED will light up at the full throttle range and turn off as I start to throttle down but the bar graph segments won't turn on one at a time as the throttle increases as I need them to and I can't seem to get my head around what could be causing the issue.
#include <SPI.h>
const int MAX7219_CS_PIN = 10;
const int RECEIVER_PIN = A0;
const int LED_PIN = 8;
void setup() {
SPI.begin();
pinMode(MAX7219_CS_PIN, OUTPUT);
digitalWrite(MAX7219_CS_PIN, HIGH); // Disable MAX7219 temporarily
// Initialize the MAX7219
sendSPICommand(0x09, 0x00); // Decode Mode off
sendSPICommand(0x0A, 0x0F); // Intensity (range: 0x00 to 0x0F)
sendSPICommand(0x0B, 0x07); // Scan Limit: 8 LEDs
sendSPICommand(0x0C, 0x01); // Power-down Mode: Normal operation
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
}
void loop() {
int throttleValue = pulseIn(RECEIVER_PIN, HIGH, 20000); // Adjust timeout based on your receiver's PWM range
// Map the PWM value to control the single LED
if (throttleValue >= 1923) {
digitalWrite(LED_PIN, HIGH); // Turn on the single LED at full throttle
} else {
digitalWrite(LED_PIN, LOW); // Turn off the single LED otherwise
}
// Map the PWM value to control the bargraph (0 to 27, assuming 28 segments)
int barGraphValue = map(throttleValue, 1362, 1923, 0, 27);
// Update the bargraph display
digitalWrite(MAX7219_CS_PIN, LOW); // Enable MAX7219
for (int i = 0; i <= barGraphValue; i++) {
sendSPICommand(i + 1, 0x01); // Turn on the LED at index i
}
for (int i = barGraphValue + 1; i < 28; i++) {
sendSPICommand(i + 1, 0x00); // Turn off the LED at index i
}
digitalWrite(MAX7219_CS_PIN, HIGH); // Disable MAX7219
}
void sendSPICommand(byte address, byte data) {
SPI.transfer(address);
SPI.transfer(data);
}

