Showing posts with label Girls' Hack Night. Show all posts
Showing posts with label Girls' Hack Night. 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.

Thursday, January 27, 2011

If only there was a little girls hack night...

My not-yet-6-year-old daughter isn't very curious about what I'm doing or where I'm going when I'm not with her. So it was unusual for her to show interest in my going to All Girls Hack Night. As I said before, All Girls Hack Night is a monthly meeting of female developers, where they get together to work on their code projects and talk, with a brief presentation on a programming topic thrown in. I told Erika I was going to a meeting with women programmers. I didn't expect her to make anything of that bit of information, let alone to take interest in it. But she did. "So you are a programmer?" she exclaimed. "Yes," I said. "I didn't know it! How do you act like a programmer?" she asked. I thought this was probably her way of asking "what do programmers do?" I said, "you write code on a computer", feeling uncertain, as usual, how much background information to supply. How do you describe succintly, without taxing a 5-year-old's attention span, what is code and how does one write it? She didn't ask me to explain, but had other questions. "Who are those ladies?" I said I could name some names, but she doesn't know them. Of course, that was even less helpful. Then she told me several times that she wanted to come along. I hated to tell her that this is for grown-ups only. I feel like I should do something about this interest of hers. I know there are some programming environments and languages for children, but they are aimed for older children, at least nine years of age. (And probably for a good reason -- most programming concepts are too abstract for a 6-year-old to understand.)

The previous All Girls' Hack Night in December was sparsely attended (yes, holidays), but this one picked up again, with one woman doing a short presentation on CodeIgniter, a PHP application framework. Then a representative of our sponsor, TabbedOut (that provided the meeting space) talking about her company and mobile software development it does. The rest of the time we were supposed to be working on our projects, but as in all coworking situations, we mostly chatted.

The talk of web development (in which many of these women specialize) inevitably brings up the topic of cross-browser compatibility, or lack thereof. Many web developers would like nothing better than for people to stop using IE 6, so that they would never have to code special hacks just to get a page to display in IE 6. But sometimes even convincing your own family to drop it can be very hard, especially if a family member is older, not too tech-savvy, and stubborn. One woman weaned her mother from IE 6.0 by installing Firefox and changing its icon to IE. Her mother, who was't very observant, noticed it only half a year later. She got angry, but the daughter asked, when was the last time you got a virus? True, mother admitted, she hasn't got a virus in a long time (that coincided with the time she had been using Firefox), but that's only because she was "being safe on the internet". The daughter didn't buy it, pointing out that she used to have to wipe out the hard drive on mom's computer every 3 months to get rid of malware. But you can't very well explain this to a person who, seeing a printer that advertised itself as wireless, demanded to know why the daughter plugged it into the wall. After all, it's wireless!