SOLVED-No Errors But not even passing setup-Thanx

Hi all,
First off i am new and using mostly example code…
But i have a rice paper floor lamp with 3 one meter LED strips in it and a Grove I2C Multitouch and Grove RBG backlight LCD…

The Code with a fire effect is working Great has 4 touch sensors to cycle though and change settings with the LCD…

And the Water looking one works but once i add in the touch and LCD code it just hangs before it even gets the setup done (sometimes makes it to the LCD backlight color) but i don’t get any errors and all the code works on its own

Original:

#include <FastLED.h>

#define LED0_PIN     2
#define LED1_PIN     4
#define LED2_PIN     6
#define CLOCK0_PIN   3
#define CLOCK1_PIN   5
#define CLOCK2_PIN   7
#define CHIPSET     WS2801
const bool    kMatrixSerpentineLayout = false;
const uint8_t kMatrixWidth = 3;
const uint8_t kMatrixHeight = 32;
#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
CRGB leds[kMatrixWidth * kMatrixHeight];

int BRIGHTNESS = 128;
int HUESPEED = .1;
int SPEED = 30;
int SCALE = 4000;

// The 32bit version of our coordinates
static uint16_t x;
static uint16_t y;
static uint16_t z;

// This is the array that we keep our computed noise values in
uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];

