Go Down

Topic: Button used to trigger thermal printer sketch in installation. (Read 136 times) previous topic - next topic

andozz93

I am trying to make an installation for my final year degree show.

The project is called 'Politics Is Rubbish' and is a future design/ critical design project. The main jist is as follows:

What if all receipts had a political debate printed on the bottom of them, and special recipt bins were able to measure if people agreed or disagreed with the debate (by having Yes and No slots in the bins).

i have been able to make the Thermal printer actually print what I want it too, but to make it an interactive installation I want to add a button so when someone presses it they can print out a receipt and choose if they agree or disagree with the statement.

This seems like it should be really simple but I'm an absolute novice. After speaking to various people they suggested putting the 'Thermal Printer' sketch within an 'If' statement of a button press. However I just can't make it work. i've managed to make an LED switch on an off but can't translate that into triggering the thermal printer sketch.

Am I searching for the wrong terminology or is it so simple that it's never covered in tutorials?

This is the switch I'm trying to use: http://www.maplin.co.uk/p/vandal-resistant-switch-mg74r

I have a bread board, many jump wires, resistors and LED's at the ready, and have been using the Adafruit thermal printer sketches as a template.

This is the Thermal Printer sketch I want to trigger when the button is pressed

Code: [Select]
// If you're using Arduino 1.0 uncomment the next line:
#include "SoftwareSerial.h"
// If you're using Arduino 23 or earlier, uncomment the next line:
//#include "NewSoftSerial.h"

#include "Adafruit_Thermal.h"
#include "ahlogo.h"
#include "pirlogo.h"
#include "adaqrcode.h"
#include <avr/pgmspace.h>

int printer_RX_Pin = 5;  // This is the green wire
int printer_TX_Pin = 6;  // This is the yellow wire

Adafruit_Thermal printer(printer_RX_Pin, printer_TX_Pin);

void setup(){
  Serial.begin(19200);
  pinMode(7, OUTPUT); digitalWrite(7, LOW); // To also work w/IoTP printer
  printer.begin();

  // The following is what I have printing out when I run the sketch, this includes the Politics is Rubbish logo.
  // The repeated asterisks are purely there for decoration

  // Print 250x250 logo
                                        printer.justify('C'); printer.printBitmap(pirlogo_width, pirlogo_height, pirlogo_data);
                                     
                                       printer.justify('C');
                                                            printer.println("********************");
                                         
                                       
                                        printer.doubleHeightOn();  printer.justify('C');
                                        printer.println("Politics is Rubbish");
                                        printer.doubleHeightOff();
                                     
                                      printer.justify('C');
                                                            printer.println("********************");
                                     
                                                            printer.justify('C');
                                                            printer.println("What if you turn an every day");
                                                           
                                                             printer.justify('C');
                                                            printer.println("object into a a dialogue ");
                                                           
                                                            printer.justify('C');
                                                            printer.println("about politics?");
                                       
                                        printer.justify('C');
                                                            printer.println("********************");
                                                           
                                          printer.justify('C');
                                        printer.println("What if everytime you threw");
                                            printer.justify('C');
                                        printer.println("a receipt away you were making");
                                              printer.justify('C');
                                        printer.println("a political statement?");
                                       
                                        printer.justify('C');
                                                            printer.println("********************");
                                       
                                            printer.justify('C');
                                        printer.println("What if every receipt");
                                     
                                            printer.justify('C');
                                        printer.println("turns into a vote?");
                                     
                                      printer.justify('C');
                                                            printer.println("********************");
                                                           
                                           printer.justify('C');
                                        printer.println("If every receipt turns into to a conversation about politics it will engage a huge amount");
                                        printer.justify('C');
                                        printer.println("of the population.");
                                     
                                      printer.justify('C');
                                                              printer.println("********************");
                                                           
                                                              printer.boldOn(); printer.justify('C'); printer.doubleHeightOn();
                                                              printer.println("Should we stay in the EU?");

  printer.sleep();      // Tell printer to sleep
  printer.wake();       // MUST call wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
 
}

void loop() {
}



Here's a mock up of what I'm going for. Am I right in thinking that if I can get the button to trigger the thermal printer I can just have the arduino on it's own in the plinth, without needing to have it connected to a computer?


Go Up