NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » E-Spock (You've Got Spock)

May 09, 2009
by paulip
paulip's Avatar

The purpose of this project was to trigger an external event when my boss received an email from me. I decided to use a talking Spock bobblehead as the device of choice.

This project was interesting less because of the complexity and more because of the 5 steps it took to complete. They are as follows:

1) Wiring the breadboard 2) Programming the microcontroller 3) Programming Visual Basic in Outlook 4) Automating Outlook to trigger the Visual Basic script 5) Wiring the bobblehead

1) Wiring the breadboard. As you can see, it’s a very simple design. Basically I took the design from the Water Squirter tutorial from the Nerdkits site. It had all of the elements I needed already. I stripped it down and just used PB3. This as you can see triggers a light which I use as to prove that the code worked and a MOSFET transistor hooked up to a cheap Radio Shack 5v relay. All of the rest of the water gun wiring was unneeded. I also used a power supply from an old cell phone…why buy when you can re-use old junk.

Board

2) Programming the microcontroller. Once again I went back to the water Squirter Code C code. Being lazy, I left all of the code intact. What I really needed from it was that when a “1” is sent from the PC down the COM port it triggers PB3. DONNYC from this forum helped me with timer code which resets the controller back to its natural state after 10 seconds.

3) Programming Visual Basic in Outlook. This could have been the hardest part of this project if it wasn’t for the support I got from Humberto and mike at the Nerdkits team. They sent me Serial Port Code which enabled me to have Visual Basic trigger COM port events. Here is the code I used VB Code. As you can see, its identical to the tutorial I received…just ported from Excel. The significance is that you can run a com port without MSCOMM.dll activex. To use that you’d need the whole VB suite…Quite annoying if you just want to do a couple of things with a com port.

4) Automating the Outlook trigger. This was perhaps the trickiest part of the project. In Outlook you can of course use filters to cause an event when Outlook receives an email. There are 2 ways to trigger an event outside of Outlook. You can have the filters run an .exe...but that brings us back to having to program in Visual Basic Studio…or you can use “Scripts” in Outlook. Scripts are tricky in that only 2 events in Outlook can be triggered by a script… outlook.mailitem and outlook.calendaritem. By defining (Item as Outlook.Mailitem), Outlook is able to run the script named “Comm_Script”. As you look at this section of VB code, you can see that I stole this from the Serial Port tutorial…and once again I left a lot of extra code in it…Lazy but functional…What you should look at is that all of the baud and com port settings can be done right in Outlook.

Sub Comm_Script(Item As Outlook.MailItem) Dim intPortID As Integer ' Ex. 1, 2, 3, 4 for COM1 - COM4 Dim lngStatus As Long

 intPortID = 3

' Open COM port
lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
    "baud=115200 parity=N data=8 stop=N")

Dim strData   As String

intPortID = 3
strData = "1"

'Writa data lngStatus = CommWrite(intPortID, strData)

intPortID = 3
lngStatus = CommRead(intPortID, strData, 10)

intPortID = 3
Call CommClose(intPortID)

End Sub

5) Wiring Spock. This was actually trickier than it appeared. Bobbleheads have an accelerometer switch in their necks…But when I tried to bypass it through the relay I put on the breadboard, the relay only worked if the bobblehead was laying on its side (weird)…So I just yanked the accelerometer out and bypassed it completely..success…

Spock

May 10, 2009
by DonNYC
DonNYC's Avatar

Nice work.

Please post your bosses reaction!

Don

Post a Reply

Please log in to post a reply.

Did you know that an electroluminescent backlight for an LCD panel requires hundreds of volts AC to run? Learn more...