posts tagged with the keyword ‘sparkfun’

2011.05.09

The Button

NOTE: Need a button? Now you can buy one! Visit our store or Etsy.

I was in need of a button, but not just any button. A USB-enabled button that could emulate a single key being pressed on a keyboard. This is that button…

It consists of the following materials:

The Button

I used a Teensy as it’s a very simple (and cheap!) way to emulate a USB HID. I do wish the Teensy had mounting holes. I ended up not mounting it at all and letting it just hang loose, which should be fine, as it’s so lightweight. There’s a bit of electrical tape wrapped around the Teensy and the solder joints.

For the box, I wanted something metal, so it would be heavier and more sturdy than the typical plastic project box. Matt Gauger of Milwaukee Makerspace suggested I check out Mammoth Electronics, as they make boxes for guitar pedals. I ended up choosing their “tall” enclosure.

For the button, I really like this button over the one I ended up using, but it was too tall to fit in the project box. Unless you’re a “button snob” you probably won’t notice much difference between the two.

If you’ve got USB cables lying around, use one… otherwise, you can get one from Monoprice for less than a dollar. I pretty much buy all my cables from Monoprice.

As for the rubber feet, I picked some up at the local hardware store… as well as some black spray paint. (Note: If you are ordering the button from Sparkfun, just get the rubber feet from them too!)

The Button

There was one more item I needed. The button needs a 27.3 mm hole to fit into, which means I needed a hole that was 1.07480315 inches wide. Well, 1.07480315 inches is pretty close to 1.0 inches, so I ended up getting an Ace Bi-Metal Variable Pitch Hole Saw. (The link is not the exact one that I got. I ended up getting mine at the local Ace Hardware store.)

As for the process, the Teensy part took a small amount of time, (see the AWESOME Button) and the drilling was a little tricky, as the 1.0 inch hole was just slightly too small. A bit of creative drilling with a regular drill bit fixed that though. The spray painting was the real time consuming part of it all. As for the assembly, I originally envisioned mounting the Teensy on the bottom plate of the box, and having a hole where the USB connector would be accessible, but I ended up going with what you see in the photo. (I just used the Dremel to cut a small groove for the cable to fit into.)

And why do I need a yellow button that can emulate a key being pressed? Well, sometimes you just need a yellow button that can emulate a key being pressed…

The Button

Note: A number of people have asked for the code I used, and even though it is in the comments, I thought I should post it in here as well.

/*
 * Button.pde
 */

void setup() {
  Serial.begin(9600);
  pinMode(10, INPUT_PULLUP);
  delay(500);
}

void loop() {
  if (digitalRead(10) == HIGH) {
    delay(10);
  } else {
    Keyboard.print(" "); // we print a space
    delay(1000);
  }
  delay(10);
}

2011.01.17

ShiftBrite

Back when I revealed the Twitter Monkey I had a dark secret… I got the Perl script to work, but just barely, and I really didn’t grok exactly how the code worked. I was just thankful MCQN Ltd. published the Alertuino code for me to get started.

I’m happy to say that I’ve made some good progress in getting Perl and the Arduino to talk to each other, and if you keep reading, you’ll see what I’ve got so far.

I’ll be using a ShiftBrite from macetech for this example. You can buy direct for $4.99, get them from Adafruit for $5.00 or use your #freeday money to get one from Sparkfun.

ShiftBrite

To connect the ShiftBrite, you just run it’s GND to the GND on the Arduino, the V+ to the 5V on the Arduino, and the run DI, LI, CI, EI to digital pins 10, 11, 12, 13 respectively, on the Arduino. Just 6 wires… pretty simple.

Once again, I stand on the shoulders of others… a hacker named Ashley Hughes wrote a post titled ShiftBrites and the Arduino and provided a library named shiftbritehughesyarduino. Grab it and drop it in your Arduino/libraries folder before we get started.

The library makes it pretty easy to send a color to the ShiftBrite using a command like this:

sb.sendColour(200,400,600);

Where the colors are in R,G,B value. Though the scale is not 0-255, or 0-100, but 0-1023. I’m not great at math, so I’m going to use the 0-100 scale and just multiply by 10. So for the line above we’d be sending a RED value of 200, a GREEN value of 400, and a BLUE value of 600.

Here’s the code for the Arduino:

/*
 * ShiftBrite.pde
 */

#include "HughesyShiftBrite.h";

HughesyShiftBrite sb;

void setup() {
  sb = HughesyShiftBrite(10,11,12,13);
  sb.sendColour(10,10,10);
  Serial.begin(9600);
}

