Serial monitor behaviour

Hi

I am attempting to develop a library, I think my serial monitor is showing or even potentially causing resets from the loop of the test sketch. The test sketch for the library looks like this.

#include <Lightman.h>
#include <Bridge.h>
#include <Console.h>
#include "Tlc5940.h"

Lightman larray;

void setup() {
  // put your setup code here, to run once:
  Bridge.begin();
  Console.begin();  // Initialize Console
  while (!Console) ;
  delay(3000);
  if (Console) Console.println("Lightman tester console");
  Tlc.init(500);
  delay(5000);
}

void loop() {
  // put your main code here, to run repeatedly:
  
  

  larray.set_light(0,0,0,2000);
  //larray.set_light(12,0,0,2000);

  //larray.set_curve();
  larray.display_all();

  delay(5000);
  if (Console) Console.println("end of loop");

The sketch references this library

#include "Arduino.h"
#include "Lightman.h"
#include "Tlc5940.h"
#include "Console.h"

#define LIGHTMAN_PARAMETER_COUNT 6
#define NUMBER_OF_LIGHTS 16
#define NUMBER_OF_COLOURS 3
int lights[NUMBER_OF_LIGHTS*NUMBER_OF_COLOURS][LIGHTMAN_PARAMETER_COUNT] = {0};

Lightman::Lightman()
{
//make an array of all the lights
//light	Current_Red Current_Green Current_Blue Start_Red Start_Green Start_Blue End_Red End_Green End_Blue Cycles Curve CurveParameter
//start all brightnesses, starts, ends and Curves at 0	
	
 

}

void Lightman::set_curve(  ) //array of integers to sub into lightmants master array
{
	if (Console) Console.println("Called set_curve");
	
	//for each line in the parameter array
	//put it in the right spot 
    
 
}

void Lightman::set_light(int light_no, int R, int G, int B) //
{
  if (Console) Console.println("Called set_light");
  
  lights[light_no][0] = R;
  lights[light_no][1] = G;
  lights[light_no][2] = B;
  
}

void Lightman::cycle() {
	int l;
	int c;
	
	
	for (l = 0; l<= NUMBER_OF_LIGHTS; l+=1) {
		for (c=0; c<=NUMBER_OF_COLOURS; c+=1) {}
		
	}
	
}

void Lightman::display_all() {
	int testint1;
	int testint2;
	int li;
	
	for (li = 0; li <= NUMBER_OF_LIGHTS*NUMBER_OF_COLOURS-1; li+=1) {
		testint1 = li%NUMBER_OF_LIGHTS;
		testint2 = li/NUMBER_OF_LIGHTS;
		
		//if (Console) Console.println(testint1);
		//if (Console) Console.println(testint2);
		//if (Console) Console.println(lights[li%NUMBER_OF_LIGHTS][li/NUMBER_OF_LIGHTS]);
		
		//if (Console) Console.println("light");	
		//if (Console) Console.println(testint1);
		//if (Console) Console.println("Colour");
		//if (Console) Console.println(testint2);
		//if (Console) Console.println("Setting in 5 seconds");
		delay(5000);
		
		//Tlc.set(li,lights[li%NUMBER_OF_LIGHTS][li/NUMBER_OF_LIGHTS]);
		//if (Console) Console.println("Updating in 5 seconds");
		//delay(5000);
		
		
		//Tlc.update(); 	
		//if (Console) Console.println("Done");	
	}
	
}

When I upload the sketch, I open the console, I am connected over Wifi to the Yun and open the consoel by selecting “serial monitor” from the tools menu. (this is required for the setup code to continue running in the test sketch) - By the way, i am a little confused by this as well - is this the console or serial monitor - I do not have the usb or lan cable plugged in, so I am assuming it is infact the console.

The console will give readouts such as

Lightman tester console
Connection closed by foreign host

or occasionally it will get further into the test sketch:

Lightman tester console
Called set_light
0
0
Connection closed by foreign host

I have followed the advice here http://forum.arduino.cc/index.php?topic=190769.0

However the Arduino continues to dropout. Any help would be greatly appreciated.

Thanks in advance
Lawrie

I'd try this.

In your test sktech and library sketch, change all commands

if (Console) Console.println("(whatever)");

for

println("(whatever)");

Just to check if the Console objetc is doing the resets.

Hi Mart

Thanks for such a quick response. I’ve replaced all the console commands to serial println commands

The test sketch behaves as expected (however I have to plug it in with USB to pick up the serial.println commands) I assume this is normal behaviour

What does this mean for the console though - it seems like this indicates that it is infact the console which is resetting the Yun

Thanks
Lawrie