Hello,

Still very new to arduino, but have made enough progress to move onto creating a PCB for my project. To get to that, I needed to bring the Atmega chip to a standalone breadboard and make sure everything works without the arduino board. When I hook it up, it appears to function properly for a split second and then locks up. Resetting (via button) the Atmega will make it work for a split second again before freezing.

I figure the problem may be code... but the program works fine with the chip hooked up in the arduino board, so I don't know how much different the program will run when standalone.

To hook up the Atmega on the breadboard, I followed the guide on this site... and for hooking up AVCC, I have a 100ohm res to power and a 0.1uF cap to ground. To be honest, I have no clue how well that works for what I'm doing. Still an electronics noob

Here's the sketch, maybe someone can find something wrong with it?

`#include <BassFilter.c>`

#include <BassFilter.h>

//The number of samples to buffer before analyzing them

int samplesN = 75;

int transSpd = 5;

float trans = 0;

int micPin = 0;

int potPin = 1;

int jackPin = 2;

int redPin = 6;

int greenPin = 5;

int bluePin = 3;

int redClr = 128;

int greenClr = 128;

int blueClr = 128;

float clrInt = 1.0;

int bassThresh = 750;

int quietThresh = 10;

int clrs[18];

int clr = 0;

BassFilter* filter;

void setup(){

Serial.begin(9600);

//randomSeed(analogRead(0));

filter = new BassFilter();

BassFilter_init(filter);

pinMode(micPin, INPUT);

pinMode(potPin, INPUT);

pinMode(jackPin, INPUT);

clrs[0] = 255;

clrs[1] = 0;

clrs[2] = 0;

clrs[3] = 255;

clrs[4] = 255;

clrs[5] = 0;

clrs[6] = 0;

clrs[7] = 255;

clrs[8] = 0;

clrs[9] = 0;

clrs[10] = 255;

clrs[11] = 255;

clrs[12] = 0;

clrs[13] = 0;

clrs[14] = 255;

clrs[15] = 255;

clrs[16] = 0;

clrs[17] = 255;

newColor();

}

void newColor() {

clr++;

int ind = clr*3 % 18;

redClr = clrs[ind]; //random(0.25*(float)clrs[ind],clrs[ind]);

greenClr = clrs[ind+1]; //random(0.25*(float)clrs[ind+1],clrs[ind+1]);

blueClr = clrs[ind+2]; //random(0.25*(float)clrs[ind+2],clrs[ind+2]);

}

void colorIntensity(float intensity) {

int m = 0;

float tr = 0;

int ind = clr*3 % 18;

clrInt = intensity;

tr = trans * (float)clrs[(ind+3) % 18];

if (clrs[ind] > 0 && clrs[(ind+3) % 18] < 255)

tr = trans * -255.0;

m = round((float)redClr + intensity * 255.0);

m = m + tr;

if (m > 255)

m = 255;

if (m < 0)

m = 0;

analogWrite(redPin, m);

tr = trans * (float)clrs[(ind+4) % 18];

if (clrs[ind+1] > 0 && clrs[(ind+4) % 18] < 255)

tr = trans * -255.0;

m = round((float)greenClr + intensity * 255.0);

m += tr;

if (m > 255)

m = 255;

if (m < 0)

m = 0;

analogWrite(greenPin, m);

tr = trans * (float)clrs[(ind+5) % 18];

if (clrs[ind+2] > 0 && clrs[(ind+5) % 18] < 255)

tr = trans * -255.0;

m = round((float)blueClr + intensity * 255.0);

m += tr;

if (m > 255)

m = 255;

if (m < 0)

m = 0;

analogWrite(bluePin, m);

}

int maxpeak = 0 ;

int minPeak = 1023;

int sndMax = 0;

int sndMin = 1023;

long sndOut = 0;

int sndFil[3];

int sndCt = 0;

int sndDamp = 10;

long minPow = 1023;

long maxPow = 0;

void loop(){

int peak = 0;

//bassThresh = analogRead(1);

sndOut = 0;

float pow = 0;

for(int k=0; k<samplesN; k++){

int val = analogRead(jackPin);

BassFilter_put(filter, val);

int filtered = BassFilter_get(filter);

peak = max(peak, filtered);

pow += (float)filtered / (float)samplesN;

}

maxpeak = max(maxpeak, peak);

minPeak = min(minPeak, peak);

pow = abs(pow);

minPow = min(minPow, pow);

maxPow = max(maxPow, pow);

if (sndCt > 1000 && peak > quietThresh) {

minPow = 1023;

maxPow = 0;

minPeak = 1023;

maxpeak = 0;

sndCt = 0;

}

sndCt++;

pow = map(pow, minPow, maxPow, 0, 1023) - analogRead(potPin);

if (pow < 0)

pow = 0;

colorIntensity((float)pow / 1023.0);

int lvl = map(peak, minPeak, maxpeak, 0, 1023);

int comp = map((float)bassThresh / 1023.0 * (float)maxpeak, minPeak, maxpeak, 0, 1023);

if (lvl > comp) {

newColor();

}

trans += (float)transSpd / 255.0;

if (trans >= 1.0) {

newColor();

trans = 0;

}

}

If anyone can help, I would really appreciate it. :.

~Plystire