#4984800
As a quick aside, If anyone is interested in using this control method for their trap build in future ( although I don't expect many will be) I'd be happy to make the wiring schematic and arduino sketch available.

This is written specifically for use with an 11 pin, 28 segment bar graph made by Barmeter.

Firstly, here's a quick wiring schematic:

Image

And the code:
Code: Select all
const int C1 = 2;
const int C2 = 3;
const int C3 = 4;
const int C4 = 5;
const int C5 = 6;
const int C6 = 7;
const int C7 = 9;

const int L1 = 10;
const int L2 = 11;
const int L3 = 12;
const int L4 = 13;

const int cathodePins[] = {C1, C2, C3, C4, C5, C6, C7};
const int anodePins[] = {L1, L2, L3, L4};

const int numSegments = 28;

// Adjustable brightness (0 to 255)
int brightness = 128; // Adjust this value to set the default brightness

const int indicatorPin = 8; // The additional LED indicator pin
const int thresholdValue = 1922; // Adjust this threshold as needed

void setup() {
  // Wait for a moment to allow the initialization process to complete
  delay(1000);

  for (int i = 0; i < sizeof(cathodePins) / sizeof(cathodePins[0]); i++) {
    pinMode(cathodePins[i], OUTPUT);
  }

  for (int i = 0; i < sizeof(anodePins) / sizeof(anodePins[0]); i++) {
    pinMode(anodePins[i], OUTPUT);
    analogWrite(anodePins[i], 0); // Set PWM brightness to 0 (LED off)
  }

  pinMode(indicatorPin, OUTPUT);
}

void loop() {
  int throttleValue = pulseIn(A0, HIGH, 20000);

  // Map the throttle value to control the number of lit segments (0 to 28)
  int numLitSegments = map(throttleValue, 1230, 4000, 0, numSegments);

  // Turn off all segments
  turnOffAllSegments();

  // Turn on segments based on throttle value with adjustable brightness
  for (int i = 0; i < numLitSegments; i++) {
    int cathodeIndex = i % 7;
    int anodeIndex = i / 7;

    digitalWrite(anodePins[anodeIndex], LOW);
    digitalWrite(cathodePins[cathodeIndex], HIGH);
    analogWrite(anodePins[anodeIndex], brightness);
  }

  // Turn on the indicator LED when the throttle value is greater than or equal to the threshold
  if (throttleValue >= thresholdValue) {
    digitalWrite(indicatorPin, HIGH);
  } else {
    digitalWrite(indicatorPin, LOW);
  }
}

void turnOffAllSegments() {
  for (int i = 0; i < sizeof(cathodePins) / sizeof(cathodePins[0]); i++) {
    digitalWrite(cathodePins[i], LOW);
  }

  for (int i = 0; i < sizeof(anodePins) / sizeof(anodePins[0]); i++) {
    // Set PWM brightness to 0 (LED off)
    analogWrite(anodePins[i], 0);
  }
}
#4984807
Thanks for sharing this! If it's of any interest someday, I've been using the brilliant HT16K33 board for my bargraphs. It has 16 Anode pins and 8 Cathode pins (so it's enough for a 28 segment bargraph). The main benefit to this is you only need 4 wires going back to the Arduino (SDA, SCL, +5V, GND) to run it, so it keeps the wiring tidy inside the trap and you run short lengths of wire from the bargraph to the board. It's also small enough to fit in the empty space beneath the bargraph.
Image

You can also repurpose one of the pins to control the indicator LED next to the bargraph, so that's effectively 29 LEDs using only 4 wires. I've been able to get by without resistors too (my wand bargraph has been going strong for over 2 years now).

First prototype (when I used one for my wand):
Image

Note that there's only 4 wires coming out of it back to the Arduino.

The official Adafruit library for it is pretty good, but there's also some others specifically designed for this bargraph, such as: I bought a pack of these on eBay fairly cheap so I use them in a lot of my projects, including my Tripod Trap builds.
RedSpecial, Nighty80, Snooker and 1 others liked this

Oh my...this will be interesting...

Hey guys, its been over a month without updates an[…]

Nice work! I have considered trying a 3D print pac[…]

Matty Trap - Replace Pedal?

Appreciate the input. Yeah I'm sure someone has. I[…]