Addressable LEDs, Ultra Sonic Range sensors, Piezo sensors, Multiple Arduinos

Hardware

-12v addressable LED strips with 6803 chipset - 6
-5v 4 pin Range sensors - 3
-Guitar hero Drums
-arduino micros/arduino unos

there is one “overarching” concept here

-take a sensor reading from either a piezo or a ultrasonic sensor
-translate that reading to a value for the LED strip
-control that LED strip in “real time”
-be it Pixel height (how many pixels are illuminated)
-color (based on sensor reading colors change)
-brightness

effect im trying to accomplish:

As I raise my hand away from the range sensor the LEDS “grow” up the strip
as I lower my hand closer to the strip the LEDS “shrink” back down the strip

I have been able to accomplish this by modifying the “amplitie” code; however the response time is very “laggy”…I thought that perhaps this was due to lack of processing power in the arduino?

anyone got anything for me? or can I clarify anything? Ive got sketch after sketch of things that kinda halfway work.

please help

Hardware

-Addressible LED strips 6803 chipset -Guitar hero drums -arduino uno/micro -one big button

Concept:

-3 guitar hero drum pads -red -blue -green

-one led strip per pad

-hit a guitar hero drum pad -harder the hit the more pixels in the strand light up (kinda like those sledge hammer games at the fair)

-with 3 people hitting 3 pads we have a different value for the "color strength" of each Pad/Strip at any given time.

-when a 4th person hits the "big button"; based on the "color values" at that moment all the LED strips with "bleed down" the new color that is determined by the color strength of each pad.

does that make sense? Can anyone help?

I think I may just not have enough "processing power" and need a way to "link everything" more efficiently?

I have a bunch of sketches but they are kinda just bits a pieces....

This sounds very doable and I think you should have processing to spare. I would start by making a sketch that can control each part of the device individually as it sounds like you have. Then you can start to integrate them piece by piece. When you do this it help to map out the general flow of the overall program. For illustration here is what I think your final code could look like at a high level.

Setup Everything

Main Loop:
  While(All Sensors Not Triggered):
    Read Each Piezo
    Save Piezo Reading if Above Trigger Threshold
    Light the strip at the saved reading

  While(button not pressed):
    Display Static Strip State

  Bleed Down LED Strips
  Set new color

I don't know enough about the project to say this is 100% what you want to do, but it should give you an idea of where to start. Also, if you can make your individual sketches use high level functions instead of doing everything in loop() then you will be far better off when you go to put everything together.

I have been able to accomplish this by modifying the "amplitie" code

The what?

/*
LED VU meter for Arduino and Adafruit NeoPixel LEDs.

Hardware requirements:

  • Most Arduino or Arduino-compatible boards (ATmega 328P or better).
  • Adafruit Electret Microphone Amplifier (ID: 1063)
  • Adafruit Flora RGB Smart Pixels (ID: 1260)
    OR
  • Adafruit NeoPixel Digital LED strip (ID: 1138)
  • Optional: battery for portable use (else power through USB or adapter)
    Software requirements:
  • Adafruit NeoPixel library

Connections:

  • 3.3V to mic amp +
  • GND to mic amp -
  • Analog pin to microphone output (configurable below)
  • Digital pin to LED data input (configurable below)
    See notes in setup() regarding 5V vs. 3.3V boards - there may be an
    extra connection to make and one line of code to enable or disable.

Written by Adafruit Industries. Distributed under the BSD license.
This paragraph must be included in any redistribution.
*/

#include <Adafruit_NeoPixel.h>

#define N_PIXELS 16 // Number of pixels in strand
#define MIC_PIN A9 // Microphone is attached to this analog pin
#define LED_PIN 6 // NeoPixel LED strand is connected to this pin
#define DC_OFFSET 0 // DC offset in mic signal - if unusure, leave 0
#define NOISE 10 // Noise/hum/interference in mic signal
#define SAMPLES 60 // Length of buffer for dynamic level adjustment
#define TOP (N_PIXELS + 2) // Allow dot to go slightly off scale
#define PEAK_FALL 40 // Rate of peak falling dot

byte
peak = 0, // Used for falling dot
dotCount = 0, // Frame counter for delaying dot-falling speed
volCount = 0; // Frame counter for storing past volume data
int
vol[SAMPLES], // Collection of prior volume samples
lvl = 10, // Current “dampened” audio level
minLvlAvg = 0, // For dynamic adjustment of graph low & high
maxLvlAvg = 512;
Adafruit_NeoPixel
strip = Adafruit_NeoPixel(N_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

// This is only needed on 5V Arduinos (Uno, Leonardo, etc.).
// Connect 3.3V to mic AND TO AREF ON ARDUINO and enable this
// line. Audio samples are ‘cleaner’ at 3.3V.
// COMMENT OUT THIS LINE FOR 3.3V ARDUINOS (FLORA, ETC.):
// analogReference(EXTERNAL);

memset(vol, 0, sizeof(vol));
strip.begin();
}

