Trinket Auto Greeter

DSC_0204web

Do you ever struggle writing the opening to an E-Mail or IM destined for friend or colleague? Before you know it you are deep in to the psychological meanings behind the words “Hi” and “Hello” or any other greeting for that matter. Often times you might even find yourself regretting the message you just sent or cease developing the message right from the beginning altogether.

The Trinket Auto-Greeter, or TAG for short, will put an end to all that. It emulates a USB keyboard and at the push of a convenient foot switch, one of several greetings will be chosen at random and typed to the cursor on your screen. If you are using an IM client, the message will be sent automatically since a return/enter key press is sent post-greeting.

DSC_0199web

The code, written in the Arduino IDE for the Adafruit Trinket, is also very easy to implement for other uses as well. In fact, the only reason greetings were chose was because of the catchy acronym “Trinket Auto-Greeter” makes. For example, you could replace the list of greetings for a list of farewells, factoids, or emoticons. I encourage you to try it for yourself:

/*
 Trinket Auto Greeter (TAG)
 
 Take all the hesitation and guesswork out of 
 opening an email or starting a chat conversation 
 with the Trinket Auto Greeter (TAG)!
 
 At the push of a button one of dozens of possible 
 greetings will be chosen and typed (and sent if 
 using an IM client) for you at your cursor's 
 current location.
 
 Special thanks to the Adafruit learning system.
 
 Visit thestuffwebuild.com for more.
 */

#include <TrinketKeyboard.h>

#define PIN_BUTTON_STRING 0

// we'll use the built in red LED as a debug LED
int led = 1; 

//Number of GREETINGS
const byte NUMBER_OF_GREETINGS = 20; 

//List of GREETINGS
char* greeting[NUMBER_OF_GREETINGS] = {
  "Ahoy ",
  "G'day ",
  "Good evening ",
  "Good morning ",
  "Greetings ",
  "Hello ",
  "Hello there ",
  "Hey ",
  "Hi ",
  "Hi there ",
  "How are you? ",
  "Hi, how are you? ",
  "How are you doing? ",
  "Howdy ",
  "Salutations ",
  "What's up? ",
  "How is everything? ",
  "How's everything going? ",
  "What's cracking? ",
  "How've you been? ",
};

void setup()
{
  // button pins as inputs
  pinMode(PIN_BUTTON_STRING, INPUT);

  // setting input pins to high means turning on internal pull-up resistors
  digitalWrite(PIN_BUTTON_STRING, HIGH);
  // remember, the buttons are active-low, they read LOW when they are not pressed

  // start USB stuff
  TrinketKeyboard.begin();

  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

void loop()
{
  // the poll function must be called at least once every 10ms
  // or cause a keystroke
  // if it is not, then the computer may think that the device
  // has stopped working, and give errors
  TrinketKeyboard.poll();

  if (digitalRead(PIN_BUTTON_STRING) == LOW)
  {
    // turn debug LED on 
    digitalWrite(led, HIGH); 

    // type out a string using the Print class
    // removing 'ln' from 'println' will not not send a return key press
    TrinketKeyboard.println(greeting[random(0,NUMBER_OF_GREETINGS)]);

    // delay for 500ms so we don't spam the screen 
    for(int i=0; i<50; i++){
      TrinketKeyboard.poll();
      delay(10);
    }
    // turn debug LED off
    digitalWrite(led, LOW);
  }
}

 

One thought on “Trinket Auto Greeter”

Leave a Reply

Your email address will not be published. Required fields are marked *