Physical Computing Journal


Week One

Getting Started
 
Not much to report this week. Still trying to figure out HTML. Found parts needed for class two and did the readings (Buxton and Petzold). Took tool safety class as well.
 

 

Week Two

 Basic Electronics
 
This week was devoted to setting up the voltage regulator. I bought a 49 cent plastic box and made holes with a drill to support the switch and power supply. Had some fun soldering things together, the key, however, is to find an iron with a good tip and heat the objects that are to be soldered (keeping the heat at about 3 or so).
 
After following the example we partially did in class, I got a voltage that varied between 4.95 and 5.05VDC, which I thought was great (+/-1%). The tolerance of other components, e.g., resistors, is about +/-20%. I set up the breadboard so it could be powered by the 12V wall wart or a 9V battery, since wall warts can become cumbersome to carry around. The battery output about 8.77V. I think I should monitor this over time to see how much the voltage of the battery varies.
 
 
 
I next lighted a couple LED's in series. I couldn't get a third to light (needed more volts). However, I then wired them up in parallel and that worked fine. For my next trick, I played around with a photoresistor, so that when someone passed closely by the breadboard, some LED's would light up. I also played around I purchased a flex sensor at the bookstore when I was buying equipment the week before and wired that up. It worked in only one direction, and was difficult to see with the LED. I presented this in class, and Jeff suggested I could wire-up a voltage divider to give it more juice.
 

 

Week Three

Digital Input and Output Using the BX-24
 
This week was considerably more exciting. I prepared the box for the serial input and outputs, and installed and powered the BX chip. I was careful to orient it properly and count the pins correctly, so it didn't blow up.  I took the voltage out of the 7805 and sent it to pin 21, connected ground to pin 23.  The BX’s LEDs happily blinked red and green. 
 
I then proceeded to create a serial connection.  I made an adaptor, and with pins 2 through 5 of the serial cable adaptor connected to pins 1 through 4 of the BX, I connected a serial cable to port one on the computer.   I then proceeded to program the chip.  I got BasicX up and running, created a module for myself, and programmed:
 
 
  Sub main()
        call delay(0.5)  ' start  program with a half-second delay
 
        do
                call putPin(13, 1)
                call delay(0.5)
                call putPin(13,0)
                call delay(0.5)
        loop
end sub
 
I compiled and ran the program, and it blinked.  A rosy-colored dawn…
 
I then spent some time with switches.  I first got a 10kOhm resistor, tied it between ground to pin 7’s bus, then put a switch between power and the bus of pin 7.  I edited the above program and put a debug.print statement in the do loop.
 
debug.print "pin 7:" ; cstr(getPin(7))
 
 
I continued on by combined switches with LEDs such that:
 
if getPin(7) = 1 then
        call putPin(13,1)
else
        call putPin(13,0)
end if
 
I tried other pins and tried lighting more LEDs.  I also got them to blink oppositely such that if one was on, another was off, again using an if statement.  I presented this in class.
I also checked out the Petzold reading on Code and sections of the language reference. 
 

 
Week Four

Memory and the BX-24
 
This week’s lab assignment mirrored what we were doing in ICM the previous week.  I also had to do my tech presentation research project, whose documentation can be found on http://stage.itp.tsoa.nyu.edu/%7Emk1062/pcomp/research/. 
 
Step one of the assignment was to write a simple for-next loop to light the LED’s in sequence:
 
Sub main()
dim nextLightVar as byte
 
     call delay(0.5)  ' start  program with a half-second delay
 
do
     for nextLightVar = 13 to 20
          call putPin(nextLightVar, 1)
          call putPin((nextLightVar - 1), 0)
          call delay(1.0)
     next
loop
end sub
 
This was easy to accomplish.  Step two was also relatively quick.  I wired up a switch using a digital input circuit.  Based on the state of pin 5, the LED in 20 was turned on or off:
 