void loop() {
uint8_t i;
uint16_t minLvl, maxLvl;
int n, height;

n = analogRead(MIC_PIN); // Raw reading from mic
n = abs(n - 512 - DC_OFFSET); // Center on zero
n = (n <= NOISE) ? 0 : (n - NOISE); // Remove noise/hum
lvl = ((lvl * 7) + n) >> 3; // “Dampened” reading (else looks twitchy)

// Calculate bar height based on dynamic min/max levels (fixed point):
height = TOP * (lvl - minLvlAvg) / (long)(maxLvlAvg - minLvlAvg);

if(height < 0L) height = 0; // Clip output
else if(height > TOP) height = TOP;
if(height > peak) peak = height; // Keep ‘peak’ dot at top

// Color pixels based on rainbow gradient
for(i=0; i<N_PIXELS; i++) {
if(i >= height) strip.setPixelColor(i, 0, 0, 0);
else strip.setPixelColor(i,Wheel(map(i,0,strip.numPixels()-1,30,150)));

}

// Draw peak dot
if(peak > 0 && peak <= N_PIXELS-1) strip.setPixelColor(peak,Wheel(map(peak,0,strip.numPixels()-1,30,150)));

strip.show(); // Update strip

// Every few frames, make the peak pixel drop by 1:

if(++dotCount >= PEAK_FALL) { //fall rate

if(peak > 0) peak–;
dotCount = 0;
}

vol[volCount] = n; // Save sample for dynamic leveling
if(++volCount >= SAMPLES) volCount = 0; // Advance/rollover sample counter

// Get volume range of prior frames
minLvl = maxLvl = vol[0];
for(i=1; i<SAMPLES; i++) {
if(vol < minLvl) minLvl = vol*;*
else if(vol > maxLvl) maxLvl = vol*;*
* }*
* // minLvl and maxLvl indicate the volume range over prior frames, used*
* // for vertically scaling the output graph (so it looks interesting*
* // regardless of volume level). If they’re too close together though*
* // (e.g. at very low volume levels) the graph becomes super coarse*
* // and ‘jumpy’…so keep some minimum distance between them (this*
* // also lets the graph go to zero when no sound is playing):*
* if((maxLvl - minLvl) < TOP) maxLvl = minLvl + TOP;*
_ minLvlAvg = (minLvlAvg * 63 + minLvl) >> 6; // Dampen min/max levels_
_ maxLvlAvg = (maxLvlAvg * 63 + maxLvl) >> 6; // (fake rolling average)_

}

// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
* if(WheelPos < 85) {*
_ return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
* } else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}*_

And now with code tags and no italics, please

I gotcha, and you are correct seems very doable; my problems may just be in my strips…
the reaction time seems really slow and choppy.
also all my sensors are about 20’ apart from the arduino (idk if that matters)?

seems that arduino is having trouble either running more that one strip at a time?

I was wondering if I had a full system:
-arduino
-strip
-pad (piezo)
for each strip

then had another arduino to handle “compinations” with the “big button” if it would ease things?

I would love that too! I stole this code from the adafruit website, Swapped my range sensor for the microphone and it “works” (so i know what im trying to do is possible) but I yeah…im having a hard time really figuring out what its doing too…

best I have been able to determine

-reads the mic pin
-stores a “base” of 60 samples
-determines an average of those samples
(to establish a “baseline” of noise so its not just displaying “ambient sound”)

-takes that average, translates it into the number of pixels in the strip
-then sends it to the strip

-there is another bit of code that lets the “top pixel” hang and fall independent of the rest of the strip
-it does all this with a “rainbow gradient”

Ive spent many hours adding and subtracting bits and pieces to figure out what it does and does not need to actually function

things I dont need

-Peak dot/fall
-rainbow gradient

however my “fear” is that these LED strips have limitations, meaning you have to send a command down the entire strip before you send the next command; there is no “mid strip” interrupt. The reason this code seems to have such and interrupt is because of the rainbow gradient…since the pixels are “always changing” the strip is constantly updating…like I said this “works” its just really slow with my distance sensor; hence my thought on lack of processing power…

if im so far off base feel free to tell me…I kinda feel like im swinging in the dark here…talking crazy

thank you for the help so far!

Hardware

-12v addressable LED strips with 6803 chipset - 6 -5v 4 pin Range sensors - 3 -Guitar hero Drums -arduino micros/arduino unos

there is one "overarching" concept here

-take a sensor reading from either a piezo or a ultrasonic sensor -translate that reading to a value for the LED strip -control that LED strip in "real time" -be it Pixel height (how many pixels are illuminated) -color (based on sensor reading colors change) -brightness

effect im trying to accomplish:

As I raise my hand away from the range sensor the LEDS "grow" up the strip as I lower my hand closer to the strip the LEDS "shrink" back down the strip

I have been able to accomplish this by modifying the "amplitie" code; however the response time is very "laggy"....I thought that perhaps this was due to lack of processing power in the arduino?

anyone got anything for me? or can I clarify anything? Ive got sketch after sketch of things that kinda halfway work.

please help

Do not cross-post. Threads merged.

Do not cross-post. Threads merged.