Intro to Physical Computing
Fall, 2003
Jeff Feddersen

Week 4

No funny business this time. Just work. All sentences. In fragment form.

Dan got eggs and bacon at deli Friday morning.
I coveted his breakfast.
But why were the eggs so yellow?
I mean: Yellow.

Forgot case, breadboard, and BX chip in room 406 Friday morning.
Returned over 6 hours later only to find everything exactly where I left it.
Faith in inherent goodness of mankind renewed.

There are 10 kinds of people in the world: Those who understand binary, and those who don't.

Stuck around to hear Todd's presentation. Stuck around longer to salvage parts. Found disassembled (disembled?) VCR in junk pile in shop area, or whatever that room is called.
Included in it were push-button switches (push: on, push again: off). Scavenged 4 or so by melting the solder off the underside of the board. Burned myself twice.
Learned to be afraid of the Knights of the Temple and the Freemasons.

QOTD: It just isn't fun until something explodes.

The BasicX software interface takes like, SIX full minutes to start or stop the chip. What the $%#!

Jeff mentioned a trick in class (awesome presentation on the sound/voice stuff, btw) for when you're getting comm errors: While the software is trying to re-establish communication (1 to 20 times) just power off and on quickly.
I tried it. It works.

Step 1:
"Wire LED's to pins 13-20 of your BX-24. Use the same digital output circuit from the previous lab. Write a simple for-next loop to light them all in sequence"
I would have written the code myself, but it's right there on the site, so I will C & P.

Sub main()
dim nextLightVar as byte

	call delay(0.5)  ' start  program with a half-second delay

	for nextLightVar = 13 to 20
		call putPin(nextLightVar, 1)
		call putPin((nextLightVar - 1), 0)
		call delay(1.0)
end sub

I tried it. It works. I only put in LEDs for pins 13 through 17, so there is a extra few seconds before the cycle repeats. The chip is busy turning on three pins that I'm not using.
I would take a picture, but a still photo doesn't capture the magic of this... this... sluggish theater marquee.

This string of obscenities uttered in an early Popeye(©) comic strip from 1931 is coincidentally the exact line of shell scripting that allowed Kevin Mitnick to access the Norad computers in 1983.

Step 2:

"Wire a switch to pin 5 of your BX-24. Use the same digital input circuit from the previous lab. Wire an LED to pin 20. Write a program that stores the state of pin 5 in a variable, and changes the LED based on that variable."

Okay. Again, this would be more challenging if we weren't given the answers. I'll use the code from the site. I'm using a pot instead of a switch, and one of those big fat yellow LEDs on pin 20.

dim switchVar as byte

Sub main()
	call delay(0.5)  ' start  program with a half-second delay

	switchVar = getPin(5)
	call putPin(20, switchVar)
end sub

If I put the LED in one way, with the long end (anode, right?) taking juice and the short end (cathode, right?) in pin 5, it works fine. Or I put it in the other way, with the long end in ground and the short end in pin 5.
The two ways were in the reading, and Jeff went over it again in class - The pins can blow 15mA, but can suck 20. So there you go.

Again, no pictures. I mean, what would a photo of an illuminated LED say to you?

Saw Philip Seymour Hoffman on the street today (Washington Square West) pushing a stroller. The kid was not cute.