dim switchVar as byte
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
 
do
     switchVar = getPin(5)
     call putPin(20, switchVar)
loop
end sub
 
 
In step three, I just took the code online and added a mod statement such that the counter only counted every tenth loop.  I didn’t get to step four (on memory registers, e.g., register.ddrc, register.portc) because I was busy on the technical research project.  I put an LED on my board to tell me that there is power on or off, because it is easier to see than the side of my box where the switch is.  Checked out the Crawford article that explored the buzzword “interactivity”.
 

 

Week Five

 Analog-to-Digital Conversion Input
 
The lab assignment this week focused on variable resistors and analog sensors.  I had purchased and/or found various flex sensors and potentiometers and photoresistors, and experimented with them this week.  I connected a 10kOhm pot up to the microcontroller and programmed the BX-24 to read the voltage using getADC:
 
dim potVar as integer
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
 
     do
          potVar = getADC(15)
          debug.print "potVar = " ; cstr(potVar)
     loop
 
end sub
 
The output in the debug window varied from 0 to 1023, depending on how far the potentiometer was turned.  I put a 10kOhm resistor between the pot and the ground, and the range changed to 90 to 1023.  When I put the same resistor between +5V and ground, it varied from 0 to 969.  (There are 1024 values, corresponding to 2^10 power.) Basically, I was making a voltage divider. 
 
For step two, I connected a flex sensor up to the circuit.
 
With the 220 Ohm resistor, the range of voltages was 11 to 135; with the 10kOhm resistor, 26 to 420; for the 100kOhm resistor, 119 to 907.  I also experimented with the values at different setting of the pot, which basically either increased or decreased the range.  It looked like a linear relationship based on the numbers being output in the debug window.
 
For step three, I wired up a bunch of LEDs, this time using the chip as a sink.  This increased the brightness of the LED’s such that I could light up three in series, which I couldn’t do in the first lab.  I then programmed the chip so that more LED’s would light up as the voltage was increased, simulating a LED bar display. 
 
After this, I wanted to start testing the servomotor that I had bought at the NYU Computer Store earlier in the month.  I tried the following code, and wired it up with the rest of my LED set-up:
 
 
dim potVar as integer
dim minPulse as single
dim maxPulse as single
dim pulseWidth as single
dim refreshPeriod as single
dim pulseRange as single
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
     minPulse = 0.0008
     maxPulse = 0.0022
     pulseWidth = minPulse
     refreshPeriod = 0.02
     do
          potVar = getADC(13)
          call pulseOut(13, pulseWidth, 1)
          pulseRange = maxPulse - minPulse
          pulseWidth = minPulse + ((pulseRange*cSng(potVar))/100.0)  
          call sleep(refreshPeriod)
 
          call putPin(19,1)
          call putPin(18,1)
          call putPin(17,1)
          call putPin(16,1)
 
          debug.print "potVar = " ; cstr(potVar)
          if ((potVar>0) and (potVar<258)) then
               call putPin(19, 0)
          elseif((potVar>257) and (potVar<516)) then
               call putPin(18, 0)
               call putPin(19, 0)
          elseif((potVar>515) and (potVar<768)) then
               call putPin(19, 0)
               call putPin(18, 0)
               call putPin(17, 0)
          elseif((potVar>767) and (potVar<1024)) then
               call putPin(19, 0)
               call putPin(18, 0)
               call putPin(17, 0)
               call putPin(16, 0)
          end if
     loop
 
end sub
 
I had the pulse going out of thirteen, and it seemed to work, however, I never incremented the pulsewidth enough to get it to move its entire motion, and the LED’s I had were blinking everytime the servomotor moved.  Jeff gave me some pointers, which I implemented in week seven.  It certainly did not make sense to have the pulseOut command coming out of the same pin as the potVar.
 
The reading for this week was Chapter One of the design of everyday things: “added complexity and difficulty cannot be avoided when functions are added, but with clever design, they can be minimized.”
 

Week Six

Controlling Big Switches
 
The goal of the lab assignment was to get comfortable with the idea of a relay/transistor as a means of controlling motors and other devices that may need their own power supplies.  I obtained a couple motors, one that had only 1.5-3V and then one that had a range between 5-18V.  The small motor I ran off my board, and added different resistors to change the speed of the motor.  It was difficult to tell how fast it was rotating, so I put some tape on it and made some marks.  Still, quantification was impossible.  (I might have tried using an oscilloscope or something??)  I also got the larger motor to turn as well, however, I used my 12V power supply to test it.  These are high-revving motors (18,000RPM).  I figured motors might need more amps than what a BX-24 might need, so it would make sense for it to have its own power source.  During this step, I found that I had a switch that was faulty, which I diagnosed using physical debugging (LEDs).
 
For step two, I connected up the TIP120.  The most difficult part of this was keeping track of what pins corresponded to the base (1), the collector (2), and the emitter (3).  I used a battery to power my board, and my 12V power supply to power the larger motor.  Since the motor causes transients when it turns on and off, in addition to the capacitor I had on pins 2 and 3 of the 7805, I added one between the +5V and ground buses.  With a new switch on 14, I used the following program to turn the motor on and off:
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
 
     do
          call putPin(13, getPin(14))
     loop
end sub
 
 
I then started to play with the program so that it wouldn’t just spin very fast.  It was also a challenge to attach anything to the axle of the motor; I ended up attaching tape and making a fan.  I also replaced the switch in the circuit with a potentiometer.  The end result was a pulsing wave of air (like a sound wave), since the fan would blow fast, and then slow, and then ramp up again. 
 
 
I checked out the Ken Rinaldo’s Autopoiesis installation online. 
 

Week Seven

ADC Output
 
This week’s lab was concerned was the servomotor and applying the concept of pulse width modulation.  I had some serial communication issues at first, since my serial connector disappeared.  Once over that hurdle, I connected everything up and wrote the code that should have pulsed the servo through its 180 degrees, and then set it back to zero degrees.  However, the motor was only vibrating.  I was powering it off the 9V battery, which still had plenty of voltage.  Realizing it might be a problem with current, I switched over to the 12V power supply, and the motor began to work.  Unfortunately, I left the 9V battery in, which promptly exploded (not seriously). 
 
Luckily, my BX wasn’t hurt, and everything still worked.  I varied the minPulse and maxPulse parameters as well as the refresh period and the amount the pulsewidth incremented per loop (it would reach the full extent of motion faster as the increment was larger).
 
 
 
' Servo testing example
'    in this example, a servo attached to pin 12
'    should travel slowly from one side to the other,
'    then quickly back to the beginning.
'    The program starts pulsing the servo at its
'    minimum pulsewidth, then increments the pulsewidth
'    a small amount with each new pulse until it reaches
'    the maximum pulsewidth.  Then it sets the
'    pulsewidth back to minimum.
Option Explicit
 
dim minPulse as single         ' the minimum pulseWidth
dim maxPulse as single         ' the maximum pulseWidth
dim pulseWidth as single     ' the servo's pulsewidth
dim refreshPeriod as single ' the time between pulses
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
 
minPulse = 0.0008
maxPulse = 0.0022
pulseWidth = minPulse
refreshPeriod = 0.02
 
     ' the main loop:
       do
         
          ' pulse the servo:
          call pulseOut(11, pulseWidth, 1)
 
             ' increase the pulsewidth for the next pulse:
          if pulseWidth <= maxPulse then
                    pulseWidth = pulseWidth + 0.00001
          else
                    pulseWidth = minPulse
          end if
 
          ' wait 20 milliseconds before pulsing again
          call sleep(refreshPeriod)
     loop
End Sub
 
 
I also tried the multitasking servo example, which also seemed to work.  I just wanted to get familiar with the way to program a task by “dim”ming a servostack.
 
 
 
' Servo testing example
 
 
const servoPin as byte = 12    ' the pin the servo is on
const refreshPeriod as single = 0.02' the time between servo pulses
 
 
 
const minPulse as single = 0.0003   ' the minimum pulseWidth
const maxPulse as single = 0.0022   ' the maximum pulseWidth
 
dim pulseWidth as single            ' the servo's pulsewidth
 
 
dim servoStack(1 to 30) as byte     ' memory for the servoTask
 
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
 
     debug.print "start"
 
     ' set initial values for variables:
     pulseWidth = minPulse
    
     ' start the servoTask loop running:
     callTask "servoTask", servoStack
    
     ' the main loop:
     do
          pulsewidth = minPulse
          debug.print "minimum angle"
          call sleep(2.0)
 
          pulseWidth = ((maxPulse - minPulse) / 2.0) + minPulse
          debug.print "middle"
          call sleep(2.0)
 
          pulseWidth = maxPulse
          debug.print "maximum angle"
          call sleep(2.0)
 
          ' this sleep makes sure your main loop runs
          ' as much as possible.
          call sleep(0.0)
     loop
End Sub
 
sub servoTask()
     do
          call pulseOut(servoPin, pulseWidth, 1)
 
          ' wait 20 milliseconds before pulsing again
          call sleep(refreshPeriod)
     loop
end sub
 
 
For step two of the lab assignment, I connected my 10kOhm pot and ranged the motion such that when the pot was closed, the servo was at zero degrees, and when the pot was open, it was at 180 degrees.  I began ranging assuming that the divisor would be somewhere around 2^10.  I helped some other people use photosensors and flex sensors and range them as well, based on the total range of the sensor.  My pot program looked like this:
 
Option Explicit
 
dim minPulse as single         ' the minimum pulseWidth
dim maxPulse as single         ' the maximum pulseWidth
dim pulseWidth as single     ' the servo's pulsewidth
dim refreshPeriod as single ' the time between pulses
dim pulseRange as single  ' the range of possible pulses
dim sensorValue as integer  'gets pot voltage
 
 
Sub main()
     call delay(0.5)  ' start  program with a half-second delay
     minPulse = 0.0003
     maxPulse = 0.002
     pulseWidth = minPulse
     refreshPeriod = 0.02
     pulseRange = maxPulse - minPulse
 
     ' the main loop:
       do
          sensorValue = getADC(13)
          if (sensorValue > 1000) then
               call putPin(14, 1)
               call putPin(15, 1)
               call putPin(16, 1)
          elseif (sensorValue > 500) then
               call putPin(14, 1)
               call putPin(15, 1)
          elseif (sensorValue > 0) then
               call putPin(14, 1)
          end if
          debug.print "sensorValue:"; cstr(sensorValue)
          pulseWidth = minPulse + ((pulseRange * cSng(sensorValue)) / 750.0)
          ' pulse the servo:
          call pulseOut(12, pulseWidth, 1)
               call putPin(14, 0)
               call putPin(15, 0)
               call putPin(16, 0)
 
          ' wait 20 milliseconds before pulsing again
          call sleep(refreshPeriod)
     loop
End Sub
 
As you can see, I combined my LED voltage meter display (like what I did in week five) to correspond to the degree to which the pot is open, and therefore how far the servo goes.  This was basically what I unsuccessfully tried to do in week five.  I also managed to get the LEDs to stop blinking, using a low pass filter circuit.  I used a 1 microF capacitor, since the 10microFarad ones made them too weak to see in normal room light.
 
I read the Norretranders article as well, and found his description of consciousness interesting.
 

