Oh joy of joys! I just tested the reed switch with the Arduino, and it works! I was pretty nervous about that one, since I hadn't had any luck with the multimeter, and I wasn't entirely sure what I would do if the reed switch was out of commission. Observe:
 |
| The magnet is far from the reed switch, and the circuit is broken. Light off. |
 |
| The magnet is close to the reed switch, and the circuit is complete. Light on (the lower light). |
I wrote a simple Arduino sketch that checks for a transition in the reed switch. If the switch goes from off to on, it sends a single bit to the serial port. Otherwise, it does nothing. The RXTX package (see my
last post) is event-driven, meaning it is not constantly polling for input and instead only does something when it receives data. I took this one step further and decided to send data only once per rotation, giving the program basically the lowest possible overhead: one bit per rotation. Next I'll be adapting my
Robot and
serial test classes (did I forget to mention those?) to take in that serial data and move the mouse cursor accordingly.
The only thing I'm really afraid of right now is reassembling the bike itself. It's got a pretty complicated internal structure; obviously they didn't intend for any tampering. When I disassembled the bike, I carefully arranged the pieces in a protective case so that I would remember which went where. And then my cat, the adorable little agent of chaos, knocked the case onto the floor, jumbling the pieces within. Wish me luck! At the very least, I'll have a working example of a rotating reed switch controlling mouse cursor position within Dasher, and a broken bike.
 |
| Keaton the Cat, proponent of entropy and avid consumer of the arts. |
No comments:
Post a Comment