Here's a paper on using a grid of LEDs in place of a standard CRT display:
(no, I didn't read it either)

But this page has a useful explanation of LEDs. This would be useful for Maia's digital display project.

Christina is trying to solve the world's transportation problems with a ball that rotates independantly in all three degrees of rotation.
Red Bull, the 'energy' drink is sponsoring a flügtag at pier 40 on the Hudson on October 5. Christina should enter. Hell, ITP ought to have a team!
I notice there isn't much communication between the second-year students and the first-years. Just like at Hogwarts. Yes. Just like that.

I am not a number, I am a free man!
But all the same, I am in group #6.
Matthias, Koichi, and I have come up with a topic. In six weeks, I will say, "You may now replace the socks that have been knocked off".

Step 3:

"Write a program that counts the number of times the switch has been switched on, and puts it in a variable:"

dim switchedOnVar as byte

Sub main()
	call delay(0.5)  ' start  program with a half-second delay

	if getPin(5) = 1 then
		switchedOnVar = switchedOnVar + 1
	end if
	debug.print cStr(switchedOnVar)
end sub

Okay. Even when the pot is cranked all the way to the other side (this is one of those taper pots, mind you) - there's still enough juice to register the pin as active.
So, I make a switch, a la Steve Oh, which is just two twist-ties stuck in the board.
Here we go.
Yes. It keeps repeating, and starts over once it gets to 256 (or 255? Does it count from zero or one?)

"Why does the counter run so high? How can you make the variable increment only once per switch press?"

Now here's a problem I like: a little logic puzzle.
This reminds me of the GRE.
All you have to do is add a variable that registers whether the switch is on or off.
Perhaps the following code would help illustrate:

dim switchedOnVar as byte
dim counter as integer
Sub main()
	call delay(0.5)  ' start  program with a half-second delay
		if ((getPin(5) = 1) and (counter = 0)) then
			switchedOnVar = switchedOnVar + 1
			counter = 1
			debug.print cStr(switchedOnVar)
		end if
		if (getPin(5) = 0) then
			counter = 0
		end if
end sub

It only increments the variable once when the switch is turned on. The switch must be turned off and on again before it will increment again.

My yelow led shines bright(ly)
You know why?
Because it's my Beacon of Hope

Did you hear that Robert Palmer died? I wasn't exactly a fan, but my brain can't help but remembering lyrics such as: "You like to think that you're immune to the stuff. Oh yeah." "Closer to the truth is that you can't get enough. You're gonna have to face it you're addicted to love."

Step 4 (optional step):
Connect 8 LED's to pins 5-12 of your BX-24. Run the following code to see the binary contents of a memory register reflected in the LED's:

Sub main()
	call delay(0.5)  ' start  program with a half-second delay

	dim counterVar as byte
	register.ddrc = bx1111_1111
	register.portc = bx0000_0000

		for counterVar = 0 to 255
			register.portc = counterVar
			call delay(1.0)
		call delay(3.0)
end sub
Okay, the leds should light in sequence, based on the curent register, which I'm incrementing with each loop. It's too slow, so I'm commenting out the delays. Hmm. I'll put them back, and add this line
debug.print cStr(counterVar)
The leds are on all the time, but change in brightness. However, I always forget which end is + and which is -, so I'll switch them around.

I think the problem is that all the leds are too close, and the metal ends come into contact. But I get the idea.

Why doesn't ITP have classes in music?
There are three disciplines that combine math and art:

  • Music
  • Architecture
  • New Media
Jean-Marc Gauthier covers architecture, how 'bout some music theory classes, hmm?

Step 5:

    Practical Joke, eh? I could:
  • Cover it in dog poo, set it on fire, put it on the floor outside Tom Igoe's office, then knock on the door and run away.
  • Tap it on the left shoulder, but I'm on the right, then when it looks - no one is there
  • Do the 5-timing switch thing.
I'll pick one randomly.
I want an oscillator so I can start making sounds. Here's a page on oscillators
I found a diagram to make an oscillator just out of resistors, put in proper order. It looked a little too complicated to try. Maybe later.

You know who has a cool name in our class? Luna Vega
Her first name is the moon, and her last name is a star.

When I was in college, one girl was named Victoria Zeppelin.
Apparently she was a descendant of the original Baron Von Zeppelin, after whom the airship and the subsequent rock and roll band were named.
I knew her boyfriend.
He was a jerk really swell guy.

Solder iron burns start out as white, then turn to dark mauve.

Sub main()
	call delay(0.5)  ' start  program with a half-second delay

	dim switchCounterVar as boolean ' is switch on or off
	switchCounterVar = false
	dim counter as integer ' how many times has switch been turned on
	counter = 0

		if ((getPin(12) = 1) and (switchCounterVar = false)) then
			switchCounterVar = true ' yes, pin is on
			counter = counter + 1 ' increment counter
		elseif (getPin(12) = 0) then
			switchCounterVar = false ' switch is off
		end if

		debug.print cStr(switchCounterVar)
		debug.print cStr(counter)

		if (counter > 4) then
			putPin 13,1 ' turn on pin
			putPin 13,0 ' turn off pin
		end if


end sub

This the 'practical joke', requiring the user to turn on the switch 5 times before the LED lights up. I tried the dog-doo approach, but Midori yelled at me.

The hardest part about this is remembering that comments are indicated with an apostrophe, rather than a double hyphen (as used in Lingo).

The Empire State Building used to always turn off their lights at midnight, but lately I've noticed that they leave them on until 4am or so. I've only noticed this since the blackout a month ago.

The Third Matrix preview is out. The second one was kind of disappointing, but it's still cool.

This is a robot site. They are hiring.

Okay, this is cool. In my readings I see that to make sound come out of a speaker, I need an amplifier. And the signal could be from a microphone or from an oscillator. But, the most basic amplifier is just a transistor, and an oscilator is just an amplifier with some kind of feedback loop. So, if I stick a transisitor in the board, I should be all done, right?

So I stick a mic in the board, one end getting red sauce, the other end in the middle pin of an NPN transistor. The speaker also gets red sauce, and its other end is in the right pin of the transistor. The left pin of the transistor goes to blue ground.

I switch on, and sure enough, I have a PA system. It's not loud, but I can hear myself in the speaker when I speak into the microphone.

So, now I want some feedback, so I stick a wire in that connects the input and output on the transistor. Right away I get a hum, the pitch of which is like that of fluorescent lights, a few hundred Hertz - definitely more than the 60Hz that is the frequency of electricity from the wall (in this country).

I want to vary the frequency to make different pitches. I try sticking a pot into the mix, and while I'm able to make a working volume control knob, I'm just varying the amplitude, not the frequency. If I throw some resistors and capacitors into the mix (specifically, within the feedback loop) I might have more luck. But that will be for the future.

I hooked up two transistors with a resistior, and now get a buzz sound of a higher pitch than the one before. The weird thing is, if I simply touch the paper cone on the speaker, the sound stops, but if I tap the metal frame of the speaker, it starts again. And if I lightly press the edge of the paper cone, I can make the pitch rise. None of this makes sense. And if I move my hand over the speaker without touching, the pitch drops. Totally weird. The buzz is probably completely a function of the size and shape of the paper speaker cone, rather than the frequency being sent via wires.

Stephanie says I look like 'The Commish'. Oh man. I realize that I have very little hair, but why not Bruce Willis? Or what about Benito Mussolini? Now, there was a guy who 'got things done'.

Found numerous diagrams on the Web for 'astable multivibrators'. The schematics look easy enough, just cross a pair of capacitors and two pair of resistors. But I couldn't get it to work. However, I haven't been looking at the numbers for any of this, and that could be the problem.

I read that a dial tone in a telephone is 440 Hz, the standard 'A' that is typically used to tune musical instruments. I tried to match the tone by ear to notes on my keyboard, but the dial tone sounds more like a 'C' and an 'F' sounding together.

The speaker is getting really hot in my 'telephone' setup, the magnet part anyway. The multimeter reading says it's getting around 22 volts - can that be right? And 5 ohms of resistance, that would explain the heat. I also get a reading of 1.25 volts AC. Can that be right? I took out the feedback loop, so there's no cycling signal, which I imagine would register as AC. No wait, that wasn't AC, that was 'DC A'. I don't even know what that is.

That was the baby speaker. When I put in the mondo speaker, the signal seems a little louder, but that may just be because the larger speaker can handle a larger bias - range of sounds - especially the bass. The mondo speaker is getting 5 volts. That seems right. And 12 ohms across the terminals. If v=i*r, then the current, i, should be equal to 12/5, or about 2.4, uh, milliamps? The numbers don't change when there's an active signal (me whistling into the microphone). I figured I would have seen something fluctuate.

When I put the feedback loop in, and match it to my keyboard, I get A#. That's odd.

Here's a diagram of a basic transistor amplifier. Let's try it. Nope. Nothing. Here's another but that looks more complex. Geez, so may designs, and all different. And none work as well as skipping all the capacitors and resistors altogether, and just linking a mic and speaker via a single transistor.

Soldering speakers is challenging because the magnet is always trying to pull the iron toward itself.

Have a third speaker, middle in size, rated at 8 ohms, 0.2 watts. The big one is 3 watts. Watts = volts * amperes, so 3w = ?v * ?a Umm, my math says that the current would be the square root of 3/8. Who knows. Mulimeter says it carries 35 ohms. That can't be right. That's not even the right significant digit, let alone which factor of ten it is.

Solder is obsolete.

Microphones and speakers are basically the same thing, and I've used headphones as microphones in the past. I plug in the middle speaker in place of the mic, but just get buzz, no voice. But this time, manipulating the big speaker doesn't give me the variation in pitch like it did before.

Matt Slaybaugh
ms171 at