Monday, November 2, 2009

Custom NXT IR Receiver

After building our pumpkin motion detector we wanted to build a Halloween prop to control with it. We decided to use a Lego NXT because we didn't need the prop to be permanent and we wanted to prototype it in a hurry.

The plan was to hang a giant spider from a rope that would be suspended under the eaves of the house on the front porch. When an IR command is received (from a motion detector hidden in a pumpkin) the spider would rush out from behind a web-decorated tree and advance toward the sidewalk.

We created a NXT platform that rolls along a rope by hanging from a single tank track. Two motors were required for torque because it had to move a very large spider. The motors were geared up to increase speed because we wanted it to emerge suddenly.

To allow the NXT to receive IR commands I created a custom I2C slave with a 38kHz IR receiver on it. I also included two reed switches that are used to detect magnets. By attaching magnets to the ends of the rope the NXT can detect when it has reached the end of its travel. The total cost of the sensor was fewer than $15 (including the NXT cable and enclosure).

The sensor fits nicely in a small project box and is easy to attach to the NXT by building a cage around it. I attached the magnet sensors to the project box itself so they sat directly under the rope.

An IR receiver is rather handy to have for the NXT. I decided to use the RCA IR protocol because I have several remote controls around the house (including an original XBox DVD remote) that can now be used for NXT control. In this case I am using an IR transmitter that I also built to send commands automatically.

Because the sensor still has plenty of processing power to spare it is ready to be extended to suit whatever need may arise in the future. The source code (AVRStudio4 C) is available for free under the GPL by request.





Motion Activated IR Transmitter


This Halloween my girlfriend and I wanted to experiment with motion-activated decorations. We decided to make a device that is small enough to fit into a pumpkin and can perform the following functions: A) act as a decorative pumpkin light, B) contain a passive infrared (PIR) motion sensor, and C) use an infrared transmitter to control other props.

We chose to use a PIR motion sensor because they are cheap ($5-$10) and readily available (including most RadioShacks). We chose to use an IR transmitter because the components are cheap (<$5 for an IR LED and 38kHz receiver pair) and we didn't want to have wires strung around the yard. We used a really cheap strobe light from Target ($2) as the main housing. After removing all of the existing electronics we replaced the cheap LEDs in the reflector with one IR LED and mounted a 2"x2" breadboard inside on standoffs. We snaked an RGB LED out of the back of the housing on a harness composed of 22gauge solid wire so it was bendable and positionable. Then we put a 1/8" stereo jack on the back panel of the housing so the PIR sensor module would be removable.

The PIR sensor itself was bolted inside a small disposable tupperware container so it could be concealed anywhere within 6' of the main pumpkin itself (for example in a smaller adjacent pumpkin or just in the bushes). We used a regular 1/8" stereo cable for the harness because the PIR sensor only requires 3 wires.

I used a cheap ($1.40) AVR microcontroller to control everything. When the sensor is idle the LED flickers green and blue and behaves like a normal pumpkin light. When the motion sensor is tripped the pumpkin sends a command using the RCA protocol (the same as the original XBox DVD remote) and then flickers red for 3 minutes before resetting.

The code (AVRStudio4 C) compiles to less than 1KB and is available under the GPL by request.

Sunday, November 1, 2009

Newspaper Box Halloween Prop


My girlfriend designed this simple Lego NXT robot to startle people who came up to our doorstep. The bot uses an ultrasonic sensor (attached to the box and hidden in spider webs) to determine when someone has stepped in front of our newspaper box. It then turns on the light sensor's red LED for dramatic effect and then thrusts a large spider (attached to the bot by a chopstick) out towards the visitor. Approximately 2 out of 3 trick-or-treaters were caught off guard.

Here is a video of it in action: http://www.youtube.com/user/ph0015d4y#p/a/u/0/8ITSmziMPSs



DIY Pumpkin Light

Becca and I found these little "tap lights" at the dollar store and liked the housings (they come in various shapes including crescent moons and simple domes). We purchased this one and replaced the incandescent bulb inside with a cheap microcontroller and three LEDs. We kept the original battery compartment (4xAA) and push switch.

Becca chose white, green, and blue LEDs to match the housing. She wanted the colors to fade in and out while cycling pseudo randomly.

The source code (AVRStudio4 C) compiles to less than 1KB in size and is available under the GPL by request.

A video of it in action: http://www.youtube.com/watch?v=QhdMVfQuDV0




Thursday, October 15, 2009

Lego NXT RFID Reader


A while ago I purchased a Parallax RFID Reader from a local RadioShack and decided to allow it to talk to my Lego NXT. It is programmed to accept the ID of my circular tag and reject all others. Here is a video demo:

http://www.youtube.com/user/ph0015d4y#p/u/0/tiamide0dLk

I have been looking for an excuse to post a UART to TWI(I2C) example for some time now. I decided to start with RFID because the idea of a robot buzzing around the house reading tags as waypoints sounded like fun. If I ever find an excuse to own a GPS unit I'll provide a schematic and some code for that as well.

Here is the schematic and a rough bill of materials for this ~$70 NXT integrated RFID Reader:
  • $4 (1) Atmel Atmega8-16PU microcontroller
  • $50 (1) Parallax RFID Reader with tags (parallax.com or RadioShack )
  • $0.10 (1) >10 kOhm 1/8watt resistor
  • $0.10 (1) .1 uFarad capacitor
  • $0.20 (4) 100 Ohm 1/8watt resistor
  • $0.30 (1) 150 Ohm 1/8watt resistor
  • $0.20 (2) 82 kOhm 1/8watt resistor
  • $6 (1) Breadboard
  • $5 (1) Lego NXT cable with pins broken out
  • $2 (1) RGB status LED
  • $0.25 (1) Red power indicator LED
  • $0.25 (1) Green heartbeat LED
  • $2 Wire/Solder
The next step for me will be to shove the RFID Reader and breadboard into a 3.5" x 4.5" x 1.5" project box and mount it to a rover. The RFID Reader has no problem reading tags through plastic at a distance of about 4".


Drop me an email if you are interested in the (AVRStudio4 C) code for the Atmega8-16 or a ROBOTC program for testing. Both are available for free under the GPL.