Go Down

Topic: OS X Lion - Serial Monitor breaks code - seems to reset rather than loop (Read 848 times) previous topic - next topic

robsta

Hi all,

As with most users, I'm new to Arduino.

I do, however, have a background in programming.

I am basically having a problem whereby I can successfully deploy to my Uno (R3), and basic inputs work when running solo (not attempting Serial.write's). When I attempt to open the Serial Monitor (or Processing, separately, of course), it seems to run through to the end of loop() and reset the device.

I'm on OS X Lion (10.7) and have tried the upgraded FTDI driver to 64bit (both with and without uninstall), I've tried the loop-back test (which returns successfully any entered text), tried editing the code to remove all other issues (TXRX lights switch off).

This is really frustrating as I obviously cannot debug code, and will also ultimately disable any projects that interact with a computer (the reason I bought into Arduino).

As I know we cannot post personal project stuff into this section of the forum, I have written a small test app (below) that flashes the TX light until I open the Serial monitor, whereby nothing flashes any longer (have tried with and without the !bTest section incase my logic is wrong (C# background on .NetCF) ).

Code: [Select]
boolean bTest;
String sTest;

void setup()
{
 bTest = true;
 Serial.begin(9600);
 delay(5000);
 sTest = "True";
}

void loop()
{
 if(bTest)
 {
   sTest = "True";
 }
 else
 {
   sTest = "False";
 }
 
 Serial.write(sTest);
 delay(1000);
 bTest = !bTest;
}


Please help as the hours spent trying to solve this problem are causing me a real headache.

Many thanks in advance,

Rob

robsta

P.s. Also tried some fix I read with adding the java jar "RXTXComm.jar" and "librxtxSerial.jnilib" to relevant Java extensions folder, however, this just prevented me from deploying to the Uno whatsoever.

Also, when installing the FTDI install is apparently supposed to return two devices when 'ls -l' (ing) the /dev/ folder, and mine returns nothing.

Many thanks in advance,

Rob

James C4S

1.  FTDI drivers have nothing to do with the Uno.  There isn't a FTDI chip.
2.  I think you want Serial.println() and not Serial.write().

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

robsta

Hi James,

Thank you for your swift response...

The changes you offered seem to have fixed the example above. It does seem, however, that any code including components attached seem to fail. Apologies in advance for posting 'real project code' now, but I have a PIR attached at V5, GND and D12, with which the code works flawlessly in standalone, but seems to reset the Uno after the loop when Serial Monito is open.

Code: [Select]
int ledPin = 13;
int switchPin = 12;
int value = 0;
boolean bShouting;

void setup()
{
 pinMode(ledPin, OUTPUT);
 pinMode(switchPin, INPUT);
 Serial.begin(9600);
 bShouting = false;
}
   
void loop()
{
     
 value = digitalRead(switchPin);
 if(bShouting == false)
 {
   if (HIGH == value) {
     digitalWrite(ledPin, LOW);
     Serial.println("High\n");
     bShouting = true;
   }
   else
   {
     digitalWrite(ledPin, HIGH);
     Serial.println("Low\n");
   }
 }
 
 if(bShouting == true)
 {
   Serial.println("Shout\n");
   delay(6000);
   bShouting = false;
 }
}


So I see the LED @ 13 switch off at PIR recognition (HIGH) without the Serial Monitor open, however, I get a loop through approx 10 'Low' Serial 'prints' followed by 1 'High' and obviously 1 'Shout' before what appears to be a reset.

Basically, the PIR is not actually functioning, just the loop of the above results; until Serial Monitor is closed again, that is.

All the best,

Rob

James C4S

PIRs are generally open collector. Are you using its output with a pull-up resistor?
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up