I'm using an arduino uno with a thermal printer and the following code:
#include "Adafruit_Thermal.h"
#include "skull.h"
#include "SoftwareSerial.h"
int printer_TX_Pin = 8; // This is the yellow wire
int printer_RX_Pin = 9; // This is the green wire
Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);
void setupPrinter() {
printer.begin();
};
void doPrint(char* output) {
Serial.print("Will print: ");
Serial.print(output);
Serial.print("\n");
printer.println(output);
printer.feed(2);
}
void setup() {
setupPrinter();
doPrint("This is a test to see if it will print only from power supply");
}
void loop() {
}
That code works fine if the arduino and printer are plugged into 5v and the arduino is also plugged in to a computer with USB. Once I remove the USB cable it starts printing:
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
This is a test to see if it will
over and over infinitely. In other programs it prints a slightly garbled first line then stops. When I remove the serial.print lines, this doesn't occur. Why would that be?