void loop() {

  int input = Serial.read();

  switch (input) {
  case 48:
    sb.sendColour(0,0,100);
    break;
  case 49:
    sb.sendColour(0,0,200);
    break;
  case 50:
    sb.sendColour(0,0,400);
    break;
  case 51:
    sb.sendColour(0,0,600);
    break;
  case 52:
    sb.sendColour(0,400,0);
    break;
  case 53:
    sb.sendColour(0,600,0);
    break;
  case 54:
    sb.sendColour(0,800,0);
    break;
  case 55:
    sb.sendColour(600,0,0);
    break;
  case 56:
    sb.sendColour(800,0,0);
    break;
  case 57:
    sb.sendColour(1000,0,0);
    break;
  }
  delay(5);
}

See all those “case” commands followed by numbers? They are looking for the ASCII code being sent from the serial port. Don’t have an ASCII chart handy? Look at this simple one and you’ll see that the decimal value for 0 is 48, for 1 is 49, etc. So our case statements are looking for anything between 0 and 9, which is a nice scale to use.

OK, if you’ve uploaded the code, you should see the ShiftBrite lit up, since the initialization sent this:

  sb.sendColour(10,10,10);

The code on the Arduino is now listening to the serial port waiting for some input. The input should be a number between 0 and 9. We should probably send it some numbers… that’s where Perl comes in:

#!/usr/bin/perl
#
# sendserial.pl
#

use Device::SerialPort;

my $port = Device::SerialPort->new("/dev/tty.usbmodem1d21");
$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);

sleep(3);

for ($i = 0; $i <= 9; $i++) {
	print $i . "\n";
	$port->write("$i");
	sleep(1);
}

exit;

This is the shortest, simplest example I’ve got. You’ll obviously need the Device::SerialPort module installed. If you’ve written anything in Perl (or other languages) this should make some sense. We’re connecting to the serial port (/dev/tty.usbmodem1d21) and sending characters (0 through 9) to it, as well as printing them to the console so you can see them.

When you run the Perl script you should see the ShiftBrite light up and change about once per second, cycling through various levels of blue, green, and red.

Note: We got the port /dev/tty.usbmodem1d21 from the Arduino IDE (though I’ll show you another way to get it) and the sleep command is in there to give things time to initialize. I’ve found that without it, the serial port communication may miss the first commands.

ShiftBrite: Red, Green, Blue

Gotchas: The serial port may change. Mine is ‘/dev/tty.usbmodem1d21′ but it will be different on different machines, and may even change after a reboot. We’ll have a fix for that next time. The other gotcha is that when the Perl script is running, it’s using the serial port, so if you try to upload a new sketch to the Arduino, you will get an error. Since this script only runs for about 13 seconds, you probably won’t hit that problem here… for scripts that loop, you probably will.

I hope that wasn’t too complex. In theory, you could write the Perl part using Ruby, Python, or any scripting language that can do serial communications. In the future I’d like to try to use seriality to see if I can do it via HTML/JavaScript.

In a future installment I’ll have a complete project using all the bits we just covered…. stay tuned!

See Also: Arduino + ShiftBrite Light Organ

2010.11.05

As I continue to explore the world of Arduino, I started looking for cheap Arduinos to use in projects – permanent projects that need a dedicated microcontroller. Once you’ve got an Arduino and start having fun with it, you think about things you can build, but you always want one around for prototyping and trying out new ideas, so for permanent installation, you’ll want a cheap Arduino you can drop in place.

Now, since Arudino is open source hardware anyone could get the parts themselves and assemble and use/sell an “Arduino-based” board. This is great, and it’s why I love open source, and it provides many choices. That said, if you are not the “build your own from scratch” kind of person, keep reading for some kits that may work for you.

These are the cheap Arduinos I found, with some notes on each. All of them require some sort of of FTDI connector, as they do not have USB connections. This is fine for boards that will find their way into projects that do not need to be connected directly to a computer, the idea being, you buy one FTDI connector, and you can use it to program all of these boards. Each vendor should also have an FTDI connector for sale, for instance, SparkFun’s FTDI Basic Breakout 5V, Adafruit’s USB FTDI TTL-232 cable, etc. (You will need to figure out the whole 5V or 3.3V thing.) Also worth mentioning is that most of these are kits, which means you’ll need to be comfortable soldering small pieces to make them functional. (Shipping costs you see below are typically estimates, with the choice of the lowest cost.)

Ardweeny
Photo from Solarbotics

Ardweeny probably wins the prize for smallest Arduino, as the “board” and the components actually sit on top of the chip! It’s a novel idea, that’s for sure. If you want a super-cheap Arduino to plug into a breadboard, this is it.

Pros: Cheap – under $10, Very small
Cons: You can’t replace the chip*, so if it gets blown, you’re out of luck, No easy way to power it, Requires FTDI to program it

