Now that there has been an introduciton to coding and a competancy for circuit design, it's time to put them together to design a system with some sort of output device. I'll be trying to tackle two things this week an optical output and a mecahnical output. For the optical output, I'll be testing out using a seven segment display, and for the mechanical I'm hoping to use a vibrating motor to make a mechanical cockroach.
There's this rather cool physical phenomenon by which a vibrating system on curved feet will progress forward by rotating from side to side. I'm hoping to take advantage of this by making wire feet, attaching the vibrator motor, and using a light sensor to detect ambient light levels and have the cockroach "run away" when the light turns on.
The curcuit ended up being a bit of an ugly brute to design, as I'm hoping to power the first iteration using a USB cable to save on draining the batteries. A later iteration will be less bulky. Eagle was used to generate the circuit, and a resistor was used as a placehoder for the motor leads.
Programming of the board was done in an Arduino Environment. It ended up (in theory) being a very simple code. The pin connected to the photoresistor was declared an input, and the current reading with some threshold was set as a trigger point. If the level detected was higher than this, it would trigger the system.
#define photo 8 #define MOTO 7 int threshold = (analogRead(photo) + 15); int vibr = 2000; void setup() { // put your setup code here, to run once: pinMode(photo, INPUT); pinMode(MOTO, OUTPUT); digitalWrite(MOTO, LOW); } void loop() { // put your main code here, to run repeatedly: digitalWrite(MOTO,LOW); while(photo > threshold) { digitalWrite(MOTO, HIGH); } }
Next step was an attempt to program the board from my computer. I had issues with this last week, but on the Xubuntu partition. In an attempt to rectify this, I installed arduino on the Windows partition to find the same problem was occuring:
Error: Courld not find USBtiny device (0x1781/0xc9f)
I was unable to find a solution to this problem on my computer, though I was able to successfullly program the board (shown below) using another person's computer. The legs were bent wires attached using "Goop".
This is were I noticed that I'd made a mistake in my wiring. Though the board was certainly getting power from the USB, there was no obvious change in the motor when light was shined on the photoresistor. It turned out that I'd confused the source and drain location, as well as where the motor should be located relative to the MOSFET. A total redesign was required, and relatively quickly completed schematic and board shown below.
As you will likely note, the board is not fully cut from the copper substrate. While I was cutting with the 1/32" endmill, I neglected to propperly tightent the set screw, and the endmill descended into the part, snapping the head. I replaced this with a new endmill, and checked to see if the top of the bit was still lodged in the board. I couldn't see it, so I restarted the cut. Unfortuanately, the first head was in fact still wedged, and this broke the second endmill.
I decided to call it quits, planning too cut it with a dremel when I got back to my room if it worked. I stuffed the board, and am at this point waiting for the opportunity to use a friend's computer to program it.