posts tagged with the keyword ‘teensy’

2015.07.14

Teensy++ 2.0 LED Pin

Yes, this post is actually titled “Teensy++ 2.0 LED Pin” because it’s really specific. This is the solution to a problem that took me a while to fix. Actually, it didn’t take a long time to fix, it just took a long time for me to figure it out and implement it. (Maybe it did take a long time for me to fix…)

Anyway, when using most pins on a Teensy++ 2.0 (and probably every other Teensy) with Arduino code, you may have an issue using the LED pin as an input, because it functions differently than all the other pins. You might say “Hey, just use another pin!” but the project I did required every single pin on the Teensy++ 2.0. (Yes, all 46 pins!)

The code is below. The LED pin is sort of treated opposite of how other pins are treated. You short it with +5v instead of ground, and swap the risingEdge and fallingEdge typically used with the bounce library.

// LEDPinButton

#include <Bounce.h>
 
Bounce buttonD6 = Bounce(6, 80); // LED Pin - tie to +5v instead of GND
Bounce buttonD7 = Bounce(7, 80); // Normal Pin - tie to GND
 
void setup() {
  pinMode(PIN_D6, INPUT);        // LED Pin - use INPUT not INPUT_PULLUP
  pinMode(PIN_D7, INPUT_PULLUP);
}
 
void loop() {
  
  buttonD6.update();
  buttonD7.update();
 
  // D6 - LED Pin - tie to +5v instead of GND
  // use risingEdge instead of fallingEdge
  // a
  if (buttonD6.risingEdge()) {
    Keyboard.set_key1(KEY_A);
    Keyboard.send_now();
  }
  if (buttonD6.fallingEdge()) {
    Keyboard.set_key1(0);
    Keyboard.send_now();
  }
  
  // D7 - Normal Pin - tie to GND
  // b
  if (buttonD7.fallingEdge()) {
    Keyboard.set_key1(KEY_B);
    Keyboard.send_now();
  }
  if (buttonD7.risingEdge()) {
    Keyboard.set_key1(0);
    Keyboard.send_now();
  }
  
}

You can also grab this code from github.

2015.06.08

Yeahs! Pi!

I presented A Life Time of Yeahs! at Bay View Gallery Night but I didn’t really post much about how it was made, so I’ll do that now, as well as talk about the shortcomings. Above you can see the front and the back. The front piece is actually from an IKEA picture frame I found in the trash. It was a nice smooth MDF-like surface, so I figured it would take the vinyl and paint pretty well.

For the illustration of Mr. Rollins I did a few searches and didn’t find anything that was perfect, so I grabbed a few images as reference and traced/drew my own in Inkscape. I then created a stencil by cutting vinyl on the Silhouette Cameo (including the lettering) and stuck it all down to the IKEA board which I had already painted white.

With the vinyl in place I then painted it all flat black. I didn’t leave it all smooth as it sort of looked too polished, so I smeared some paint around with a brush and then with my fingers so it gave it some texture. I’m still not sure that was the right thing to do, but I did it, and there’s no going back.

Once I had the front piece done I found some scrap wood for the frame in my garage and cut it on the table saw. I made sure the wood was wide enough to fit the speakers into. It was, but as I’ll get to in a bit, wider would have been better…

Yeahs!

The back of the piece contains a Raspberry Pi, a set of speakers, and a Teensy 3.0 with a few buttons connected to it. It’s all powered by a power bank from Brown Dog Gadgets.)

The speakers are USB powered so they, along with the Raspberry Pi, connect to the power bank. Turning on the power bank boots up the Pi and starts a script called “rpisounds.pl” which is a Perl script that starts running and waits for keyboard input to do something. That “something” is playing an audio file if you press the red button on the front of the piece. There’s also a small button on the back of the piece that safely shuts down the Pi if you want to turn it all off.

Yeahs! Pi!

It’s been suggested that the Teensy in addition to the Raspberry Pi is overkill, and… it is! I originally had a separate project that used some of this code and hardware and ended up just grabbing what I had lying around because it was quick and easy. Sometimes it works out that way, and that’s fine…