Now, if you want to “free your Ardweeny from the breadboard” you can get an Ardweeny BackPack which provides power, and a few other niceties. It’s $11.95, which makes teaming it with an Ardweeny total more than $20, which doesn’t make a ton of sense to me… It’s a neat idea, but it all seems a little weird.

Maker Shed has it for $9.95 + $6.95 shipping and Solarbotics has it for $9.95 + $6.94 shipping but note that Solarbotics has a $5.00 “handling fee” if you place an order under $30.

PicoDuino
Photo from The Makerspace

PicoDuino is another small Arduino. I don’t know much about “The Makerspace” and their web site doesn’t really provide much info on them. I do like their description of the product “We designed the Picoduino to be small, cheap, and disposable so that you can throw it in a project and forget about it.”

Pros: Cheap – just $10, Small, The chip is in a socket, so it is replaceable
Cons: No easy way to power it, Don’t know much about “The Makerspace”


Similar to how the Ardweeny has it’s backpack, the PicoDuino has it’s PicoDuino Shield Adapter, which makes using it in a more traditional fashion a little bit easier. The adapter is $10, same price as the PicoDuino itself.


The Makerspace has it for $10.00 + $5.00 shipping.

RBBB
Photo from Modern Device

Really Bare Bones Board (or RBBB) is a step-up in the small/cheap Arduino world. It’s got an easy to connect power jack, a socket for the chip, and the board itself is a bit “customizable” as far as the size you want it to be.

Pros: Affordable – under $13, Power jack, Customizable board size, Chip is socketed
Cons: Still need an FTDI connection (maybe)

I really like the specs of the RBBB. Also note, you can buy one fully assembled for $22.00 if that’s more your style.

Modern Device has it for $12.95 + $4.00 shipping, and The Shoppe at Wulfden has it for $12.00 + $2.00 shipping.

BoArduino
Photo by ladyadaSome Rights Reserved

BoArduino comes from Adafruit Industries, and looks to be pretty similar to the RBBB with perhaps just a few more niceties and features.

Pros: Affordable – $17.50, ICSP header, “No-Wait” bootloader, “protection” diode
Cons: A bit more expensive than the other options

Adafruit has it for $17.50 + $3.99 shipping. (Occasionally Adafruit offers 10% discounts on kits, so if you’re lucky you could get it for $15.75, which would just get you in under the $20 barrier including shipping.)

(Note that Adafruit also has a USB version of the BoArduino, which swaps the DC power jack for a mini-USB connection and comes in at $25.00)

Arduino Pro Mini
Photo from SparkFun Electronics

Arduino Pro Mini comes from SparkFun Electronics and it’s damn small. In fact, it’s miniature! It’s also not really a kit, as it comes assembled (you just need to add header pins.) The chip is surface mounted, so it’s non-replaceable. Again, size is the #1 feature of the Pro Mini.

Pros: Affordable – $18.95, Small, Really Small
Cons: More expensive than the other options, non-replaceable* chip

SparkFun Electronics has it for $18.95 + $4.41 shipping. (That’s the 3.3V version. There is also a 5V version.)

(Note that SparkFun also has the Arduino Pro which is just a dollar more, and comes in 3.3V and 5V versions as well, but at almost $20 and a surface mounted chip, I’m not as interested in this one.)

Diavolino
Photo by Windell H. Oskay, www.evilmadscientist.comSome Rights Reserved

Diavolino comes from Evil Mad Science, and it’s red, and has flames. The Diavolino does not come with a socket for the chip, so add another $1.50 or so if you want one. As for power, you can get a battery pack for an extra $1.00. There’s an extremely detailed assembly guide which I think any beginner would be comfortable following.

Pros: Cheap – $13.00, Nice power options
Cons: Large, No socket included

Evil Mad Science has it for $13.00 + $5.55 shipping.

So that’s my quick rundown of cheap (non-USB) Arduino boards. It should be noted that almost all of these get cheaper as you buy more of them. For instance, the RBBB is $12.50 for one, but just $9.50 each when you buy 10 of them. Also, while it makes the most sense to use an FTDI cable to program these, for any of the boards that use a socketed chip, you should be able to pull the chip, put it in a USB-equipped Arduino, program it, and then return it to the non-USB board. In theory anyway… Note that I also didn’t really talk about what model these are based on, most appear to be based on the Duemilanove or the slightly older Diecimila. How you use it will determine if this matters much. All boards mentioned use the ATmega328, though many show outdated photos with older chips on their product pages, so always read the specs!

And if this isn’t enough, take a look at the spreadsheet of many more Arduinos, which may be slightly dated, but is definitely a nice long list.

(Update: When I say something is “not replaceable” it may be better to say “not easily replaceable” at least by a beginner. — Thanks to Milwaukee Makerspace for pointing this out.)

|


buy the button:

Buy The Button