Thermal Printer + Processing - breaks every third time

Hi,

I’m absolutely flummoxed.

I’ve a thermal printer connected to my Uno and its talking to Processing. This is the tutorial that I’ve used to connect them Connecting Arduino to Processing - learn.sparkfun.com

For my project, I’m playing an audio track. When it reaches 10 seconds, I send a character to Arduino to print something, when it reach 20 seconds I send a command to print something else, and the same when it reaches 35 seconds.

So, track begins to play, 10 seconds == print, 20 seconds == print, 35 seconds == print.

This process works fine for the first two times, but on the third time it doesn’t get past the 20 second mark.

I have no idea what is it wrong with it. I’m putting a delay(2000); in each time I print.

I’m using the Adafruit Thermal Printer Library

These code extracts will give you an idea of how I’m controlling the printing process:

Processing code: posRound is the amount of seconds that have passed in the track

if(posRound == 20){
      println("its 20 seconds in");
      println("print again");
      myPort.write('6');
    }

Arduino Code:

if(val == '6'){
      printer.wake();
      printer.begin();
      digitalWrite(LED_13, HIGH);
      //PRINT STORY
      printer.setSize('S');
      printer.println("Keep churning!");
      delay(2000);
      Serial.write(firstSensor);
      Serial.write(encoderValue);
      Serial.write(thirdSensor);
      
      //printer.feed(3);
      
      printer.sleep();
      digitalWrite(LED_13, LOW);
      RFIDReader.begin(RFIDSerialRate);
    }

If anyone has any ideas I’d love to hear of them!

Please post the whole code as that helps to diagnose it Also add links to the libraries used (as not everyone has the same libs)

Ok, I didn’t post the code first because there is lots of it there.

The thermal printer library I’m using : GitHub - adafruit/Adafruit-Thermal-Printer-Library: Arduino Library for Small Thermal Printers

I can’t post the code because it exceeds the maximum allowed length, so I’ll attach both the arduino and the Processing files and I’ll leave a link to a pastebin of them too:

Arduino http://pastebin.com/qGWxwNFh
Processing http://pastebin.com/sDwFM1Jh

churn_printer_test_3.ino (14 KB)

churn_minim_rfid_2.pde (8.1 KB)

Right,

I still don't know for certain what was causing the issue, but I recon that may have been with what I was trying to print on the Thermal Printer.

So I was trying to print strings like this :

String story5_link = "http://goo.gl/PPNj57";

So I took that line out. Like, I'm still having problems, but less frequently.