Week Eight
Serial Intro

 
This week I experimented with asynchronous serial communication and getting bytes into the terminal program. I actually attempted the assignment after I did the midterm, so I took apart part of the midterm project (sadly) and began wiring up the ground wire, and decided to eliminate the 22K resistor on pin 12 (since RS-232 is robust enough not to need it). Pin 2 on the nine-pin serial cable went to pin 11 on the BX (PC receive, BX transmit) and pin 12 was the BX receive and the PC transmit on pin 3 of the serial connector. Ground was on pin 5 of the serial connector.
I did not have an extra serial cable, so I kept switched from pins 1-4 then to 11, 12 and ground. I programmed the BX as follows:


dim inputBuffer(1 To 13) As Byte '4-byte output buffer.
dim outputBuffer(1 To 50) As Byte '1-byte output buffer.
dim thisByte as byte
sub main ()
call delay(0.5) ' start program with a half-second delay
' define which pins COM3 will be
' (input pin, output pin, baud mode):
call defineCom3(12,11,bx1000_1000)
' set aside memory for input and output:
call openQueue(inputBuffer, 13)
call openQueue(outputBuffer, 50)
' open COM3:
call openCom(3, 9600, inputBuffer, outputBuffer)
do
' read the switch, convert it to a readable ASCII value:
thisByte = getPin(15) + 48
' send it out the serial port:
call putQueue(OutputBuffer, thisByte, 1)
loop
end sub


