Adafruit Pro Trinket
Posted: Fri Jun 10, 2016 5:44 pm
Hi All
Just a FYI, i am planning to use a Adafruit Pro Trinket 5v instead of the teensy only because thats what i currently have with me.
Works ok, have modded the PCB and works with the code below, works but not too pretty.
Just follow the tutorial on the adafruit pages https://learn.adafruit.com/pro-trinket- ... d/examples
Still need to mod the case for the extra buttons.
/*
ProTrinketKeyboard example
For Pro Trinket (ATmega328 based Trinket) by Adafruit Industries
Please use library TrinketKeyboard for the ATtiny85 based Trinket
Version 1.0 2015-01-01 Initial Version derived from TrinketKeyBoardExample Mike Barela
*/
#include <ProTrinketKeyboard.h> // Ensure the library is installed
// Switches are connected from ground to these defined pins
const int PIN_BUTTON_p = 3;
const int PIN_BUTTON_l = 4;
const int PIN_BUTTON_w = 5;
const int PIN_BUTTON_s = 6;
const int PIN_BUTTON_a = 8;
const int PIN_BUTTON_d = 9;
const int PIN_BUTTON_x = 11;
const int PIN_BUTTON_z = 12;
void setup()
{
// Declare button pins as inputs
pinMode(PIN_BUTTON_p, INPUT);
pinMode(PIN_BUTTON_l, INPUT);
pinMode(PIN_BUTTON_w, INPUT);
pinMode(PIN_BUTTON_s, INPUT);
pinMode(PIN_BUTTON_a, INPUT);
pinMode(PIN_BUTTON_d, INPUT);
pinMode(PIN_BUTTON_x, INPUT);
pinMode(PIN_BUTTON_z, INPUT);
pinMode(13, OUTPUT);
// setting input pins to high means turning on internal pull-up resistors
digitalWrite(PIN_BUTTON_p, HIGH);
digitalWrite(PIN_BUTTON_l, HIGH);
digitalWrite(PIN_BUTTON_w, HIGH);
digitalWrite(PIN_BUTTON_s, HIGH);
digitalWrite(PIN_BUTTON_a, HIGH);
digitalWrite(PIN_BUTTON_d, HIGH);
digitalWrite(PIN_BUTTON_x, HIGH);
digitalWrite(PIN_BUTTON_z, HIGH);
// remember, the buttons are active-low, they read LOW when they are not pressed
// start USB stuff
TrinketKeyboard.begin();
}
void loop()
{
TrinketKeyboard.poll();
// the poll function must be called at least once every 10 ms
// or cause a keystroke
// if it is not, then the computer may think that the device
// has stopped working, and give errors
if (digitalRead(PIN_BUTTON_p) == LOW)
{
TrinketKeyboard.print("p");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_l) == LOW)
{
TrinketKeyboard.print("l");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_w) == LOW)
{
TrinketKeyboard.print("w");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_s) == LOW)
{
TrinketKeyboard.print("s");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_a) == LOW)
{
TrinketKeyboard.print("a");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_d) == LOW)
{
TrinketKeyboard.print("d");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_x) == LOW)
{
TrinketKeyboard.print("x");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_z) == LOW)
{
TrinketKeyboard.print("z");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
}
Just a FYI, i am planning to use a Adafruit Pro Trinket 5v instead of the teensy only because thats what i currently have with me.
Works ok, have modded the PCB and works with the code below, works but not too pretty.
Just follow the tutorial on the adafruit pages https://learn.adafruit.com/pro-trinket- ... d/examples
Still need to mod the case for the extra buttons.
/*
ProTrinketKeyboard example
For Pro Trinket (ATmega328 based Trinket) by Adafruit Industries
Please use library TrinketKeyboard for the ATtiny85 based Trinket
Version 1.0 2015-01-01 Initial Version derived from TrinketKeyBoardExample Mike Barela
*/
#include <ProTrinketKeyboard.h> // Ensure the library is installed
// Switches are connected from ground to these defined pins
const int PIN_BUTTON_p = 3;
const int PIN_BUTTON_l = 4;
const int PIN_BUTTON_w = 5;
const int PIN_BUTTON_s = 6;
const int PIN_BUTTON_a = 8;
const int PIN_BUTTON_d = 9;
const int PIN_BUTTON_x = 11;
const int PIN_BUTTON_z = 12;
void setup()
{
// Declare button pins as inputs
pinMode(PIN_BUTTON_p, INPUT);
pinMode(PIN_BUTTON_l, INPUT);
pinMode(PIN_BUTTON_w, INPUT);
pinMode(PIN_BUTTON_s, INPUT);
pinMode(PIN_BUTTON_a, INPUT);
pinMode(PIN_BUTTON_d, INPUT);
pinMode(PIN_BUTTON_x, INPUT);
pinMode(PIN_BUTTON_z, INPUT);
pinMode(13, OUTPUT);
// setting input pins to high means turning on internal pull-up resistors
digitalWrite(PIN_BUTTON_p, HIGH);
digitalWrite(PIN_BUTTON_l, HIGH);
digitalWrite(PIN_BUTTON_w, HIGH);
digitalWrite(PIN_BUTTON_s, HIGH);
digitalWrite(PIN_BUTTON_a, HIGH);
digitalWrite(PIN_BUTTON_d, HIGH);
digitalWrite(PIN_BUTTON_x, HIGH);
digitalWrite(PIN_BUTTON_z, HIGH);
// remember, the buttons are active-low, they read LOW when they are not pressed
// start USB stuff
TrinketKeyboard.begin();
}
void loop()
{
TrinketKeyboard.poll();
// the poll function must be called at least once every 10 ms
// or cause a keystroke
// if it is not, then the computer may think that the device
// has stopped working, and give errors
if (digitalRead(PIN_BUTTON_p) == LOW)
{
TrinketKeyboard.print("p");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_l) == LOW)
{
TrinketKeyboard.print("l");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_w) == LOW)
{
TrinketKeyboard.print("w");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_s) == LOW)
{
TrinketKeyboard.print("s");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_a) == LOW)
{
TrinketKeyboard.print("a");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_d) == LOW)
{
TrinketKeyboard.print("d");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_x) == LOW)
{
TrinketKeyboard.print("x");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
if (digitalRead(PIN_BUTTON_z) == LOW)
{
TrinketKeyboard.print("z");
digitalWrite(13, HIGH);
// this should type a capital A
TrinketKeyboard.pressKey(0, 0);
digitalWrite(13, LOW);
// this releases the key
}
}