Toymaker Television

Daily content for the geek and DIYer

4 notes &

Coding a Heartbeat Part I

In the spirit of Halloween, I’ve decided to take an idea suggested on the savagecircuits forums and work on coding a heartbeat.  This should combine both RCTime and photoresistors and include a whole bunch of new things like audio integration.

Goal: To code a heartbeat (audio/visual) that increases in rate and volume as you “get closer” and have it decrease in rate and volume as you “back away”

Step 1

So I’ve already figured out how to make the LEDs on a Propeller demo board blink as if a heartbeat (lub dub).  And I realize this may not be the best way to code it but it works!:

Step 2

But now I have to incorporate using RCTime to read the photoresistor.  I put the multimeter leads to it while blocking out light and having a bright light shining on it to see what its range would be:

Bright light shining: 200k ohms

Light blocked out: 400 ohms

So more resistance with more light, and less resistance with less light.

Now the coding portion is all sorts of…complicated and I don’t fully understand it but it calls a few “side programs” into the main program to help things work: Chiefly RCTIME and Parallax Serial Terminal (PST).  RCTime is essentially an ADC - converts the analog voltages from the photoresistor to digital values.  And for you to actually see it in action, PST shows the values being sent to the propeller chip:

When you run this program - the original code I wrote for the blinkey LEDs doesn’t show up, but you can at least see what the photoresistor is sending to the chip via the PST terminal (an exe file that’s included with PropTools, the program used to program the propeller):


Filed under rctime parallax serial terminal propeller halloween heartbeat programming spin proptools tymkrs coding for dummies

  1. tymkrs posted this