This seemed to work and the BX was programmed; the buffers contained 9 bytes for the BX and the rest of the bytes for the output buffer itself. The input pin corresponded to pin 12 (BX input) and output was 11. The number 48 corresponds to a readable ASCII value, since the value on the pin could be zero. I then found Hyperterminal. I remembered to close the port on BasicX, so I went back and did that. I selected Com2 and adjusted the settings to 9600 baud, 8 bits, no parity, 1 stop bit. At first run, I got a bunch of smiley face characters. I switched around 11 and 12 in the call defineCom3 line to see what would happen, and ended up getting !! characters. I was trying to figure out at the time what input and output were being referred to in the defineCom3 line.
For the second part of the lab, I connected up an analogue sensor to pin 14 (a photoresistor). This only required a simple change to the code, such that thisByte = cByte(getADC(14)\4). It is divided by four since 2^10 = 1023; a byte is 0-2^8. I was able to make some pretty patterns with the code, since the terminal was getting the data at a more or less steady rate:
...NNNNNNNNN.......NNNNNNnNN........NNNNnNnNN......NNNnNnNNNNN....NNNnNnnnNNN.NNN
NNNNnnnnnnNNNNN.NnnnÎÎÎήÎnnnNNNNnnÎÎÎή®ÎÎnnnNNNnnή®®®®®ÎÎNNnnnnÎή®®®®®Înnnnn
nÎή®®®®Î®®nnnnnnnÎήÎÎή®ÎnnnnnnnÎή®ÎÎήÎÎnnnnnή®®ÎÎή®ÎÎÎnnnÎÎήÎÎÎÎήÎÎÎÎnÎ
ή®®îîîîή®®ÎnÎή®ÎÎîîîîÎή®ÎÎÎή®ÎÎîîîÎήÎÎnÎÎÎÎÎîîîÎή®ÎÎÎή®Îîîîîîîή®ÎÎή
®ÎÎîîîÎήÎÎÎή®®ÎîîîîÎÎÎÎÎÎÎή®îîîîή®ÎÎÎήÎÎîîîîîήÎÎÎÎή®ÎîîîîήÎÎÎή®
ÎÎîîîîÎÎÎÎÎÎÎή®ÎîîîîÎήÎÎÎή®ÎÎîîîîήÎÎÎή®ÎÎîîîîήÎÎÎÎή®Îîîîîîή®ÎÎÎή®
Îîîîή®ÎÎÎή®®ÎîîîîήÎÎÎnÎή®îîîîîÎήÎnÎÎή®ÎÎîÎîÎήÎÎnnnÎή®ÎÎÎÎήÎÎnnnnnÎή
ήή®®ÎnnnnnÎή®ÎÎή®ÎÎnnNnnÎή®®Î®ÎÎnnnnnnnÎÎή®®ÎÎnnnnNNnnnnÎήÎÎÎNNNN..NnNnnn
nnnNN.N.N.NNNnNnnNnN.....NNNNnnnnnN........NNNNNnNN........NNNnNNN.N.......NNNNN
NNN......N.NNNnNNN.......NNNNNNNNN.......NNNNNnNN.N......NNNNNNNN.......NNNNNNNn
N........NNNNNNNN.......NNNNNNNN........NNNNNnNNN.......NNNNNNNN.......NNNNNNNNN
N......NNNNNNNNN.......NNNNNNNNN.......NNNNNNNN.N......NNNNNNNNN......NNNNNNNNN.
.......NNNNNNNNN.......NNNNNNNN.N......NNNNNNnNN.......NNNNNNNN........NNNNNNNN..
......N.NNNNNNN.......NNNNNNNNN.......NNNNNnNN........NNNNNNNNN......NNNNNNNNN...
.....NNNNNNnNN.......NNNNNnNnNN......NNNNnNNN.......N.NNNNnNN........NNNnNNNNN...
...NNNnNNNnnNNNNNNNNNNnnnnÎnnNNNNNNNnnÎÎήήÎÎnnNNnnnnÎή®®®ÎÎnnNnNnnnή®®®®®ÎnNn
nnnÎή®®®Î®®ÎÎnnnnnÎή®Î®Î®®Înnnnnnή®Î®Î®®ÎÎÎnnnnnÎήÎήή®ÎÎnnnnnÎήÎÎÎή®ÎÎnn
ÎÎή®ÎÎîîÎή®ÎÎnÎή®®Îîîîîή®®ÎnÎήÎÎÎîîîÎήÎÎÎÎήÎÎÎîîÎήÎÎÎÎή®îÎîîîÎÎÎÎÎÎ
Îή®ÎîîîÎÎÎÎÎÎή®ÎîîîîÎÎÎÎÎή®ÎÎîîîή®®®Î®ÎÎîîî®®®ÎήÎÎÎ.îîή®Î®
®ÎÎÎîîή®®Î®®Îîîîή®®®®®Îîîîî®®®Îή®ÎÎîîîή®ÎÎή®ÎÎÎîîîÎή®ÎÎή
®ÎÎÎîîîîήÎÎÎÎή®ÎÎîîîîήÎÎÎή®®ÎîîîîîήÎÎÎÎÎήÎîÎîîÎήÎÎnnnÎή®Î®Îή®ÎnnnnnÎÎ
®®ÎÎÎήÎÎnNnnÎn®®®®ÎήÎÎÎnnnnnÎή®Î®Î®ÎÎnnNNnnÎÎήή®ÎÎnnNnNnnÎή®®®ÎÎnnnnNnnnÎÎ
ήÎήÎnNnNNnnnnÎήÎÎnnNNNNNNNnnÎÎnÎnnnNNNNN.NnNnnnnnN......NNNNNnnnNNN......NNNN
nnnNN......N.NNNNNN.N........NNNNNNN.........NNNNNN.......NNNNNNNNN......NNNNNN
NNN......NNNNNNNNN.......NNNNNNnN.N......NNNNNNNNN......NNNNNNNNN.......NNNNNnN
NN.......NNNNNNNNNN......NNNNNNnNN.......NNNNNNNN........NNNNNNNN.......NNNNNNNN
N.......NNNNNnNNN.......NNNNNnNN.N......NNNNNNNNN.......NNNNNNNN.......NNNNNNNN.
I changed resistors between the photoresistor and ground to get different ASCII characters as well (ASCII is a standard and a priori has nothing to do with the voltages being read). I attached an LED to the output of the microcontroller (pin 11) and saw the LED flash; however, it flashed very quickly, almost to the point of imperceptibility.
I also got to send a string out of the BX. The trick was to dimension the output buffer and call the command putQueueStr. I did not make a Luv-O-Meter, but it would be a simple matter of using if (condition of sensor) then putQueueString(clever thing to say).

 


Week Nine
Midterm


For documentation of the midterm, see http://stage.itp.tsoa.nyu.edu/~mm1754/phcom/week7/. The midterm essay can be found at http://stage.itp.tsoa.nyu.edu/~jml401/pcompessay.

 


Week Ten

Talking to Director


This week was interesting. The ICM and Pcomp material coincided and connected in interesting ways, giving me ideas for lots and lots of projects I would love to get to. I used Geoff Smith's serial xtra for Director and downloaded it onto a PC in the PC lab. I put the extra in the folder containing my Director movie. This seemed to avoid the problem of being at such a promiscuous environment as ITP and having different xtras at different machines. I used three sensors in my program: a switch, a pot, and a photocell. My first step was to make sure the circuit on the circuit board was set up correctly. I used the debug.print commands to do this. I had trouble at first because I had not grounded the photocell, and the switch had a soldering problem. Once those two problems were diagnosed, everything seemed fine. I packed it up for the day in fact.


Only to find that the next day, nothing would work. At first I couldn't download anything. Then I was able to program the chip, but only got gibberish out. I diagnosed the problem one step at a time. First, I tested the chip turning on and off an LED from each pin. I made sure the board was getting proper power. I tested different serial cables and connectors. I tried different Com ports. Did it all. After a few hours of this, I tried a different computer and it worked, with the same equipment, code...everything. Here's the BasicX code:

'using a POT on pin 17
'using Photocell on pin 15
'using Switch on pin 13Sub Main()
dim invar as byte
dim outvar as integer
dim variableResistor as integer
dim pulsewidth as integer
dim pos as single
'set up a buffer
dim InputBuffer(1 to 10) as byte
dim OutputBuffer(1 to 10) as byte
call openQueue(InputBuffer,10)
call openQueue(OutputBuffer,10)
'set up the port
  call defineCom3(12, 11, bx1000_1000) ' defineCom3(InPin, Outpin,
parameterMask)
call openCom(3,9600,InputBuffer,OutputBuffer) '9600 baud
debug.print "start"
do
'''''''deal with another variable resistor and send it
variableResistor = getADC(15)
'debug.print cStr(variableResistor) 'determine that I get numbers 50 - 230
if variableResistor < 1 then
variableResistor = 1
end if
if variableResistor > 255 then
variableResistor = 255
end if
call putQueue(OutputBuffer,variableResistor,1)
'''''''deal with one variable resistor and send it
variableResistor = getADC(17)
'debug.print cStr(variableResistor) 'determine that I get numbers 0 - 1023
variableResistor = variableResistor\4
if variableResistor < 1 then
variableResistor = 1
end if
if variableResistor > 255 then
variableResistor = 255
end if
call putQueue(OutputBuffer,variableResistor,1)
'''''''deal with the switch and send it
outvar = cInt(getPin(13)) + 65
  'debug.print cStr(outvar)
'so you don't send 0 (the nasty null char) or 1 but 65 or 66, "A" or "B"
call putQueue(OutputBuffer,outvar,1)
call getQueue(InputBuffer,invar,1) 'program stops until it hears something
loop
end sub
So, once I had the data coming out, I went into Director and programmed a Lingo program that would move a ball left and right, change the shape of a sprite depending on the switch state, and change the blend of the ball based on the photocell. I had some trouble getting everything to communicate, but it finally began to work after I carefully went through the Lingo. I then changed the Lingo a bit so that the three sensors controlled the vertices of a vector graphic, using the movevertex command, such that the ball would morph into a Calder-esque shape.
The next step was to take the midterm glove and see if we could get that to work at all. We got the serial data out, but didn't write up a Lingo program to do anything with it yet.