Jump to content

Teensey 3.0 Pin Out.


2 replies to this topic

#1 ORIGINAL SteelWolf

    Member

  • PipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 460 posts
  • Google+: Link
  • Facebook: Link
  • Twitter: Link
  • Twitch: Link
  • LocationThe land of ID.

Posted 08 March 2014 - 11:58 PM

Anyone using a Teensey 3.0 for emulation? I've got the program written for the buttons but i am stuck on how to tie the buttons to the board for effect. After i get that figured out its just a matter of drywalling my cockpit or fiberglass. Basing mine off a Battlemaster.
J.



https://www.pjrc.com/teensy/[color=#666666][/color]

#2 Gevurah

    Member

  • PipPipPipPipPipPipPip
  • The Flame
  • The Flame
  • 500 posts

Posted 09 March 2014 - 03:35 PM

I am. Are you using the buttons as a USB keyboard?

Basically you want to run the each pin to ground, it will automatically do the resistor work for you. It's very straightforward, once you get the windows HID mess cleared up.

#3 Gevurah

    Member

  • PipPipPipPipPipPipPip
  • The Flame
  • The Flame
  • 500 posts

Posted 09 March 2014 - 03:41 PM

http://imagizer.imag...90/401/0fas.jpg My circuit - very easy to see the wiring. Comes out from the pin, goes to the button, across the button to ground. The Teensy itself does the work of a pullup resistor.

This is a blanket code which can be easily modified, I've only got two buttons coded but the basics are there.
The REALLY important part is adding in the USB keyboard device properly inside of the arduino interface so when the teensy is loaded it is recognized by windows as an HID keyboard.
My code (slightly modified version of example code):
/* Buttons to USB Keyboard Example
You must select Keyboard from the "Tools > USB Type" menu
This example code is in the public domain.
*/

#include <Bounce.h>
// Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10); // 10 = 10 ms debounce time
Bounce button2 = Bounce(2, 10); // which is appropriate for
Bounce button3 = Bounce(3, 10); // most mechanical pushbuttons
Bounce button4 = Bounce(4, 10);
Bounce button5 = Bounce(5, 10); // if a button is too "sensitive"
Bounce button6 = Bounce(6, 10); // to rapid touch, you can
Bounce button7 = Bounce(7, 10); // increase this time.
Bounce button8 = Bounce(8, 10);
Bounce button9 = Bounce(9, 10);

void setup() {
// Configure the pins for input mode with pullup resistors.
// The pushbuttons connect from each pin to ground. When
// the button is pressed, the pin reads LOW because the button
// shorts it to ground. When released, the pin reads HIGH
// because the pullup resistor connects to +5 volts inside
// the chip. LOW for "on", and HIGH for "off" may seem
// backwards, but using the on-chip pullup resistors is very
// convenient. The scheme is called "active low", and it's
// very commonly used in electronics... so much that the chip
// has built-in pullup resistors!
pinMode(13, OUTPUT);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP); // Teensy++ LED, may need 1k resistor pullup
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
}

void loop() {
// Update all the buttons. There should not be any long
// delays in loop(), so this runs repetitively at a rate
// faster than the buttons could be pressed and released.
button0.update();
button1.update();
button2.update();
button3.update();
button4.update();
button5.update();
button6.update();
button7.update();
button8.update();
button9.update();

// Check each button for "falling" edge.
// Type a message on the Keyboard when each button presses
// Update the Joystick buttons only upon changes.
// falling = high (not pressed - voltage from pullup resistor)
// to low (pressed - button connects pin to ground)
if (button0.fallingEdge()) {
Keyboard.println("B0 press");
}
if (button1.fallingEdge()) {
Keyboard.println("B1 press");
}
if (button2.fallingEdge()) {
Keyboard.println("B2 press");
}
if (button3.fallingEdge()) {
Keyboard.println("B3 press");
}
if (button4.fallingEdge()) {
// Keyboard.println("B4 press");
digitalWrite(13, HIGH);
delay(300);
digitalWrite(13, LOW);
Keyboard.set_modifier(0);
Keyboard.set_key1(KEY_F);
Keyboard.send_now();
}
if (button5.fallingEdge()) {
//Keyboard.println("B5 press");
digitalWrite(13, HIGH);
delay(300);
digitalWrite(13, LOW);
Keyboard.set_modifier(0);
Keyboard.set_key1(KEY_G);
Keyboard.send_now();
}
if (button6.fallingEdge()) {
Keyboard.println("B6 press");
}
if (button7.fallingEdge()) {
Keyboard.println("B7 press");
}
if (button8.fallingEdge()) {
Keyboard.println("B8 press");
}
if (button9.fallingEdge()) {
Keyboard.println("B9 press");
}

// Check each button for "rising" edge
// Type a message on the Keyboard when each button releases.
// For many types of projects, you only care when the button
// is pressed and the release isn't needed.
// rising = low (pressed - button connects pin to ground)
// to high (not pressed - voltage from pullup resistor)
if (button0.risingEdge()) {
Keyboard.println("B0 release");
}
if (button1.risingEdge()) {
Keyboard.println("B1 release");
}
if (button2.risingEdge()) {
Keyboard.println("B2 release");
}
if (button3.risingEdge()) {
Keyboard.println("B3 release");
}
if (button4.risingEdge()) {
//Keyboard.println("B4 release");
Keyboard.set_key1(0);
Keyboard.send_now();
}
if (button5.risingEdge()) {
//Keyboard.println("B5 release");
Keyboard.set_key1(0);
Keyboard.send_now();
}
if (button6.risingEdge()) {
Keyboard.println("B6 release");
}
if (button7.risingEdge()) {
Keyboard.println("B7 release");
}
if (button8.risingEdge()) {
Keyboard.println("B8 release");
}
if (button9.risingEdge()) {
Keyboard.println("B9 release");
}
}

Edited by Gevurah, 09 March 2014 - 03:42 PM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users