Thanks for the replies, here's some more info
Yeah, forget about getting any help on this until you post a photo of your circuit, a schematic that shows anything that is not in the schematic you linked of the op amp circuit and your code.
There's nothing else in the schematic, this is it. Here's a picture and the code;
#include <Adafruit_NeoPixel.h>
#define analogIn 1
#define PIN 4
#define NUM_LEDS 19
uint8_t input=0;
uint8_t oldInput=0;
uint8_t decrease=2;
float increaseFact=1.2;
uint8_t colors[3];
uint8_t brightness;
uint8_t lastRead=90;
uint16_t lowCol=20;
uint16_t highCol=70;
uint16_t mainCol=45;
uint16_t maxInput=500;
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
wavey(lowCol,highCol,0.011,1); // color effect, with speed and color limits
}
void readSens(){
if (millis()>lastRead+50){
input = analogRead(analogIn);
if (input>maxInput){
maxInput=input;
}
input=map(input,0,maxInput,10,255);
// Serial.println(input);
}
}
void updateBrightness(){ // call the sensor function + translate sens value into a brightness level
readSens();
if (input>oldInput && oldInput<(254/increaseFact)){
oldInput=oldInput*increaseFact+1;
if (oldInput>254){
oldInput=254;
}
}
else{
oldInput=oldInput*.98;
}
brightness=oldInput;
//Serial.println(oldInput);
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void wavey(int low,int high,float rt,uint8_t wait) {
float in,out;
int diff=high-low;
int step = diff/strip.numPixels();
for (in = 0; in < 6.283; in = in + rt) {
for(int i=0; i< strip.numPixels(); i++) {
out=sin(in+i*(6.283/strip.numPixels())) * diff + low;
HSVtoRGB(out,255,255,colors);
strip.setPixelColor(i,(colors[0]*brightness)/255,(colors[1]*brightness)/255,(colors[2]*brightness)/255);
}
updateBrightness();
strip.show();
delay(wait);
}
}
void HSVtoRGB(int hue, int sat, int val, uint8_t * colors) {
int r, g, b, base;
if (sat == 0) { // Achromatic color (gray).
colors[0] = val;
colors[1] = val;
colors[2] = val;
}
else {
base = ((255 - sat) * val) >> 8;
switch (hue / 60) {
case 0:
colors[0] = val;
colors[1] = (((val - base) * hue) / 60) + base;
colors[2] = base;
break;
case 1:
colors[0] = (((val - base) * (60 - (hue % 60))) / 60) + base;
colors[1] = val;
colors[2] = base;
break;
case 2:
colors[0] = base;
colors[1] = val;
colors[2] = (((val - base) * (hue % 60)) / 60) + base;
break;
case 3:
colors[0] = base;
colors[1] = (((val - base) * (60 - (hue % 60))) / 60) + base;
colors[2] = val;
break;
case 4:
colors[0] = (((val - base) * (hue % 60)) / 60) + base;
colors[1] = base;
colors[2] = val;
break;
case 5:
colors[0] = val;
colors[1] = base;
colors[2] = (((val - base) * (60 - (hue % 60))) / 60) + base;
break;
}
}
}
FYI. - Try isolating the problem by separating the led power from the ATtiny power. Also separate the code . Run just the op amp
Like I said, isolating the opamp-sensor + ATtiny part from the LEDS (also running them on an Uno) works perfect, no problem at all, but I would them to work together and that doesnt work on any of them.
Take voltage measurements to see if you can find anything strange.
Voltage readings while measuring are showing the same as the analog reads; low signal (<.5V) when there is no volume, ~3V at loud sounds, and then the signal voltage stays there, even without sound input. Input voltage stays stable at 5.0V.
You need to learn more about Op Amps and how to use them.
I've tried to research as much as I could into what I need, but I got stuck at what I have right now... some more indications on what part to look at would be helpful. I've had my basic introduction... its been a few years though.
The OpAmp circuit is an exact copy of the Arduino Esplora volume sensor part, the only thing I changed of the esplora design (http://arduino.cc/en/uploads/Main/arduino-esplora-schematic.pdf top right corner part), the value of R1 100k resistor to a 2mOhm resistor in my setup....