posts tagged with the keyword ‘teensy’

2016.01.25

Video Installation

Last summer Ray Chi got in touch with me about an installation he was doing for the Milwaukee Art Museum. He wanted a video screen that could be activated to play a video by touching a metal plate. Well, actually six videos and six video screens and six metal plates.

I told him I’d figure out how to get it all to work the way he wanted. I came up with a few ideas, one of which was using Processing, which I did get working, but at the time Processing wasn’t really running on the Raspberry Pi, at least not officially (or very well) and since the Pi was what we ended up choosing, I needed another solution.

For an installation that’s going to be running for years, simplicity and reliability are key. I had used Pis in the past many times for video players using omxplayer. Typically I’d just launch omxplayer on boot and have it play a video, looping, forever. For this application we wanted the video to play only when the metal plate was touched by a human hand (and then stop playing when someone stopped touching it) which meant capacitive touch.

Rather than spend a lot of time coming up with something that might work, I went with something that I was 98% sure would work. I used Adafruit’s Standalone Momentary Capacitive Touch Sensor Breakout attached to a Teensy LC. Why a Teensy LC? Because it’s a low-cost (LC!) Arduino-compatible microcontroller and it can emulate a keyboard.

Yes, a keyboard! If you have a USB keyboard connected to a Raspberry Pi computer while omxplayer is playing a video, you can just hit the space bar to play the video, and then hit it again to pause the video. Those are the two things we needed to do.

Video Player Controls

So, Raspberry Pi, running omxplayer to play the video, with a Teensy LC attached programmed to work as a USB keyboard, and triggered by a capacitive touch sensor, which was then connected to the metal plate. Simple!

There was this issue of……. timing.

So in theory, the Teensy would just need to send a space character to play the video, and it would do this when you touched the metal plate. But! (And it’s a Big But) the issue was that we wanted the video to start playing at boot and then pause at the beginning and sit there waiting… for someone to touch the metal to start the video playing. Rather than fire up the video via the typical Linux methods, we ended up just starting up the Pis, auto-logging in, and having them wait at the command line… yes, just sit their waiting, doing nothing… Sort of.

When the Pi booted up, it provided power to the Teensy, which then started running its sketch. The sketch would start at boot, wait 45 seconds to ensure the Pi was booted up and sitting there waiting at the command line, and then it would type:

/bin/bash /boot/video.sh

So we actually used the Teensy to send the text to the Pi (just as if a human typed it) which then fired up the script and started the video playing. The sketch would then wait 2.4 seconds and type a space character, which would pause the video. This set the state of things exactly where we wanted them. The video way paused, just waiting for the next command from the Teensy, which was… space, of course!

Now, there’s the concept of “rising edge” and “falling edge” when it comes to pressing buttons. A rising edge is the transition from low to high, and a falling edge is the transition from high to low. That’s a fancy way of saying we can tell when the button is being pressed, and when it’s being released. It’s best to use debouncing for this, and there’s a library for that.

Video Players Mounted

So with everything mounted in place we still had to deal with one issue. The HDMI displays worked find as long as they were turned on before the Raspberry Pi computers. If they were turned on at the same time the resolution wouldn’t set right, and the video would be letter-boxed. There were two options, one would be using two different power strips to get power to everything, with instructions for museum staff to follow a specific order. This wasn’t ideal, so we went with option two. I used a time delay relay so that one single power strip could be turned on, which would turn on the HDMI displays, and then a few seconds later turn on the computers. It worked. (And yes, I found out later I probably could have fixed the issue in software. Duly noted.)

Are there things we could have done better? Yes. Did we get the project done on time, and within (or under) budget? Yes. Was it fun and challenging? Yes and Yes. You may read this and think “Hey, you totally could have solved problem X by doing Y!” and you’d probably be right. I’ve found a number of things I’d do slightly differently if I were to do something like this again. That’s all part of experience, and learning, and sharing… right?

Video Player

When the installation was all done and tested, I got photos of everything, and then set to work on documenting it all. I delivered a 14 page manual on the construction and operation of the video players, along with the code and instructions on how to use one of the backup SD cards that was prepared in case of failure.

Besides, now I can (sort of) say that my work is in the Milwaukee Art Museum. ;)

2015.10.02

X11_ssh_tunnelling by Tene~commonswiki

When I first started using *nix-based operating systems I played with xeyes, which is a “follow the mouse X demo” and a very simple program. (Really, it’s not fancy, but 25 years ago, it was sort of neat.)

A few days before Maker Faire Milwaukee Vishal and I were brainstorming ideas for something done in Processing to show with a projector, and I suggested xeyes because it was silly and simple and we hadn’t slept much.

I figured there was a Processing version out there, and our old pal Alex has one at Tinkerlog. I grabbed it and started hacking. Someone mentioned putting the old Milwaukee Makerspace logo in place and putting the eyes on it. (It may have been me, I honestly don’t remember, again… not much sleep.)

Then Lexie showed up and I ran the demo and she suggested there should be a fly for the cursor. In my tired state I thought this was a great idea, and then checked on how cursors work in Processing (yes, you can use an image) and then I found a fly on OpenClipArt.org and added it.

mms-xeyes

Now we had something that let you move the mouse around and the fly would move and the eyes would follow it. I sent Vishal the code and he had a trackpad he thought about using with it… But then he said it would be cool if it just moved around on its own. I didn’t have time to write the code, so Vishal asked if I had a Teensy on me, and since I always do, I gave it to him. He then wrote code to make the Teensy act as a mouse and randomly move around the screen.

We hacked this all together pretty quickly, and it was fun, and not super-impressive, but we liked it. Oh, I also made a Processing.js version you can try. (It’s an early test version before I added the fly.)

mms-xeyes-rpi

A few days after Maker Faire I got an email from Bryan Cera about running Processing on the Raspberry Pi, which we had been discussing. He got it working, so I finally circled back around to give it a try. Well, it worked, and I got this mms-xeyes thing running as a full-on application.

This is pretty awesome. I mean, the cursor is a little weird, and disappears when you do not move the mouse (but reappears when you do move it) but overall it does work, and I’m pretty pleased with it. I’ve got a few ideas that involve Raspberry Pi computers running Processing sketches, so yeah… overall, this is good.

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 gone 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 a 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!

« Older Entries |


buy the button:

Buy The Button

top recent artists: