Thursday, March 03, 2016

Add an LED to your LogoTurtle

Erin Riley has a great project using an LED throwy and taking a long exposure picture of her LogoTurtle in a dark box to make drawings with light. So we put our heads together and found a way to add an LED directly into the LogoTurtle's circuitry so you can add on and off commands for it in your drawing program. Here's how!

The basic problem is to add code to control a pin on the Metro that isn't being used. Pins 2-9 are used for the steppers and 10 is used for the servo. So we'll use pin 11.

First look in the folder where your Logo.jar file is and find sys.txt. Open it in any plain text editor. Find these lines in that file:
define on8 [][bsetb portb $01]
define off8 [][bclrb portb $01]
define on9 [][bsetb portb $02]
define off9 [][bclrb portb $02]
Now copy the lines define on9 and define off9 and paste it right below. Change it to the following, so you now have this:
define on8 [][bsetb portb $01]
define off8 [][bclrb portb $01]
define on9 [][bsetb portb $02]
define off9 [][bclrb portb $02]
define on11 [][bsetb portb $08]
define off11 [][bclrb portb $08]
How did we know to do this? Brian Silverman talked me and Josh Burker through how he added more pins when we were developing LogoTurtle. I personally didn't really understand it, but the pattern was that the $01 code is a hexadecimal number that doubles for each new pinout. So on a hunch I figured pin 10 would be $04 and pin 11 would be $08.
So save that and close it.
Now get an LED and solder on a 330 ohm resistor to the anode (positive) leg.















Print out this nice LED holder from Thingiverse (http://www.thingiverse.com/thing:1388637), insert the LED, and glue them together (I used hot glue).















Now connect up your LED to the Metro circuit. Put the resistor on the anode leg into the row connecting to pin 11 on the Metro. Put the cathode leg into the ground rail closest to the pen holder. Insert the LED holder into the pen holder hole.















Now get programming! Your new commands to control the LED are on11 and off11. Here is a sample program:
to startup
repeat 10 [
arcrt 18 50
on11 wait 100 off11
]
end
And here's what it does:


No comments :