Sorry about that, I was trying to make it simple, my bad.
Here is the full code.
The wiring is also pretty simple.
Push button connected to GND and D0
Thermal Printer RX Pin2 and TX Pin5
9v DC is coming in through the DC power jack.
Thanks.
// wrap to 33
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
#include <avr/pgmspace.h>
#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"
#include "lips.h" // Bonfire logo
#define TX_PIN 2 // Arduino transmit YELLOW WIRE labeled RX on printer
#define RX_PIN 5 // Arduino receive GREEN WIRE labeled TX on printer
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
char inchar;
int delimeter = 59; // ";"
long mySelect;
File myFile;
char mydata;
long idx = 0;
const int buttonPin = 0;
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
Serial.begin(9600);
mySerial.begin(19200);
Serial.println("Starting.....");
randomSeed(analogRead(A0));
printer.begin();
printer.setSize('S');
pinMode(buttonPin, INPUT_PULLUP);
SD.begin(10); // initialise the SD card
} // setup
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == 0) {
Serial.println("Somebody pressed the button");
printRandomSentance (24);
}
}//end loop
void printRandomSentance(int num)
{
Serial.print ("\nreading fortune number " +num);
printer.setSize('L');
printer.justify('C');
printer.println("----------------");
printer.println("Chad Fantastic\nFortune Teller");
printer.setSize('S');
printer.justify('L');
printer.println("\n\nChad says....");
printer.setSize('M');
//printer.feed(1);
mySelect = random(1, num);
myFile = SD.open("chad.txt");
while (myFile.available()) {
mydata = (myFile.read());
if (mydata == 59) { // delimeter
mydata = 13; // reset my character
idx++ ; // increment index
}
if (idx == mySelect) {
printer.print(mydata);
Serial.print(mydata);
}
}
myFile.close();
idx = 0;
printer.feed(4);
printer.setSize('S');
printer.justify('C');
printer.printBitmap(lips_width, lips_height, lips_data);
printer.feed(2);
printer.println("--------------------------");
printer.feed(5);
}