I should have went with the more powerful speakers I had, because as I learned last time, if you’re doing something with audio in a public space, make it much louder than you think it should be. I had a louder pair of speakers, but they would have required AC power, so I compromised. Oh well. (You can’t tell from the photo, but there are speaker hole drilled in the side of the frame.)

I’ll probably clean up the code and publish it eventually, but essentially it gets kicked off by /etc/rc.local and runs it a continual loop waiting for a key to be pressed. If you press “a” (the button on the front) it randomly selects an WAV file and plays it. If you press the button on the back the script sees a “r” and shuts down. Why an “r” instead of an “s”? I don’t know… There’s another button that was taped up that types a “q” for quit, which quits the script, and is handy for debugging or troubleshooting if you have a monitor and keyboard attached.

That’s the summary of my Raspberry Pi based interactive painting titled “A Life Time of Yeahs!”

I hope you enjoyed it… As always, let me know if you have any questions.

2014.11.16

In case you’re wondering, this is what you see the first time a computer running Mac OX sees a Teensy (or other controller) acting as a USB HID device. (You know, like a keyboard.)

Mac OS X Keyboard

No worries, just hit the “Continue” button…

Mac OS X Keyboard

And then hit the little red dot in the upper left to close the window. Hopefully you’ll only see this the first time.

That’s it!

2014.05.07

Teensy 2.0
Teensy is teensy

For the past few years I’ve been building devices that can emulate computer keyboards. Typically I’ve used the Teensy microcontrollers for this along with the Arduino IDE and the Teensyduino add-on. The things you can do with a Teensy to emulate a keyboard are very impressive! Basically, it’s the best way I know of to create your own custom USB keyboard.

Comparison
Size matters – A-Star with Arduino Micro and Leonardo

When the Arduino Leonardo was introduced, one of the features I was interested in was the ability to emulate a USB keyboard. I never actually got a Leonardo to test this with, mainly because the form factor was too large for my projects. Sometimes shield compatibility is good, sometimes the smallest board wins.

A-Star
Size matters!

I recently got a Pololu A-Star 32U4 Micro, which is a tiny (and cheap, under $13USD) board very similar to a Leonardo, once again using the Atmel ATmega32U4.

There may be a little bit of work involved in getting the A-Star up and running. There are drivers needed if using Windows, and (supposedly) a little more work to get things going with Linux. I had no issues with Mac OS X, but I’m pretty familiar with add-ons for the Arduino IDE due to using Teensyduino. You can also just pretend this is an Arduino Leonardo and that seems to work fine.

(I also can’t tell if the Pololu A-Star 32U4 Micro is open source hardware. They do have a bunch of files available, but I did not see an explicit “Open Hardware” note anywhere. It’s worth mentioning that the Teensy is not open source hardware. If that’s not a big deal to you, then it’s not a big deal to you. The official Arduino hardware is of course, open source.)

I’ll probably keep experimenting with the Pololu A-Star as a keyboard emulator for simple things, and stick with the Teensy for more complex things. I’ve also heard that the Teensy 2.0 will disappear in the future, which isn’t a huge deal, as the Teensy 3.1 is a big improvement over it, but the 3.1 does cost a bit more than the 2.0, so that’s one factor to consider when evaluating which board to use.

Have fun building your own keyboard!

Update #1: I’ve been talking to Pololu and they suggested the A-Star may actually be able to use the Teensyduino Keyboard libraries. I’m awaiting more info on this, as it would be an exciting development.

Update #2: It looks like the Teensyduino Keyboard libraries cannot be installed onto the A-Star, which is good to know. But don’t worry, I’ll be using the A-Star for some future projects anyway. ;)

2012.02.26


Buttons

Today’s Maker Business involved some early morning soldering. (What else would I do at 7am?) Next up is programming, and then I need to drill out all the enclosures. (I’m hoping to do that later in the day.)

Oh, I also built a spray booth this weekend since I’ll be doing a bunch of spray painting. (We also use spray glue in the basement, and this should make that a little less messy.)

« Older Entries |


buy the button:

Buy The Button

top recent artists: