Labs are listed in reverse chronological order.
Weeks 10-14: Final Project
Final Project Updates and specific Pcomp notes. Code in progress (12.2)- Attach:table3.txt
Week 9: Final Project Ideas, MIDI
Visit my new PComp site, which includes final project ideas and links to the group projects documentation. Did the MIDI lab - the simple version (no opto-isolator), and using Michael's code. Not enough time to experiment more with it right now...
Week 8: Motor Lab
Kate and I did the motor lab together - the one with the TIP. I'm ordering the parts for the MIDI lab now - it would be great to further the umbrella project with MIDI sound.

Weeks 6 and 7: Group Tool Project
Check out our Umbrella Project documentation and prototype: http://www.overainslie.org/rbray/pcomp/umbrella/
Week 5: Serial I/O, Processing
Serial to Desktop Lab (Processing)
Wrote the code in text style first, modifying this code. Got an ellipse onstage to react to sensors. Code uploaded: 10.10.toprocessing.txt. And the code for Processing itself: 10.10.processing.txt. But, I want to get more control. I also want to play around with the photo cells more to get a better range. Also tried out the binary code example, but a code error message I haven't been able to debug yet.
Did a series of call and responses with input from keyboard calling up results from sensors and such. This all worked fine, although I had some issues with setting up HyperTerminal?. Serial Communicator worked fine though.
Step 1 - got back series of 1's when toggle was on, 0's when off.
Step 2 - used potentiometer. Changed code to get output. Got readout from pot of range 0-1022. Also did thisByte of pot reading divided by 4, to get a byte. His questions: why convert the result of the ADC reading to a byte? why divide the result by 4? why does the result look like gibberish in hyperTerm? My results don't look like gibberish - it looks like the pot readings divided by 4? As I understand it, you want to divide by 4 in order to come up with a number between 0 and 255. Code is uploaded: 10.10.step2.txt
Step 3 - LED test...
Step 4 - cheesy love tester on pot:
' send message depending on pot reading
IF adcVar > 1000 then
SEROUT2? portc.6, 16468, ["You're so passionate!"]
endif
IF adcVar < 500 then
SEROUT2? portc.6, 16468, ["You need to work on your finger muscles!"]
endif
Week 4: Analog Output
Did Servo control. Still working on figuring out how to better control the servo. Also did more with analog input. The photocells worked but couldn't get a reading from the flex sensor yet. I did find that changing resistors on the photocells drastically changes the readout.
And, I put together my cool little breadboard box, which is really helping to keep everything together. Having the serial and power connectors go through holes in the box means things are more stable.

Here's the code:
' this code includes: board test blink, toggle that turns red LED on/off, ' toggle sets yellow LED to stay on for time period stored in variable, ' read output of potentiometer, photocell and flex in serial output, ' servo pulse control, DEFINE OSC 4 DEFINE ADC_BITS 10 '10 bit reading DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 50 '20 microseconds potVar VAR WORD 'variable for analog input result for potentiometer phoVar VAR WORD 'variable for input result for photocell flxVar VAR WORD 'variable for input result for flex sensor wrdVar VAR WORD 'word size variable blink VAR BYTE 'variable for test blink accumulation TRISA = %11111111 'set all of port A to input ADCON1? = %10000010 '10 BIT set port a analog and right justify TRISB = %00001000 'b.7 red LED, b.6 yellow LED, b.4 toggle switch OUTPUT portd.2 'port d.2 is board test green LED 'pulse variables for servo: pulseWidth var byte ' set up constants with the minimum and maximum pulsewidths minPulse CON 50 maxPulse CON 250 ' set up a constant with the time between pulses: refreshPeriod CON 20 ' set an initial pulsewidth: pulseWidth = minPulse PAUSE 500 'wait .5 second CLEAR main: 'code for board test blink 4 times if blink < 4 THEN HIGH portd.2 PAUSE 200 LOW portd.2 PAUSE 200 blink = blink + 1 ENDIF 'if toggle switch on, red LED will be on IF portb.4 = 1 THEN HIGH portb.7 ELSE LOW portb.7 ENDIF 'if toggle switch on, yellow LED will stay on for 10000 rotations IF portb.4 = 1 THEN wrdVar = 0 HIGH portb.6 ENDIF IF wrdVar > 10000 THEN LOW portd.0 ELSE wrdVar = wrdVar + 1 ENDIF 'potentiometer in port a0 ADCIN 0, potVar serout2 portc.6, 16468, ["potVar = ", DEC potVar, 13, 10] 'print to serial out 'photocell in port a1 ADCIN 1, phoVar serout2 portc.6, 16468, ["phoVar = ", DEC phoVar, 13, 10] 'print to serial out 'flex sensor in port a3 ADCIN 3, flxVar serout2 portc.6, 16468, ["flxVar = ", DEC flxVar, 13, 10] 'print to serial out 'servo pulse control 'take the output pin low so we can pulse it high Low PORTC.3 ' pulse the pin PulsOut? PORTC.3, pulseWidth ' pause for as long as needed: Pause refreshPeriod ' change the angle for the next time around: IF pulseWidth > maxPulse Then pulseWidth = minPulse Else pulseWidth = pulseWidth + 1 Endif GOTO main
Go look at our group tool project page!
Week 3: Variables and Analog Input
Nanna and I did this lab together - see her journal for more specifics and code.
We weren't sure about the capacitor in Step 1. Is that just in power and ground next to the potentiometer?
We programmed the PIC and got the range that the pot returned: 0 - 1022. We wondered about why we get a reading even though the code doesn't specify input from the pin the potentiometer is in.
For Step 3, we used the setup that Nanna had on her board previously, with lots of blinking. We found that the readout seemed to measure all output from the various switches. We put in code to define a variable for the potentiometer. We had all lights turn off if the numbers went above 1000, which worked. We didn't have another analog sensor.
The following photo shows the setup we had for Steps 4 and 5, when we had a variable store information about the switch. We found that the counter only rain to 246 when we did this.

Here's a photo from when we coded the PIC to output the binary contents of the memory register and reflect that number in the LEDs?. Can you actually know the number by watching the LEDs??

Week 2 Update
This wasn't working last week so I wanted to do an update:

It does turn out to work correctly. Thanks Michael. Apparently the chip had a bad day or I just didn't wait long enough for it to light up before.
Week 2 Digital I/O
I will upload some photos and a diagram soon, but I wanted to get some basic blinking going before I moved on to more complicated switches and such. And that didn't happen. I think my board is wired correctly - I checked it many times and had others check it to. Here's my code:
DEFINE OSC 4
OUTPUT portd.0 'low left red LED
OUTPUT portd.1 'low left yellow
OUTPUT portb.7 'upper right yellow
OUTPUT portd.2 'low right red LED
OUTPUT portd.4 'low right green
INPUT portb.4 'switch button in
main:
HIGH portb.7 ' blink upper right yellow
PAUSE 1000
LOW portb.7
PAUSE 1000
HIGH portd.2 'blink low right red
PAUSE 1000
LOW portd.2
PAUSE 1000
GOTO main
switch: 'switch alternates yellow green
IF portb.4 = 1 THEN
HIGH portd.1
ELSE
LOW portd.1
HIGH portd.4
ENDIF
GOTO switch
But when I tried it out, nothing happened. Power was going through the board - my test LED was lit - but nothing was going on through the microprocessor. I was told it looked like I fried it - two of them, actually. I don't have another to test with (and don't want to borrow another one and fry it), so I'll do some more checking and double checking my circuits and wait to get my samples in the mail.
In the meantime, I got some fun switches and a motor and solar panel that I'm looking forward to trying out once I get these basics working...
Oh, I also learned something crucial about the code. I thought the function names were arbitrary, but found out you have to have a 'main' function. Originally I just had 'switch' and 'blink'.
Switch
My first thought was to design something for all the poor people with tendinitus. I'm sure I'll join them someday soon. So, I wanted to stay away from hands and arms altogether.
At my old workplace, I saw people entering a door that needed a pass waved in front of a sensor in order to open. The sensor was placed pretty low, so lots of people had their passes in their back pockets and just sort of swung their hips in front of the sensor in a kind of 80s slow dance way. So I was thinking about a switch that could be pressed with the hip - the panel would be slightly curved and the switch would be a press on-off with some heft to it - like a foot pedal.
My workplace also unfortunately was the kind of place where people yelled more than necessary. Perhaps a volume-triggered mechanism... when people yell above a certain volume, a motor turns on for a water pump in a fountain - the soothing sound of water reminds people to calm down.
And also, for people sitting in chairs - at the computer/in a wheelchair/on an airplane, there's the head-switch idea. Roll to the left to turn your reading light/video/radio on, to the right for off.

Week 1 Electronics Lab
First, a simple layout with a regulator, a homemade switch made of wires, a resistor and 2 LEDs?. Plus the test light.

Then Todd showed us his basic board setup with power to switch to 10 uF (microferret?) capacitor to 5V DC regulator to 1 uF capacitor. And at the other end, the testing light. Also learned that the green LEDs? glowing bright yellow means they've got too much power and are going to burn out. And, some extra tips I haven't tried yet, like using the drill to neatly braid your wires and gluing the switch so the wires don't touch.

I wasn't sure what to do about the part of the assignment that asks us to make a puzzle or combination lock. I guess you could put a bunch of LEDs? and resistors and connecting wires on a board and ask someone to just light the green LEDs?. I would need to get a bunch more switches to do this.
The user would have to figure out which switches to flip to make that happen. In that case it'd be a matter of using the form of the object to confuse the user, to make it harder to figure out. As opposed to making objects that are easy for the user and in fact enhance rather than complicate their lives (as our reading this week was exploring). But then of course, puzzles and art and security are a different thing entirely.