void setup()
{
 delay(3000);
 FastLED.addLeds<CHIPSET, LED0_PIN, CLOCK0_PIN>(leds, 0, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.addLeds<CHIPSET, LED1_PIN, CLOCK1_PIN>(leds, kMatrixHeight, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.addLeds<CHIPSET, LED2_PIN, CLOCK2_PIN>(leds, 2 * kMatrixHeight, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.setBrightness(BRIGHTNESS);

 // Initialize our coordinates to some random values
 x = random16();
 y = random16();
 z = random16();
}

void loop()
{
 WaterNoise();
 FastLED.setBrightness(BRIGHTNESS);
}

void WaterNoise()
{
 static float ihue = 0;
 for(int i = 0; i < MAX_DIMENSION; i++)
 {
 int ioffset = SCALE * i;
 for(int j = 0; j < MAX_DIMENSION; j++)
 {
 int joffset = SCALE * j;
 noise[i][j] = inoise8(x + ioffset, y + joffset, z);
 }
 }
 z += SPEED;
 for(int i = 0; i < kMatrixWidth; i++)
 {
 for(int j = 0; j < kMatrixHeight; j++)
 {
 // We use the value at the (i,j) coordinate in the noise
 // array for our brightness, and the flipped value from (j,i)
 // for our pixel's hue.
 //leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]);

 //leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>1),255,noise[i][j]);
 leds[XY(i, j)] = CHSV(ihue + noise[j][i], 255, noise[i][j]);
 }
 }
 ihue += HUESPEED;
 LEDS.show();
}

uint16_t XY( uint8_t x, uint8_t y)
{
 uint16_t i;

 if( kMatrixSerpentineLayout == false)
 {
 i = (y * kMatrixWidth) + x;
 }

 if( kMatrixSerpentineLayout == true)
 {
 if( y & 0x01)
 {
 // Odd rows run backwards
 uint8_t reverseX = (kMatrixWidth - 1) - x;
 i = (y * kMatrixWidth) + reverseX;
 }
 else
 {
 // Even rows run forwards
 i = (y * kMatrixWidth) + x;
 }
 }
 return i;
}

Code in Question with the touch-n-LCD from the fire code:

#include <FastLED.h>
#include <Wire.h>
#include <GroveMultiTouch.h>
#include <rgb_lcd.h>

#define LED0_PIN     2
#define LED1_PIN     4
#define LED2_PIN     6
#define CLOCK0_PIN   3
#define CLOCK1_PIN   5
#define CLOCK2_PIN   7
#define CHIPSET     WS2801
const bool    kMatrixSerpentineLayout = false;
const uint8_t kMatrixWidth = 3;
const uint8_t kMatrixHeight = 32;
#define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)
CRGB leds[kMatrixWidth * kMatrixHeight];

int BRIGHTNESS = 128;
int HUESPEED = .1;
int SPEED = 30;
int SCALE = 4000;

// The 32bit version of our coordinates
static uint16_t x;
static uint16_t y;
static uint16_t z;

// This is the array that we keep our computed noise values in
uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];

int menumode = 0;
int COLPAL = 0;
#define MAXMENUMODE 4
#define MAXCOLPAL 3

String COLPALNAME = "Hello          ";
rgb_lcd lcd;
const int colorR = 0;
const int colorG = 0;
const int colorB = 250;

GroveMultiTouch feelers(8);
boolean padTouched[4];
boolean wastouched = true;
static unsigned long last_touched_time = 0;
long previousMillis = 0;

void setup()
{
 delay(3000);
 FastLED.addLeds<CHIPSET, LED0_PIN, CLOCK0_PIN>(leds, 0, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.addLeds<CHIPSET, LED1_PIN, CLOCK1_PIN>(leds, kMatrixHeight, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.addLeds<CHIPSET, LED2_PIN, CLOCK2_PIN>(leds, 2 * kMatrixHeight, kMatrixHeight).setCorrection( TypicalLEDStrip );
 FastLED.setBrightness(BRIGHTNESS);

 // Initialize our coordinates to some random values
 x = random16();
 y = random16();
 z = random16();
 
 Wire.begin(); // needed by the GroveMultiTouch lib
 lcd.begin(16, 2);
 lcd.setRGB(colorR, colorG, colorB);
 feelers.initialize(); // initialize the feelers
 for(int i = 0; i <= 3; i++)
 {
 padTouched[i] = false;
 }
}

void loop()
{
 unsigned long currentMillis = millis();

 if (currentMillis - last_touched_time > 5000UL)
 {
 if(wastouched)
 {
 lcd.setCursor(0, 0);
 lcd.print("Run Time       ");
 lcd.setCursor(0, 1);
 lcd.print("               ");
 wastouched = false;
 }
 lcd.setCursor(0, 1);
 lcd.print(millis() / 1000);
 }

 feelers.readTouchInputs(); // test read the touch sensors
 for(int i = 0; i <= 3; i++)
 {
 if(feelers.getTouchState(i))
 {
 if(!padTouched[i])
 {
 //Serial.print(i);
 //Serial.println(" +");
 }
 padTouched[i] = true;
 touched(i);
 }
 else
 {
 if(padTouched[i])
 {
 //Serial.print(i);
 //Serial.println(" -");
 }
 padTouched[i] = false;
 }
 }

 WaterNoise();
 FastLED.setBrightness(BRIGHTNESS);
}

void touched(int pad)
{
 unsigned long touched_time = millis();
 if (touched_time - last_touched_time > 200)
 {
 last_touched_time = touched_time;
 wastouched = true;
 lcd.setCursor(0, 1);
 lcd.print("                ");
 if(pad == 0)
 {
 menumode ++;
 if(menumode == MAXMENUMODE)
 {
 menumode = 0;
 }
 }
 if(pad == 1)
 {
 menumode --;
 if(menumode == -1)
 {
 menumode = MAXMENUMODE - 1;
 }
 }
 switch(menumode)
 {
 case 0:
 if(pad == 2 && SCALE <= 3999)
 {
 SCALE += 10;
 }
 if(pad == 3 && SCALE >= 2)
 {
 SCALE -= 10;
 }
 lcd.setCursor(0, 0);
 lcd.print("Scale          ");
 lcd.setCursor(0, 1);
 lcd.print(SCALE);
 break;
 case 1:
 if(pad == 2 && SPEED <= 99)
 {
 SPEED ++;
 }
 if(pad == 3 && SPEED >= 2)
 {
 SPEED --;
 }
 lcd.setCursor(0, 0);
 lcd.print("Speed          ");
 lcd.setCursor(0, 1);
 lcd.print(SPEED);
 break;
 case 2:
 if(pad == 2 && BRIGHTNESS <= 254)
 {
 BRIGHTNESS ++;
 }
 if(pad == 3 && BRIGHTNESS >= 1)
 {
 BRIGHTNESS --;
 }
 lcd.setCursor(0, 0);
 lcd.print("Brighness      ");
 lcd.setCursor(0, 1);
 lcd.print(BRIGHTNESS);
 break;
 case 3:
 if(pad == 2 && HUESPEED <= 1.0)
 {
 HUESPEED += .01;
 }
 if(pad == 3 && HUESPEED >= .01)
 {
 HUESPEED -= .01;
 }
 lcd.setCursor(0, 0);
 lcd.print("HueSpeed       ");
 lcd.setCursor(0, 1);
 lcd.print(HUESPEED);
 break;
 case 4:
 if(pad == 2)
 {
 COLPAL ++;
 if(COLPAL == MAXCOLPAL)
 {
 COLPAL = 0;
 }
 }
 if(pad == 3)
 {
 COLPAL --;
 if(COLPAL == -1)
 {
 COLPAL = MAXCOLPAL - 1;
 }
 }
 switch(COLPAL)
 {
 case 0:
 COLPALNAME = "a              ";
 break;

 case 1:
 COLPALNAME = "b              ";
 break;

 case 2:
 COLPALNAME = "c              ";
 break;
 }
 lcd.setCursor(0, 0);
 lcd.print("Palate         ");
 lcd.setCursor(0, 1);
 lcd.print(COLPALNAME);
 break;
 }
 }
}

void WaterNoise()
{
 static float ihue = 0;
 for(int i = 0; i < MAX_DIMENSION; i++)
 {
 int ioffset = SCALE * i;
 for(int j = 0; j < MAX_DIMENSION; j++)
 {
 int joffset = SCALE * j;
 noise[i][j] = inoise8(x + ioffset, y + joffset, z);
 }
 }
 z += SPEED;
 for(int i = 0; i < kMatrixWidth; i++)
 {
 for(int j = 0; j < kMatrixHeight; j++)
 {
 switch(COLPAL)
 {
 case 0:
 leds[XY(i, j)] = CHSV(ihue + noise[j][i], 255, noise[i][j]);
 break;

 case 1:
 leds[XY(i, j)] = CHSV(ihue + (noise[j][i] >> 1), 255, noise[i][j]);
 break;

 case 2:
 leds[XY(i, j)] = CHSV(noise[j][i], 255, noise[i][j]);
 break;
 }
 }
 }
 ihue += HUESPEED;
 LEDS.show();
}

uint16_t XY( uint8_t x, uint8_t y)
{
 uint16_t i;

 if( kMatrixSerpentineLayout == false)
 {
 i = (y * kMatrixWidth) + x;
 }

 if( kMatrixSerpentineLayout == true)
 {
 if( y & 0x01)
 {
 // Odd rows run backwards
 uint8_t reverseX = (kMatrixWidth - 1) - x;
 i = (y * kMatrixWidth) + reverseX;
 }
 else
 {
 // Even rows run forwards
 i = (y * kMatrixWidth) + x;
 }
 }
 return i;
}

…Thanx in advance for any help

Original Working fire lamp code, it exceeded the original post size limit:

#include <FastLED.h>
#include <Wire.h>
#include <GroveMultiTouch.h>
#include <rgb_lcd.h>

#define LED0_PIN     2
#define LED1_PIN     4
#define LED2_PIN     6
#define CLOCK0_PIN   3
#define CLOCK1_PIN   5
#define CLOCK2_PIN   7
#define CHIPSET     WS2801
#define NUM_STRIPS   3
#define NUM_LEDS    32
CRGB leds[NUM_STRIPS][NUM_LEDS];
CRGBPalette16 gPal;

int COOLING = 75;
int SPARKING = 30;
int LOGS = 3;
int BRIGHTNESS = 128;
int FRAMES_PER_SECOND = 50;

int menumode = 0;
int COLPAL = 0;
#define MAXMENUMODE 6
#define MAXCOLPAL 12

String COLPALNAME = "Hello          ";
rgb_lcd lcd;
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;

GroveMultiTouch feelers(8);
boolean padTouched[4];
boolean wastouched = true;
static unsigned long last_touched_time = 0;
long previousMillis = 0;

void setup()
{
	delay(3000); // sanity delay
	FastLED.addLeds<CHIPSET, LED0_PIN, CLOCK0_PIN>(leds[0], NUM_LEDS).setCorrection( TypicalLEDStrip );
	FastLED.addLeds<CHIPSET, LED1_PIN, CLOCK1_PIN>(leds[1], NUM_LEDS).setCorrection( TypicalLEDStrip );
	FastLED.addLeds<CHIPSET, LED2_PIN, CLOCK2_PIN>(leds[2], NUM_LEDS).setCorrection( TypicalLEDStrip );
	FastLED.setBrightness(BRIGHTNESS);
	
	gPal = HeatColors_p;
	
	Wire.begin(); // needed by the GroveMultiTouch lib
	lcd.begin(16, 2);
	lcd.setRGB(colorR, colorG, colorB);
	feelers.initialize(); // initialize the feelers
	for(int i = 0; i <= 3; i++)
	{
		padTouched[i] = false;
	}
}

void loop()
{
	// Add entropy to random number generator; we use a lot of it.
	random16_add_entropy( random());
	unsigned long currentMillis = millis();

	if (currentMillis - last_touched_time > 5000UL)
	{
		if(wastouched)
		{
			lcd.setCursor(0, 0);
			lcd.print("Run Time       ");
			lcd.setCursor(0, 1);
			lcd.print("               ");
			wastouched = false;
		}
		lcd.setCursor(0, 1);
		lcd.print(millis() / 1000);
	}

	feelers.readTouchInputs(); // test read the touch sensors
	for(int i = 0; i <= 3; i++)
	{
		if(feelers.getTouchState(i))
		{
			if(!padTouched[i])
			{
				//Serial.print(i);
				//Serial.println(" +");
			}
			padTouched[i] = true;
			touched(i);
		}
		else
		{
			if(padTouched[i])
			{
				//Serial.print(i);
				//Serial.println(" -");
			}
			padTouched[i] = false;
		}
	}

	Fire2012WithPalette();
	FastLED.setBrightness(BRIGHTNESS);
}

void touched(int pad)
{
	unsigned long touched_time = millis();
	if (touched_time - last_touched_time > 200)
	{
		last_touched_time = touched_time;
		wastouched = true;
		lcd.setCursor(0, 1);
		lcd.print("                ");
		if(pad == 0)
		{
			menumode ++;
			if(menumode == MAXMENUMODE)
			{
				menumode = 0;
			}
		}
		if(pad == 1)
		{
			menumode --;
			if(menumode == -1)
			{
				menumode = MAXMENUMODE - 1;
			}
		}
		switch(menumode)
		{
			case 0:
				if(pad == 2 && COOLING <= 199)
				{
					COOLING ++;
				}
				if(pad == 3 && COOLING >= 1)
				{
					COOLING --;
				}
				lcd.setCursor(0, 0);
				lcd.print("Cooling        ");
				lcd.setCursor(0, 1);
				lcd.print(COOLING);
				break;
			case 1:
				if(pad == 2 && SPARKING <= 199)
				{
					SPARKING ++;
				}
				if(pad == 3 && SPARKING >= 1)
				{
					SPARKING --;
				}
				lcd.setCursor(0, 0);
				lcd.print("Sparking       ");
				lcd.setCursor(0, 1);
				lcd.print(SPARKING);
				break;
			case 2:
				if(pad == 2 && BRIGHTNESS <= 254)
				{
					BRIGHTNESS ++;
				}
				if(pad == 3 && BRIGHTNESS >= 1)
				{
					BRIGHTNESS --;
				}
				lcd.setCursor(0, 0);
				lcd.print("Brighness      ");
				lcd.setCursor(0, 1);
				lcd.print(BRIGHTNESS);
				break;
			case 3:
				if(pad == 2 && FRAMES_PER_SECOND <= 99)
				{
					FRAMES_PER_SECOND ++;
				}
				if(pad == 3 && FRAMES_PER_SECOND >= 9)
				{
					FRAMES_PER_SECOND --;
				}
				lcd.setCursor(0, 0);
				lcd.print("FPS            ");
				lcd.setCursor(0, 1);
				lcd.print(FRAMES_PER_SECOND);
				break;
			case 4:
				if(pad == 2)
				{
					COLPAL ++;
					if(COLPAL == MAXCOLPAL)
					{
						COLPAL = 0;
					}
				}
				if(pad == 3)
				{
					COLPAL --;
					if(COLPAL == -1)
					{
						COLPAL = MAXCOLPAL - 1;
					}
				}
				switch(COLPAL)
				{
					case 0:
						COLPALNAME = "Heat Colors PAL";
						gPal = HeatColors_p;
						break;

					case 1:
						COLPALNAME = "Random MultiHUE";
						// @ 'if (COLPAL==1)' in void Fire2012WithPalette
						break;

					case 2:
						COLPALNAME = "Lava Colors PAL";
						gPal = LavaColors_p;
						break;

					case 3:
						COLPALNAME = "Red / YellowPAL";
						gPal = CRGBPalette16(CRGB::Black, CRGB::Red, CRGB::Yellow, CRGB::Orange);
						break;

					case 4:
						COLPALNAME = "Blue / Aqua PAL";
						gPal = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua,  CRGB::White);
						break;

					case 5:
						COLPALNAME = "Simple Fire PAL";
						gPal = CRGBPalette16( CRGB::Black, CRGB::Red, CRGB::White);
						break;
					
					case 6:
						COLPALNAME = "PartyColors PAL";
						gPal = PartyColors_p;
						break;
						
					case 7:
						COLPALNAME = "RainbowColorPAL";
						gPal = RainbowColors_p;
						break;
						
					case 8:
						COLPALNAME = "RainbowStripPAL";
						gPal = RainbowStripeColors_p;
						break;
						
					case 9:
						COLPALNAME = "CloudColors PAL";
						gPal = CloudColors_p;
						break;
						
					case 10:
						COLPALNAME = "OceanColors PAL";
						gPal = OceanColors_p;
						break;
						
					case 11:
						COLPALNAME = "ForestColorsPAL";
						gPal = ForestColors_p;
						break;
				}
				lcd.setCursor(0, 0);
				lcd.print("Palate         ");
				lcd.setCursor(0, 1);
				lcd.print(COLPALNAME);
				break;
			case 5:
				if(pad == 2 && LOGS <= 15)
				{
					LOGS ++;
				}
				if(pad == 3 && LOGS >= 2)
				{
					LOGS --;
				}
				lcd.setCursor(0, 0);
				lcd.print("Logs           ");
				lcd.setCursor(0, 1);
				lcd.print(LOGS);
				break;
		}
	}
}

void Fire2012WithPalette()
{
	static byte heat[NUM_STRIPS][NUM_LEDS];
	static float hue0 = 0, hue1 = 0, hue2 = 0;
	//For mode 1
	if (COLPAL == 1)
	{
		hue0 += random8(1, 8);
		hue1 += random8(2, 8);
		hue2 += random8(3, 8);
		CRGB darkcolor  = CHSV(hue2, 255, 128); // pure hue, three-quarters brightness
		CRGB midcolor   = CHSV(hue1, 192, 192);
		CRGB lightcolor = CHSV(hue0, 128, 255); // half 'whitened', full brightness
		gPal = CRGBPalette16( CRGB::Black, darkcolor, midcolor, lightcolor);
	}
	for(int x = 0; x < NUM_STRIPS; x++)
	{
		// Step 1.  Cool down every cell a little
		for( int i = 0; i < NUM_LEDS; i++)
		{
			heat[x][i] = qsub8( heat[x][i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
		}

		// Step 2.  Heat from each cell drifts 'up' and diffuses a little
		for( int k = NUM_LEDS - 1; k >= 2; k--)
		{
			heat[x][k] = (heat[x][k - 1] + heat[x][k - 2] + heat[x][k - 2] ) / 3;
		}

		// Step 3.  Randomly ignite new 'sparks' of heat near the bottom
		if( random8() < SPARKING )
		{
			int y = random8(LOGS);
			heat[x][y] = qadd8( heat[x][y], random8(100, 255) );
		}

		// Step 4.  Map from heat cells to LED colors
		for( int j = 0; j < NUM_LEDS; j++)
		{
			// Scale the heat value from 0-255 down to 0-240
			// for best results with color palettes.
			byte colorindex = scale8( heat[x][j], 240);
			leds[x][j] = ColorFromPalette( gPal, colorindex);
		}
	}
	//FastLED.show();
	FastLED.delay(1000 / FRAMES_PER_SECOND);
}

Normally that kind of thing is a symptom of running out of SRAM. What does the compiler say your global variable usage is?

I can't see any obvious problems, like declaring an array of 1000 integers but there may be something lurking in the libraries.

The usual fix, if you're only just out of memory, is to put any strings longer than 4-5 chars into the flash memory:

Serial.println(F("This is a long string"));

But then I looked at what you're doing with capital-S Strings. This doesn't look right. I'm not sure if this will do what you think it should do.

XxDILBERTxX:
Original Working fire lamp code, it exceeded the original post size limit:

You can attach code to posts.

How to use this forum

Where did you get those libraries from?

uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];

I see 1024 bytes gone right there. Out of 2048 if you are using a Uno.

All but the GroveMultiTouch are included on codebender.cc
GroveMultiTouch is from Seeedstudios (Grove) for the I2C multitouch sensor

/*
 GroveMultiTouch.h - Library for the Grove I2C Touch Sensor
 Created by Wendell A. Capili, August 27, 2011.
 
 Code adapted from:
 http://bildr.org/2011/05/mpr121_arduino/ 
 
 Released into the public domain.
 */


#ifndef GroveMultiTouch_h
#define GroveMultiTouch_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Wire.h>

class GroveMultiTouch {
    public:
    //GroveMultiTouch(int irqPin, TwoWire &wire);    
    GroveMultiTouch(int irqPin);
    void initialize();
    void readTouchInputs();
    boolean getTouchState(int pad);
    
    private:
    //TwoWire* _wire;
    int _irqPin;
    boolean _touchStates[12];
    void mpr121_setup();
    boolean checkInterrupt();
    void set_register(int address, unsigned char r, unsigned char v);
};

#endif

As for the global variable issue i don’t see that info anywhere on codebender. cant find my RaspberryPi at the moment have the IDE and libs on that…

And by “capital-S Strings” are you talking about COLPALNAME or all my capital Vars?

Sorry… only familiar with various programming codes but not very good at how to do it

Bingo! I missed that one. That's what I was expecting to find in the "obvious" category.

Thanks its working now…You Guys Rock!

i didn’t really look at it… thought it was just a 3x32 grid… like it is now.

uint8_t noise[kMatrixWidth][kMatrixHeight];

by the way what was it adding up to and how? if you don’t mind explaining that a bit…
((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)

by the way what was it adding up to and how? if you don't mind explaining that a bit..
((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight)

The ? in C denotes a conditional, the following : is the else, so its equivalent of typing this:

if( kMatrixWidth>kMatrixHeight )
  kMatrixWidth;
else
  kMatrixHeight;

In your example, it takes the largest size in either direction, and anywhere MAX_DIMENSION is used, gives that size. So you have a single byte per element array of size 32*32.

32321 = 1024 bytes.