Thermal Printer and Pushbutton: Compatible?

Hello :slight_smile:

I'm trying to make the mini thermal printer print a shopping list when a button is pressed on an Arduino Uno board. I am using this mini thermal printer Arduino Code | Mini Thermal Receipt Printer | Adafruit Learning System and this button Rugged Metal Pushbutton with Red LED Ring [16mm Red Momentary] : ID 559 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits. Even though the code does not seem complicated, I somehow don't manage it.

The printertest script works. The button itself works on a simple script with the build-in LED on pin 13 (even though it only dims the brightness, not completely shuts it off). However, in the code below it does not work anymore. I have no idea why, I checked the code a hundred times now. Maybe I just bought an inadequate switch for that purpose? Maybe you can help me. Eternal gratefulness for sure! :wink:

All the best,

#include "SoftwareSerial.h"
#include "Adafruit_Thermal.h" // you need to download this and put it in your Arduino library

int RX_PIN = 6;  // This is the green printer wire
int TX_PIN = 7;  // This is the yellow printer wire
const int buttonPin = 5;     // the number of the pushbutton pin - doesn't change
const int led = 13;
//const int buttonPin = 5;  
int buttonState = 0;         // variable for reading the pushbutton status
int debounce_delay = 300;           // set variables to hold the state of the button
//int prevState = 0;

SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial);     // Pass addr to printer constructor
// Then see setup() function regarding serial & printer begin() calls.

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(led, OUTPUT); 
  Serial.begin(19200);   // this is the baud rate my printer

void loop(){
  // read the state of the button:
   buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    digitalWrite(led, HIGH);
  else {
    digitalWrite(led, LOW);// if you want something to happen when the button is released, put it here
    // such as a beep, or a display saying 'your poem is on its way'

void printList(){

  // put author names & dates here, in order
  printer.println(F("Ingredients for"));
  printer.println(F(" Banana Bread:"));

  printer.println(F("- Flour (200 grams)\n- Banana (150 grams)\n- Sugar (50 grams)\n- Cinnamon (1 gram)"));

  delay(2000);   // 2 second pause to help prevent multiple presses     

How have you got your button wired.
If between 5V and the digital input pin you will need 10K between the pin and gnd to make sure the input goes to gnd when the button is open.

If between gnd and the digital input pin you will need 10K between the pin and 5V to make sure the input goes to 5V when the button is open.

Tom.. :slight_smile:

Hey Tom,
Thank you for your reply.

I wired my button the following way:

LED- to Gnd
LED+ to 3V
C/COM to 5V
NO to pin nbr 5

I am not entirely sure about it. Does it seem correct?

The manual of the button said that it has a built-in resistor, so I didn't add any. Would you recommend to add another one?

Thank you for your help - it is needed a lot :smiley:


Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

Yes, of course thank you :slight_smile:

I hope that’s professional enough :stuck_out_tongue: I really tried :slight_smile:

I attached the picture (is there any better way of posting it?)

All the best,

Hi, thanks.
OPs circuit.

Tom... :slight_smile:

You are switching to 5V, so you need to put a 10K resistor between Pin5 and GND, this will make sure that Pin5 is LOW when the button is not pressed.

Tom... :slight_smile: