Showing posts with label crafts. Show all posts
Showing posts with label crafts. Show all posts

Saturday, November 26, 2011

Girls hack Arduino

In all my programming life I never tried communicating in code with real-world objects. But now there is something to make it easy (or at least doable): Arduino. Sharon Cichelli demonstrated it at the All Girl Hack Night in October of 2011. Arduino is a microcontroller that lets you program blinky LED lights, or things that make buzzing alarm sounds, or all sorts of other electronic. It also accepts input from buttons or sensors, or anything that translates a physical action into electric pulse. You can plug things into one of its pins (there are 13 of them, if I recall), and have it "read" electric pulses from those pins, or "write" to them.

"Read" and "write" probably shouldn't be in quotes, because they are the same programming concepts as reading and writing to/from any input/output device. So, to switch on an LED light that's plugged into pin 13, you would digitalWrite(13, HIGH). As with all things digital, the function digitalWrite only recognizes on/off, or in this case, HIGH/LOW values. HIGH means the device plugged into the pin is on, LOW -- off. Simple, right? These basics allow one to sit down and program a primitive blinky light in minutes. The programming language is fairly high level. Its function names, as one can see, resemble human language -- this isn't assembly, where you push bits around with three-letter commands. It enables you to quickly do simple demos, like Sharon Cichelli did. Just as you digitalWrite to a pin to turn a device on, you digitalRead from a pin to recognize, say, a button press. Again, you pass to it the number of a pin into which the button is plugged in.

You write the code in an IDE, and with one mouse click upload it to an Arduino connected to your computer via USB.

Sharon Cichelli dictates the code that Anne types up on the laptop Sharon Cichelli demonstrates Arduino programming.

Arduino programming seems encouragingly simple at first, but as with everything, once you get deeper into it, you discover complexities. In fact, one's lack of electronics background might put brakes on the progress. Having been told that a LED light is plugged into a pin number 13, you (and by you, I mean me) might notice that the light actually has two wires, both plugged into tiny slots. Why are there two wires, and which of them is # 13, you ask. Oh, it's because the light needs to be grounded. The other wire is plugged into the grounding pin, you can ignore it for the purposes of your program. Yes, grounding is something you should have remembered from physics classes, but didn't. Then you digitalWrite to it, and it still doesn't light up -- that's because something is wrong with the hardware, and the circuit does not close as expected. Maybe the light isn't plugged in firmly enough. So, there are two dimensions to debugging Arduino code: a programmatic and an electrical dimension. As if catching just the software bugs wasn't tricky in itself!

Sharon couldn't help but demonstrate troubleshooting techniques, as things malfunctioned. Pins "floated". Still we had enough time to progress to a more advanced part of the lesson: Pulse Width Modulation. If you can only send "on" or "off" signals to a LED, how would you dim the lights, or produce nice, slow fade on / fade off effects? The fading or increase in brightness is caused by flickering very fast between on and off positions. If the light spends more time in the "off" position than "on", it appears to fade; if in on position, it grows brighter. If we graph HIGH and LOW signals versus time, where every HIGH signal is a vertical bar, we'll see that the "width" of the HIGH signal decreases (increases) over time. So that, simply put, is Pulse Width Modulation. Sharon pair-programmed with someone (sitting another person down at her laptop's keyboard, and dictating code to her) to implement the slow fade.

Besides blinking and buzzing things, you can connect Arduino to vibrating things. Erm. I mean, like a mat under a cat food bowl. A vibrating mat would scare off a cat that is afraid of vibration. This was the idea one of the girls had. How do you make a cat lose weight, if you also have a normal-weight cat, and each time one sees the other eating, she will eat too? The goal is to make the fat cat to eat less frequently than the normal-weight cat. So, this girl got an idea to put a vibrating mat under the cats' food bowl, so that when the cat steps on it, her weight would send an input to Arduino, which would trigger the vibration, scaring the cat off. The smaller cat's weight would not trigger this response. And the fat cat's weight would only do it at certain times but not others, otherwise the pudgy feline would never eat.

And if you don't have problematic cats, there is still a wide variety of applications for Halloween costumes, such as blinky eyeballs like Sharon made for her own Halloween costume.

Saturday, November 08, 2008

Highlights from Maker Faire 2008 (October 18-19, Austin, Texas)

I won't blog much about Maker Faire this year, because the most interesting exhibits were the same as last year. This includes art cars and bicycles, and pedal-powered merry-go-rounds by Cyclecide. You can read about those wonders by accessing all posts with the label "Maker Faire".

I took two new pictures of the Cyclecide devices that weren't here last year (or at least I missed them): a merry-go-round of two hanging bicycles that may or may not be known by a more elegant name Bike Rodeo, and Axe Grinder that plays sounds resembling an electric guitar when a rider pedals it. I guess you can play some rudimentary music this way. For some reason there was a written sign forbidding Stairway to Heaven. ;-)

Last year I somehow also managed to miss the Life Size Mousetrap. It is a giant Rube Goldberg-style chain of devices inspired by the desktop Mousetrap game.

Here are some images of Life Size Mousetrap: 1: the mousetrap rests between demonstrations, 2: the curiously dressed people who run the mousetrap, 3: a one-woman band Esmeralda Strange, 4: the guy bring in the "cheese" for the mousetrap, 5: the World's Sexiest Mice come in, 6: the World's Sexiest Mice are bound with ropes, 7: volunteers hoist the 4000-pound black cube, 8: the 4000-pound black cube has been hoisted into the air, 9: a "mouse" collects donations after the show, 10: collection of donations, 11: a World's Sexiest Mouse and a Lizard Boy make a victory tour, 12: the desktop Mousetrap game that inspired the life-size one.

Here is my YouTube video of the Life Size Mousetrap in action.

A low-tech but cute gift for a science fiction fan in your life: journals with covers made of vintage science fiction paperbacks.

Technical and cute: Armadillo-shaped car.

Among the more offbeat: knit plarn bags. Plarn is "plastic yarn", made by cutting up plastic grocery bags into long strips.

There were robots and robot competitions too numerous to name. And microcontrolled devices were really popular at Maker Faire. In addition to homegrown makers making toys with microcontrollers, Microsoft had an entire pavillion devoted to promotion of their .NET Micro Framework. It gave people an opportunity to create their own applications right there at the Maker Faire. One could also enter a Microsoft contest that starts later this year. A Microsoft guy attending the booth told me that people like me, who have only developed web applications in .NET, are a prime audience for .NET Micro Framework. But... doesn't programming embedded devices requires knowledge of hardware? I asked, puzzled. No, said the guy, .NET Micro Framework abstracts it all away. According to him, all you need to do is to read the manufacturer's specifications that came with your microcontroller, so that you would know how its pins are numbered, and then you can write code directly to the pins. He encouraged me to enter the contest. Yet, as an application programmer, this is hardly my idea of fun. The conversation wasn't in vain, though: he gave me a Microsoft t-shirt. Now, would I dare to wear it, given how much I associate with free software people? What a conundrum.