<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-16556216</id><updated>2011-12-13T19:53:05.127-08:00</updated><title type='text'>Pcomp - Physical Computing</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://greg-b-physcomp.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-16556216.post-113692624569595596</id><published>2006-01-10T12:31:00.000-08:00</published><updated>2006-11-13T18:54:28.045-08:00</updated><title type='text'>Stay away from SparkFun Electronics</title><content type='html'>If you refer back to Week 9 of my blog, I describe the Bluetooth device that I purchased and intended to use for my project. Well, I never got it working, even after installing the software for the USB Dongle. After further troubleshooting and answer seeking on the net I finally found out why my Bluetooth adapter was not working. IT WAS COUNTERFEIT!!! The actual company that makes the USB Dongle explains how to spot a counterfeit on their website. Take a look at the "real" vs. counterfeit dongle comparison:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.billionton.com.tw/website/press/newsdetail.asp?ID=27"&gt;http://www.billionton.com.tw/website/press/newsdetail.asp?ID=27&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Sad to say SparkFun Electronics (&lt;a href="http://www.sparkfun.com"&gt;http://www.sparkfun.com&lt;/a&gt;) did not reply to my email regarding their sale of counterfeit products. I advise the ITP &amp;amp; NYU community to stay away from Spark Fun Electronics as they do not sell legitimate products. Note: Even if you're looking to buy counterfeit merchandise I recommend you stick to the street vendors on 34th st. Even though those DVD's and Louis Vuitton bags are knockoffs, at least they work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113692624569595596?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113692624569595596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113692624569595596'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2006/01/stay-away-from-sparkfun-electronics.html' title='Stay away from SparkFun Electronics'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113411385740636885</id><published>2005-12-08T22:40:00.000-08:00</published><updated>2006-11-13T18:54:27.921-08:00</updated><title type='text'>Week #10 - Final Observation Project</title><content type='html'>The pulse sensor that I finally settled on was a Burdick 100 Pulse Oximeter, which I got for a great price on eBay. The Burdick unit is a portable device that runs on 3 C-cell batteries and comes with a finger sensor probe. Here's a pic:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/ox2.jpg" border="0" /&gt;&lt;br /&gt;As you can see, the connection between the body and the finger probe is a 9-pin D-sub connection. I thought for a second it could be serial, and if it were serial then I could easily tap into the Rx/Tx pins and see what kind of voltage was coming through. In order to investigate this and not tear open the finger probe, I built a bridge of wires between the oximeter unit and finger probe. All 9-pins on the oximeter base had wires attached to them that went into my breadboard in series. I then plugged in another 9 wires from the same series that went from the breadboard to the finger probe. I turned on the unit and it was working. Great! I now had 9 wires that I could test with a multimeter and possibly send into my Pic chip as a variable. I was hoping that there had to be one wire that was getting information from the finger probe sensor and relaying it back to the base unit. I found the ground wire, which like serial, was pin #5. Then I discovered that 2 of the other wires didn't do anything because after they were unplugged, the unit still worked fine. 5 wires had the same voltage and therefore weren't useful. The 2 remaining wires did carry a varying voltage, but it was highly erratic. I sent one of them into my Pic and took a look at the results that were serialed out into Hyperterminal. I couldn't see anything of value here just by looking at these seemingly arbitrary numbers. I then plotted these numbers in MS Excel and tried to find a hint of order in this numerical chaos. Check it out:&lt;/p&gt;&lt;p&gt; &lt;a href="http://www.greg-b.com/itp/gregb.xls"&gt;http://www.greg-b.com/itp/gregb.xls&lt;/a&gt;&lt;/p&gt;&lt;p&gt;(you need MS Excel installed, I will replace with images instead soon)&lt;/p&gt;&lt;p&gt;Wow! I was pretty sure that I had found what I was looking for. After all, the graph looked like a wave! Maybe this wire was supplying power that lit up the 10 LED bars on the base unit. If it was in fact doing that, then I can use this as a starting point. Unfortunately I was unable to find a mathematical formula that was consistent enough in getting a pulse reading that matched the one on the unit. Furthermore, since these numbers that I am talking about only changed when the finger probe was slipped on, I think the wires were controlling led activation in the sensor. Anyway, I couldn't figure it out and had realized that I spent 2 days of soldering, hypothesizing and calculating without progress. I was frustrated, worried about not having a working prototype which was due in 2 days and tired from and of leaving the lab at 3am. So what did I do when all things failed? I went back to the one thing that has always worked for me. I'll give you a hint, I used it in almost every single lab. What is this magical thing that I speak of? What is it that saved me? The answer is my trusty, handy-dandy photosensor. I slapped my photensor directly over the LED meter that spikes up and down according to your pulse and the rest is history.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/ox1b.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;The yellow cirlce indicates the digital meter. I taped my photocell right in the middle.&lt;/p&gt;&lt;p&gt;With a working analog input that was sensing your heartbeat I was now ready to do something with it. It was time to represent my pulse with a visual something or other in Processing. Here's what I did, which can be toggled through by pressing any key:&lt;br /&gt;&lt;br /&gt;Nintendo EKG&lt;br /&gt;&lt;br /&gt;This resembles a traditional EKG monitor. It tells you your pulse reading and draws waves according to the strength of your heart beat. The nintendo aspect of it is the 8-bit beeping noises that are emmitted according to the amplitude of the wave.&lt;br /&gt;&lt;br /&gt;Heart Visual&lt;/p&gt;&lt;p&gt;A spectral heart appears and dissapears in synch with your pulse. Color brightness and saturation of the image depend on the strength of your pulse.&lt;/p&gt;&lt;p&gt;You're Pulsing&lt;br /&gt;&lt;br /&gt;Camera input is used to capture live video of you getting your pulse taken. It then jitters the video feed according to your hearbeat. Unfortunately I could not get the quicktime java library installed on the school computer and could not demonstrate this. I substituted a staticpicture of doctors to show how the effect would look like anyway.&lt;/p&gt;&lt;p&gt;Exploding Sea Anemone&lt;/p&gt;&lt;p&gt;Snake-like plasma bursts out when your heart beats and gets sucked back inbetween beats. &lt;/p&gt;&lt;p&gt;Check out the video of the whole thing: &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.greg-b.com/itp/vid/gregbekg.wmv"&gt;http://www.greg-b.com/itp/vid/gregbekg.wmv&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Pic Code (same, refer to last week)&lt;br /&gt;&lt;br /&gt;Processing Code&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.greg-b.com/itp/journals/icmfinal.txt"&gt;http://www.greg-b.com/itp/journals/icmfinal.txt&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113411385740636885?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113411385740636885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113411385740636885'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/12/week-10-final-observation-project.html' title='Week #10 - Final Observation Project'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113236929000647306</id><published>2005-11-18T18:30:00.000-08:00</published><updated>2006-11-13T18:54:27.770-08:00</updated><title type='text'>Week #9 - Final Observation Project (Progress)</title><content type='html'>I got my BlueTooth wireless transmitter/receiver and USB base from Spark Fun Electronics (&lt;a href="http://www.sparkfun.com"&gt;www.sparkfun.com&lt;/a&gt;) but couldn't implement it because the ITP computers in the firmware lab did not allow me to install any new software for this unit to work. I think I just need permission to do so and then I'll be fine to experiment with this gadget. Anyway, here are some pics and specs:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/400.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;The Serial RF Link that will transmit the pulse sensor's readings.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/billionton_usbbtc1a.gif.big.gif" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;The USB dongle receives the pulse signal and goes into the computer w/ Processing.&lt;/p&gt;&lt;p align="left"&gt;The BlueSMiRF is the latest Bluetooth wireless serial cable replacement from Spark Fun Electronics! These modems work as a serial (RX/TX) pipe. Any serial stream from 9600 to 115200bps can be passed seamlessly from your computer to your target. We've even tested these units successfully over open air at 350ft (106m)!&lt;br /&gt;The remote unit can be powered from 3V up to 6V for easy battery attachment. The base unit attaches to any computer via USB. Drivers for USB available for Windows, Linux, and Mac. All signal pins on the remote unit are 3V-6V tolerant. No level shifting is required.&lt;br /&gt;You can select from two different remote types. Remote-Basic has only TX/RX and power pins (pictured). Remote-Extended includes hardware control pins CTS and RTS for a total 6-pin interface.&lt;br /&gt;&lt;/p&gt;&lt;p align="left"&gt;Specifications:&lt;br /&gt;FCC Approved Class 1 Bluetooth Radio Modem&lt;br /&gt;Extremely small radio - 0.15x0.6x1.9"&lt;br /&gt;Very robust link both in integrity and transmission distance (100m) - no more buffer overruns!&lt;br /&gt;Low power consumption : 25mA avg&lt;br /&gt;Hardy frequency hopping scheme - operates in harsh RF environments like WiFi, 802.11g, and Zigbee&lt;br /&gt;Encrypted connection&lt;br /&gt;Frequency: 2.4~2.524 GHz&lt;br /&gt;Operating Voltage: 3V-6V&lt;br /&gt;Serial communications: 2400-115200bps&lt;br /&gt;Operating Temperature: -40 ~ +70C&lt;br /&gt;Built-in antenna &lt;/p&gt;&lt;p align="left"&gt;For starters I opened up the Pcomp/ICM portal by getting my Pic Microcontroller to communicate with Processing via a standard Serial cable. To emulate the pulse sensor (which I don't have yet) I used my trusty PhotoSensor to Serout numbers from my Pic into a little Processing program that emulated a standard EKG. It looked kind of cool already! Tapping my finger on the Photocell would create a fake pulse that would register as an EKG wave on my computer screen. &lt;/p&gt;&lt;p align="left"&gt;Here's a screen shot:&lt;/p&gt;&lt;p align="left"&gt;(coming soon)&lt;/p&gt;&lt;p align="left"&gt;Here's a video demo:&lt;/p&gt;&lt;p align="left"&gt;&lt;a href="http://www.greg-b.com/itp/vid/pulse1.wmv"&gt;http://www.greg-b.com/itp/vid/pulse1.wmv&lt;/a&gt;&lt;/p&gt;&lt;p align="left"&gt;By next week I should have wireless serial up and running and my pulse sensor (most probably a pulse oximeter finger probe) will hopefully be working.&lt;/p&gt;&lt;p align="left"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/26_12.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;/p&gt;&lt;p align="center"&gt;Pulse sensor probe I am looking to purchase.&lt;/p&gt;&lt;p align="left"&gt;Please be advised that the code I used is not optimized for this application. It is a dirty cut &amp; paste &amp;amp; changing around of code from my previous assignements. It includes a lot of stuff I really don't need but don't have time to perfect at the moment. It only does the job for now.&lt;/p&gt;&lt;p align="left"&gt;The current code on my Pic:&lt;/p&gt;&lt;p align="left"&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;DEFINE OSC 4&lt;br /&gt;&lt;br /&gt;INCLUDE "modedefs.bas"&lt;br /&gt;&lt;br /&gt;DEFINE ADC_BITS 10&lt;br /&gt;&lt;br /&gt;DEFINE ADC_CLOCK 3&lt;br /&gt;&lt;br /&gt;DEFINE ADC_SAMPLEUS 10&lt;br /&gt;&lt;br /&gt;TRISA = %11111111&lt;br /&gt;&lt;br /&gt;adcon1 = %10000010&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;adcVar0 VAR WORD ' ir Create variable to store result&lt;br /&gt;&lt;br /&gt;adcVar1 VAR WORD ' ir Create variable to store result&lt;br /&gt;&lt;br /&gt;switchVar var byte&lt;br /&gt;&lt;br /&gt;inputVar Var BYTE&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;pause 500&lt;br /&gt;&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;ADCIN 0, adcVar0&lt;br /&gt;&lt;br /&gt;ADCIN 1, adcVar1&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;serout2 portc.6, 16468, [DEC adcVar0,44,DEC adcVar1,44,DEC PORTB.6,13]&lt;br /&gt;&lt;br /&gt;serIN2 portc.7, 16468, [inputVar]&lt;br /&gt;&lt;br /&gt;debug inputVar&lt;br /&gt;&lt;br /&gt;PULSOUT portd.0 ,inputVar&lt;br /&gt;&lt;br /&gt;PAUSE 10&lt;br /&gt;&lt;br /&gt;GoTo main&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p align="left"&gt;The Processing Code:&lt;/p&gt;&lt;p align="left"&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// Example by Dan O'Sullivan apologies to Tom Igoe&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;Ekg ekg1;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;import processing.serial.*;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;Serial myPort; // The serial port&lt;br /&gt;&lt;br /&gt;int slide;&lt;br /&gt;&lt;br /&gt;int light;&lt;br /&gt;&lt;br /&gt;int button;&lt;br /&gt;&lt;br /&gt;PImage ekg;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;String accumulation = "";&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void setup() {&lt;br /&gt;&lt;br /&gt;// List all the available serial ports:&lt;br /&gt;&lt;br /&gt;println(Serial.list());&lt;br /&gt;&lt;br /&gt;//framerate(100);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;size(567,556,P3D);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;ekg = loadImage("&lt;/span&gt;&lt;/strong&gt;&lt;a href="http://www.blogger.com/"&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;http://www.greg-b.com/itp/compmedia/final/ekg.gif&lt;/span&gt;&lt;/strong&gt;&lt;/a&gt;"&lt;strong&gt;&lt;span style="font-size:78%;"&gt;);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;ekg1 = new Ekg(width,height,100); // Call the constructor of Ekg to create a new Ekg&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// I know that the first port in the serial list on my mac&lt;br /&gt;&lt;br /&gt;// is always my Keyspan adaptor, so I open Serial.list()[0].&lt;br /&gt;&lt;br /&gt;// Open whatever port is the one you're using.&lt;br /&gt;&lt;br /&gt;myPort = new Serial(this, Serial.list()[0], 9600);&lt;br /&gt;&lt;br /&gt;//prime the pump in case your microcontroller is stuck in serin&lt;br /&gt;&lt;br /&gt;myPort.write(65);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void draw() {&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;ekg1.display();&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void serialEvent(Serial p) {&lt;br /&gt;&lt;br /&gt;int input = myPort.read();&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// if the last thing in was a carriage return, it means that a whole reading is ready&lt;br /&gt;&lt;br /&gt;if (input== 13) {&lt;br /&gt;&lt;br /&gt;String[] asText = accumulation.split(","); //separate out the reading based on the comma (44)&lt;br /&gt;&lt;br /&gt;int[] asNumbers = int(asText); //turn the text reading in to numbers, beware if there is a 13 still attached at the end&lt;br /&gt;&lt;br /&gt;println("accumulation " + accumulation );&lt;br /&gt;&lt;br /&gt;if (asNumbers.length &amp;gt;=3){&lt;br /&gt;&lt;br /&gt;light = asNumbers[0]; //scale it a bit based on the empirical readings of this sensor&lt;br /&gt;&lt;br /&gt;slide = asNumbers[1]/4; //easy scaling because it is a potentiometer which delivers solid 0-1020&lt;br /&gt;&lt;br /&gt;button = asNumbers[2];&lt;br /&gt;&lt;br /&gt;println("light " + light + " slide" + slide + " button" + button);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//now that you go a whole reading, clear your accumulation&lt;br /&gt;&lt;br /&gt;accumulation = "";&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;//now send something to satisfy the serin&lt;br /&gt;&lt;br /&gt;//in this case I actualy am sending information back but even if you are not just send anything back&lt;br /&gt;&lt;br /&gt;//my servo wants numbers 65- 250 and the mouse gives me numbers between 0 and width&lt;br /&gt;&lt;br /&gt;int servoRange = 250-65;&lt;br /&gt;&lt;br /&gt;float percentageAcross = mouseX/float(width);&lt;br /&gt;&lt;br /&gt;int servoOut = int(servoRange*percentageAcross) + 65;&lt;br /&gt;&lt;br /&gt;myPort.write(servoOut);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;br /&gt;&lt;br /&gt;else{&lt;br /&gt;&lt;br /&gt;accumulation= accumulation + char(input); //if you did not hear 13, accumulate&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;class Ekg&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// our Class variables.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;float x, y, xDirection, yDirection;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// Constructor for the EKG Wave&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;Ekg(int windowWidth, int windowHeight, int carsize)&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// Starting position of the wave or Flatline&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;x = 33;&lt;br /&gt;&lt;br /&gt;y = 100;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void compute()&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;x += 2; // EKG moves from left to right at a default rate of x + 2&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;if (x &amp;gt; 540)&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;{&lt;br /&gt;&lt;br /&gt;background(ekg);&lt;br /&gt;&lt;br /&gt;x = 33;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// Displays the EKG Wave&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void display()&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;compute(); // first we run the computation&lt;br /&gt;&lt;br /&gt;noStroke();&lt;br /&gt;&lt;br /&gt;fill(0,220,0);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;rect(x,y+slide*4,3,3); // Then we draw the EKG Line&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113236929000647306?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113236929000647306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113236929000647306'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/11/week-9-final-observation-project.html' title='Week #9 - Final Observation Project (Progress)'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113108993481826712</id><published>2005-11-03T22:24:00.000-08:00</published><updated>2006-11-13T18:54:27.595-08:00</updated><title type='text'>Week #8 - Final Observation Project (Idea)</title><content type='html'>Final Observation Project (Idea)&lt;br /&gt;"Hartwork"&lt;br /&gt;&lt;br /&gt;For my final observation project I will be using your heartbeat to make art. I call it "Hartwork".&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/ekg.gif" border="0" /&gt;&lt;/p&gt;&lt;p&gt;My heartbeat has always fascinated me. It's always there, making its lub-dub sounds, whether I notice its drum solo or not. High School Bio explained to me how the heart works, how truly special my cardiac tissue is and how it contracts the muscular chambers of the heart, which in turn pump blood into my arteries. I understand the science, but my inner child still believes a big part of it is magic. The EKG is the visual representation of that miracle. Much more than a life-status indicator, the EKG is a dynamic, living work of art. And you are the artist. My project will stretch the artistic boundary of the EKG by exploring different colors and shapes drawn by the rhythm of your heart. I might even make the art a continual work in progress, which would collaborate everyone's individual pulse and add it to the finished piece. The true heart of ITP.&lt;/p&gt;&lt;p&gt;Watch a video that encapsulates my observations for this project. &lt;/p&gt;&lt;p&gt; &lt;a href="http://www.greg-b.com/itp/vid/heart.wmv"&gt;http://www.greg-b.com/itp/vid/heart.wmv&lt;/a&gt;&lt;/p&gt;&lt;p&gt;For materials I would need a pulse sensor. I think hacking a digital wristwatch with pulse capability would work well. Maybe I'd incorporate it into a wristband to make it easier to put on and conceal the wi-fi transmission being fed into my Pic Microcontroller. The Pic would be programmed to relay the pulse signal into Processing, which is where coding magic would actually draw the art onto the computer screen. I know the sound aspect of the traditional EKG with its beeping noises is just as important as the visual waves are, so I am going to include audio as well.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/gagung.jpg" border="0" /&gt;Ga-Gung, Ga-Gung...&lt;/p&gt;&lt;p align="left"&gt;Basic diagram outlining the general components required:&lt;/p&gt;&lt;p align="center"&gt;&lt;/p&gt;&lt;p align="left"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/sensor.0.jpg" border="0" /&gt;Pulse Sensor, Pic Microcontroller &amp;amp; Battery rest in a Sports armband and broadcast your pulse via Wifi-Blutooth transmitter. Wifi-Receiver gets the pulse signal and USB's it into Processing. Processing code will display colorful visuals analogous to winamp's equalizer visualization and also output music. The music will include the actual beating of your own heart mixed in with instrumentals. Changes in your hearbeat will affect the BPM of the music. For example, if you are jogging in place, your accelerated hearbeat will increase the pace of the music being outputted into your headphones to catch up with your rapid pulse.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113108993481826712?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113108993481826712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113108993481826712'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/11/week-8-final-observation-project-idea.html' title='Week #8 - Final Observation Project (Idea)'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113073530519833144</id><published>2005-10-30T19:15:00.000-08:00</published><updated>2006-11-13T18:54:27.413-08:00</updated><title type='text'>Week #7 - Observation Project 2 (Final)</title><content type='html'>Observation Project 2 (Final)&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/p2.jpg" border="0" /&gt;&lt;/p&gt;&lt;p&gt;Here it is, our final prototype in all it's luminescent glory. The futuristic bouquet looked really nice. Kudos to Fazreen for laser-cutting the acrylic and Sandra for the pretty windvane sensor. Once again it looked nice. But unfortunately, the unit's performance was less than perfect. We had only tested one flower stem at first, which performed fairly smoothly. It rotated according to the motion of the windsensor, perfectly shadowing its every move. The solenoid also did what it was programmed to do. It released its magnetic grip and tilted the petals at the extreme left and right positions of the servo-motor as instructed by code. If one worked this well, then why not just replicate the code &amp; wiring for 8 more flower stems? We tried to and it didn't work. There wasn't enough power.&lt;/p&gt;&lt;p&gt;We then added an external power source and TIP120 Transistors w/ Snubber Diodes to delegate power to each solenoid to fix our power shortage. The 4 stems worked, kind of. They were twisting in a very slow and jerky manner. The smoothness of motion was gone but at least the servos and solenoids were now cooperating. Then, our voltage regulator started to overheat. It was so hot that it was broiling. You could literally see wavy heat lines above the breadboard, that's how hot it was. We were naive in thinking that just because a single flower stem was functioning, all 9 would work the same way if put together right before our presentation. I learned my lesson. Don't assume things will work until they are actually working for at least 5 minutes w/o overheating.&lt;/p&gt;&lt;p&gt;Here's a diagram illustrating the components we used in our flower unit: &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/flowerrobot.0.jpg" border="0" /&gt;The Servo Motor is programmed to rotate the entire stem 180 degrees left &amp; right. The speed and direction of the rotation is based upon the analog readings of the Windvane Sensor. Because the Windvane Sensor can rotate 360 degrees and go around an infinite number of times, there was a compatibility issue with our 180 degree servomotor. How could our flower mimic the Windvane if it could not keep up with it's ability to continually rotate? I really wish our servos could spin 360 degrees. But unfortunately that was not the case. We chose the Servo Motor for its precision performance and cheap price and are now stuck with a problematic limitation. Nevertheless the show had to go on and we decided to have the servo just stop at the extreme left and right position when the angle of the Windvanve Sensor was between 180 and 360 degrees. So if you were pushing the Windvane clockwise, the stem would follow clockwise and stop when it reached it's limit at 180 degrees. If you continued pushing the Windvane clockwise all the way around 360 degrees, the stem itself would jump back (anti-clockwise) from it's 180 degree stopped position back to 0 degrees as soon as the Windvane went all the way around and passed the 0 degree threshhold. The stem would then begin to once again go clockwise tracking the Windvane. This reset period when the servo had to jump back to 0 degrees was an undesirable effect but in the end an unavoidable one.&lt;/p&gt;&lt;p&gt;The Windvane Sensor was a brilliant device. It used 2 Potentiometers working simultaneously and thus had 2 separate analog wires for each Pot reading. A single potentiometer can only go around 180 degrees, giving you a variable resistance reading anywhere from 0-1023. This works very nicely with the 180 degree servo, but we needed a wind instrument that could measure wind 360 degrees. The solution was the 2 Pots found in this store bought Windvane Sensor. Each Pot was broken so that it could twist all the way around, 360 degrees. When Pot 1's readings terminated at 1023 after a 180 degree twist, Pot 2 began at 0 and then terminated at 1023 when the circle was completed. This is the pattern that happened everytime the Windvane was spun around. Our only task was to program the Pic when to use Pot 1 or Pot 2's resistance readings to move the Servo Motor.&lt;/p&gt;&lt;p&gt;The Solenoid was cool when it worked properly. For some reason it didn't have enough juice to pull back the Flower to an upright position. The magnetic force was not strong enough to undo the release. I guess it could be either that the weight of the flower is too heavy for the magnet to pull or the solenoid simply needs more voltage then we are giving it. To be honest, because we each worked on a specific task, I don't even know what the voltage rating of the solenoid is! Anyhow, the solenoid was originally in the ON position and the magnetic force was keeping the string taught, which in turn kept the hinge erect and the flower up. When the stem reached an extreme left or right position, the Pic set the solenoid output port to Low and cut the power to release the solenoid. The solenoid jumped out of it's shell, the flower tilted down towards the floor and the solenoid insert was stopped by the stopper. We just couldn't get the reverse to happen.&lt;/p&gt;&lt;p&gt;The flower stem was made from the skeleton of a real umbrella and thus embodied the soul of our original idea.&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/p5.jpg" border="0" /&gt;&lt;/p&gt;&lt;p&gt;In conclusion our project was not very successful as far as accomplishing the smooth, bio-mechanical movement we desired. But the experience was extremely positive and worthwhile. I think our ambitions were a bit too high for the allotted time frame and the mechanical complexity involved. The design was aesthetically pleasing and worked very well, and with a little retooling could easily increase the fluidity of motion it lacked. I'm sure we'll all roll out with better stuff next time around.&lt;/p&gt;&lt;p&gt;Checkout a video demo:&lt;/p&gt;&lt;p&gt;(Will be added by Friday)&lt;/p&gt;&lt;p&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip. This constitutes the work for one flower stem:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;DEFINE OSC 4&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;DEFINE ADC_BITS 10&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;DEFINE ADC_CLOCK 3&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;DEFINE ADC_SAMPLEUS 10&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;TRISA = %11111111&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;adcon1 = %10000010&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;adcVar0 VAR WORD ' Create variable to store result for POT 1&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;adcVar1 VAR WORD ' Create variable to store result for POT 2&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;switchVar var byte&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;inputVar Var BYTE&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;pause 500&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;main:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;ADCIN 0, adcVar0&lt;br /&gt;&lt;br /&gt;ADCIN 1, adcVar1&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;serout2 portc.6, 16468, [DEC adcVar0/4,44,DEC adcVar1/4,44,DEC PORTB.6,13]&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;'serIN2 portc.7, 16468, [inputVar]&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;'debug inputVar&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;PAUSE 10&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;'SERVO MOTOR MOTION&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;adcVar0 = adcVar0/4 ' Divide Pot reading by 4 to give us a range that the Servo&lt;br /&gt;Motor likes better (~50 - 255)&lt;br /&gt;&lt;br /&gt;adcVar1 = adcVar1/4&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;if (adcVar0 &amp;gt;= 60) &amp;&amp;amp; (adcvar0 &amp;lt;= 250) THEN&lt;br /&gt;&lt;br /&gt;'take the output pin low so we can pulse it high&lt;br /&gt;&lt;br /&gt;Low PORTD.1&lt;br /&gt;&lt;br /&gt;' pulse the pin&lt;br /&gt;&lt;br /&gt;PulsOut PORTD.1, adcVar0 'Move the Servo according to Pot 1 readings&lt;br /&gt;&lt;br /&gt;ENDIF&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;if (adcVar0 &amp;gt;= 251) &amp;&amp;amp; (adcvar1 &amp;gt;= 59) THEN&lt;br /&gt;&lt;br /&gt;'take the output pin low so we can pulse it high&lt;br /&gt;&lt;br /&gt;Low PORTD.1&lt;br /&gt;&lt;br /&gt;' pulse the pin&lt;br /&gt;&lt;br /&gt;PulsOut PORTD.1, 250 - adcVar1 'Move the Servo according to the difference between&lt;br /&gt;Pot 2 reading and 250 (Pot 1 max )&lt;br /&gt;&lt;br /&gt;ENDIF&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;'SOLENOID MOTION&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;if (adcVar0 &amp;lt;= 62) &amp;&amp;amp; (adcvar0 &amp;gt;= 248) THEN&lt;br /&gt;&lt;br /&gt;Low PORTB.1 ' Cut the magnetic field and lower the Flower when Servo is at or&lt;br /&gt;near max left/right position&lt;br /&gt;&lt;br /&gt;ELSE&lt;br /&gt;&lt;br /&gt;High PORTB.1 'Keep the magnetic field on and flower propped up at all other&lt;br /&gt;Servo positions&lt;br /&gt;&lt;br /&gt;ENDIF&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;GoTo main&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113073530519833144?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113073530519833144'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113073530519833144'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-7-observation-project-2-final.html' title='Week #7 - Observation Project 2 (Final)'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113021876562489409</id><published>2005-10-24T22:03:00.000-07:00</published><updated>2006-11-13T18:54:27.262-08:00</updated><title type='text'>Week #6 - Assignment</title><content type='html'>Assignment #6&lt;br /&gt;&lt;em&gt;DC Motor Control&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;This lab assignment looked easy, so I immediately began disassembling my breadboard, ripping out whatever I didn't need from last week's assignment and prepping it for my motor. The motor I'll be implementing and attempting to control is a tiny, Radio Shack 1.5 - 3v DC hobby motor, which cost me just under $3 bucks. Ok, so what is DC motor control? Well, there are different levels of control. If you simply power your motor and give it ground it will keep on spinning at a constant rate until you kill the power. So I guess this implies little or no control. What if I installed a simple Push-Button Switch between my motor's power line? I'd have more control. I'd be able to manually pulse the motor and be able to more accurately turn it on and off by simply tapping the Push-Button. Is this the control we are looking for? Not exactly, because this type of manual control is just not reliable (e.g., human error). We need to demonstrate consistent control and manipulation over this motor. To show such mastery of our motor we need help from our Pic Microcontroller and an H-Bridge or a TIP120. An H-Bridge has the ability to make a motor run forwards and in reverse, that's a pretty nifty trick. Unfortunately I couldn't get my fingers on an H-Bridge so I ended up using a TIP120, which can only vary the speed of the motor by receiving pause intervals (in milliseconds) from one of the ports off the Pic. This is a pretty shabby trick in my opinion. All you're basically doing is setting your chosen port to High for a second or two, then Low for a second or two, and this will create intervals where the motor is receiving (On) and not receiving (Off) voltage in an attempt to create a smooth motor cycle. I just wanted to say motorcycle. Anyway, that shabby trick is exactly what I did. My motor will not be able to spin backwards and though it's not as much fun as firing the motor On and Off with a Push-Button, I will be able to display some control. You can also hook up a Potentiometer and use ADCvar to use the Pot as a speed control nob.&lt;br /&gt;&lt;br /&gt;Here's a breakdown of what is plugged into the breadboard:&lt;br /&gt;(I only numbered the new components, please refer to previous lab assignments for other component info.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/pcomp61.jpg" border="0" /&gt;&lt;strong&gt;1&lt;/strong&gt;- 220 ohm Resistor giving power from the Pic Micro's Port.D1&lt;/p&gt;&lt;p&gt;&lt;strong&gt;2&lt;/strong&gt;- TIP120 Transistor. Has three pins: Base, Collector &amp; Emitter (going left to right). The resistor bringing power from the chip goes into the Base, the Ground from the motor goes into the Collector and the Emitter is grounded to the board. &lt;/p&gt;&lt;p&gt;&lt;strong&gt;3&lt;/strong&gt;- Snubber Diode (1N4004). This polarized diode connects to the Collector &amp;amp; Emitter.&lt;br /&gt;&lt;br /&gt;No video this week, it's only a motor spinning so you can use your imagination.&lt;br /&gt;&lt;br /&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip:&lt;/p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;'define oscillator @ 4mhz&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;DEFINE OSC 4&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;' make ports D1 output&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;output PORTD.1&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;pause 500 ' start program with a half-second delay&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;main:&lt;br /&gt;&lt;br /&gt;high PORTD.1&lt;br /&gt;&lt;br /&gt;pause 1000 ' turns motor power on for 1 second&lt;br /&gt;&lt;br /&gt;low PORTD.1&lt;br /&gt;&lt;br /&gt;pause 1000 ' turns power off for 1 second&lt;br /&gt;&lt;br /&gt;goto main&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113021876562489409?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113021876562489409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113021876562489409'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-6-assignment.html' title='Week #6 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113012024981650999</id><published>2005-10-23T18:54:00.000-07:00</published><updated>2006-11-13T18:54:27.114-08:00</updated><title type='text'>Week #5 - Assignment</title><content type='html'>Assignment #5&lt;br /&gt;&lt;em&gt;Serial Input to the Desktop in Processing&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;In the spirit of unifying ICM (Intro to Computational Media) &amp; Pcomp (Physical Computing) and to prove that I have learned something from both courses, I decided to create an interactive car game using non-traditional inputs for controlling the car around the track. Using the same exact breadboard setup from Assignment #5, all I had to add in was a Potentiometer to fully control my car. My ever-reliable photosensor will act as a gas pedal, giving the car speed when you "step on it" with your finger. The Potentiometer will act as the steering wheel, rotating the car around its own axis. As a fun bonus, I kept the speaker in and will Freqout an engine humming noise when the car is moving and high-pitched screechin noises on sharp turns. With the controls and sound planned out, the rest of the work consists of programming the Pic Microcontroller to Serial Out our 2 variables receiving and sending Analog (Photosensor &amp;amp; Pot) and have Processing read those variables and make the car move accordingly.&lt;br /&gt;&lt;br /&gt;Here are some screen shots of the game. The car you see trying to negotiate the turns is Ecto-1 from Ghostbusters (Happy Halloween). The track is actually an image file drawn as the background, I'm pretty sure it is a screenshot of Atari's Championship Sprint video game.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://greg-b.com/images/shot1.gif" target="_blank"&gt;Screen Shot 1&lt;/a&gt; &lt;a href="http://greg-b.com/images/shot2.gif" target="_blank"&gt;Screen Shot 2&lt;/a&gt; &lt;a href="http://greg-b.com/images/shot3.gif" target="_blank"&gt;Screen Shot 3&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;DEFINE OSC 4&lt;br /&gt;&lt;br /&gt;INCLUDE "modedefs.bas"&lt;br /&gt;&lt;br /&gt;DEFINE ADC_BITS 10&lt;br /&gt;&lt;br /&gt;DEFINE ADC_CLOCK 3&lt;br /&gt;&lt;br /&gt;DEFINE ADC_SAMPLEUS 10&lt;br /&gt;&lt;br /&gt;TRISA = %11111111&lt;br /&gt;&lt;br /&gt;adcon1 = %10000010&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;adcVar0 VAR WORD ' Create variable to store result&lt;br /&gt;&lt;br /&gt;adcVar1 VAR WORD ' Create variable to store result&lt;br /&gt;&lt;br /&gt;output PORTC.2 ' Speaker Output&lt;br /&gt;&lt;br /&gt;switchVar var byte&lt;br /&gt;&lt;br /&gt;inputVar Var BYTE&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;pause 500&lt;br /&gt;&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;ADCIN 0, adcVar0&lt;br /&gt;&lt;br /&gt;ADCIN 1, adcVar1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;serout2 portc.6, 16468, [DEC adcVar0,44,DEC adcVar1,44,DEC PORTB.6,13]&lt;br /&gt;&lt;br /&gt;'serIN2 portc.7, 16468, [inputVar]&lt;br /&gt;&lt;br /&gt;debug inputVar&lt;br /&gt;&lt;br /&gt;PULSOUT portd.0 ,inputVar&lt;br /&gt;&lt;br /&gt;PAUSE 10&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (ADCvar0/3 &amp;lt; 26) &amp;&amp;amp; (adcVar0/3 &amp;gt; 1) THEN&lt;br /&gt;&lt;br /&gt;freqout PORTC.2,2,250,250 'Freqout engine noise when gas pedal is activated&lt;br /&gt;&lt;br /&gt;ENDIF&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;' This outputs a screeching noise when the car is rotating between these angles&lt;br /&gt;&lt;br /&gt;if (ADCvar1 &amp;gt;= 105*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 125*3 ) (adcVar1 &amp;gt;= 150*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 170*3) (adcVar1 &amp;gt;= 200*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 220*3) (adcVar1 &amp;gt;= 200*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 215*3) (adcVar1 &amp;gt;= 245*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 260*33) (adcVar1 &amp;gt;= 295*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 305*3) (adcVar1 &amp;gt;= 340*3) &amp;&amp;amp; (ADCvar1 &amp;lt;= 350*3) THEN&lt;br /&gt;&lt;br /&gt;freqout PORTC.2,20,180,180&lt;br /&gt;&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;GoTo main&lt;/span&gt;&lt;/strong&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;Here's the Processing code:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;Car car1; &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// Example by Dan O'Sullivan apologies to Tom Igoe &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;import processing.serial.*; &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;Serial myPort; // The serial port&lt;br /&gt;&lt;br /&gt;float slide;&lt;br /&gt;&lt;br /&gt;int light;&lt;br /&gt;&lt;br /&gt;int button;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;String accumulation = "";&lt;br /&gt;&lt;br /&gt;PImage track, ecto1;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void setup() {&lt;br /&gt;&lt;br /&gt;// List all the available serial ports:&lt;br /&gt;&lt;br /&gt;println(Serial.list());&lt;br /&gt;&lt;br /&gt;size(600,450,P3D);&lt;br /&gt;&lt;br /&gt;track = loadImage("http://www.greg-b.com/itp/compmedia/week5/track.jpg");&lt;br /&gt;&lt;br /&gt;ecto1 = loadImage("http://www.greg-b.com/itp/compmedia/week5/ecto1.gif");&lt;br /&gt;&lt;br /&gt;car1 = new Car(width,height,100); // Call the constructor of Car to create a new Car&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// I know that the first port in the serial list on my mac&lt;br /&gt;&lt;br /&gt;// is always my Keyspan adaptor, so I open Serial.list()[0].&lt;br /&gt;&lt;br /&gt;// Open whatever port is the one you're using.&lt;br /&gt;&lt;br /&gt;myPort = new Serial(this, Serial.list()[0], 9600);&lt;br /&gt;&lt;br /&gt;//prime the pump in case your microcontroller is stuck in serin&lt;br /&gt;&lt;br /&gt;myPort.write(65);&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;} &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void draw() {&lt;br /&gt;&lt;br /&gt;background(track);&lt;br /&gt;&lt;br /&gt;fill(45,0,0);&lt;br /&gt;&lt;br /&gt;if (button == 1){&lt;br /&gt;&lt;br /&gt;ellipse(slide,100,10,10);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;else{&lt;br /&gt;&lt;br /&gt;car1.display();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;} &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void serialEvent(Serial p) {&lt;br /&gt;&lt;br /&gt;int input = myPort.read();&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;// if the last thing in was a carriage return, it means that a whole reading is ready&lt;br /&gt;&lt;br /&gt;if (input== 13) {&lt;br /&gt;&lt;br /&gt;String[] asText = accumulation.split(","); //separate out the reading based on the comma (44)&lt;br /&gt;&lt;br /&gt;int[] asNumbers = int(asText); //turn the text reading in to numbers, beware if there is a 13 still attached at the end&lt;br /&gt;&lt;br /&gt;println("accumulation " + accumulation );&lt;br /&gt;&lt;br /&gt;if (asNumbers.length &amp;gt;=3){&lt;br /&gt;&lt;br /&gt;light = asNumbers[0]/3; //scale it a bit based on the empirical readings of this sensor&lt;br /&gt;&lt;br /&gt;slide = asNumbers[1]/2.8444; //scaled to give range of circular motion 0-359.9&lt;br /&gt;&lt;br /&gt;button = asNumbers[2];&lt;br /&gt;&lt;br /&gt;println("light " + light + " slide" + slide + " button" + button);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//now that you go a whole reading, clear your accumulation&lt;br /&gt;&lt;br /&gt;accumulation = "";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//now send something to satisfy the serin&lt;br /&gt;&lt;br /&gt;//in this case I actualy am sending information back but even if you are not just send anything back&lt;br /&gt;&lt;br /&gt;//my servo wants numbers 65- 250 and the mouse gives me numbers between 0 and width&lt;br /&gt;&lt;br /&gt;int servoRange = 250-65;&lt;br /&gt;&lt;br /&gt;float percentageAcross = mouseX/float(width);&lt;br /&gt;&lt;br /&gt;int servoOut = int(servoRange*percentageAcross) + 65;&lt;br /&gt;&lt;br /&gt;myPort.write(servoOut);&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;br /&gt;&lt;br /&gt;else{&lt;br /&gt;&lt;br /&gt;accumulation= accumulation + char(input); //if you did not hear 13, accumulate&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;class Car&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// our Class variables.&lt;br /&gt;&lt;br /&gt;float x, y, xDirection, yDirection;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Constructor for the car&lt;br /&gt;&lt;br /&gt;Car(int windowWidth, int windowHeight, int carsize)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;// Starting position of the car&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;x = 310;&lt;br /&gt;y = 80;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Variables for car's velocity, so when (xDirection = -1) car is moving forward from right to left.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;xDirection = 1;&lt;br /&gt;yDirection = 1;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This tells our car how to move according to our steering wheel (Pot) and gas pedal (Photosensor).&lt;br /&gt;// Slide is the Pot and Light is the Photosensor.&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;void compute()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if (slide &amp;lt; 360 &amp;&amp;amp; slide &amp;gt; 180 )&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;translate(x,y);&lt;br /&gt;&lt;br /&gt;rotate(radians(-2*slide-180));&lt;br /&gt;&lt;br /&gt;translate(-x,-y);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt;= 0 &amp;&amp;amp; slide &amp;lt; 180)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;translate(x,y);&lt;br /&gt;&lt;br /&gt;rotate(radians(-2*slide+180));&lt;br /&gt;&lt;br /&gt;translate(-x,-y);&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;&lt;p&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="font-size:78%;"&gt;if (slide &amp;lt; 45 &amp;&amp;amp; slide &amp;gt; 35 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;lt; 5 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;lt; 35 &amp;&amp;amp; slide &amp;gt; 5 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;lt; 89 &amp;&amp;amp; slide &amp;gt; 45 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 89 &amp;&amp;amp; slide &amp;lt; 96 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 96 &amp;&amp;amp; slide &amp;lt; 130 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 130 &amp;&amp;amp; slide &amp;lt; 145 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 145 &amp;&amp;amp; slide &amp;lt; 175 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 175 &amp;&amp;amp; slide &amp;lt; 190 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 190 &amp;&amp;amp; slide &amp;lt; 224 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 224 &amp;&amp;amp; slide &amp;lt; 240 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 240 &amp;&amp;amp; slide &amp;lt; 270 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;y -= yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 270 &amp;&amp;amp; slide &amp;lt; 280 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 280 &amp;&amp;amp; slide &amp;lt; 314 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x -= xDirection;&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 314 &amp;&amp;amp; slide &amp;lt; 320 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 320 &amp;&amp;amp; slide &amp;lt; 350 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;y += yDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if (slide &amp;gt; 350 &amp;&amp;amp; slide &amp;lt; 360 &amp;&amp;amp; light &amp;lt; 26 &amp;amp;&amp; light != 0)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;x += xDirection;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// Displays the car&lt;br /&gt;&lt;br /&gt;void display()&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;compute(); // first we run the computation&lt;br /&gt;&lt;br /&gt;image(ecto1,x,y,56,21); // Then we paste the image of the ecto-1 on the x &amp;amp; y coordinates&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;See the sounds and hear the visuals (strike that, reverse it) by watching a video demo of the game:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.greg-b.com/itp/vid/pcomp5.wmv"&gt;http://www.greg-b.com/itp/vid/pcomp5.wmv&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113012024981650999?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113012024981650999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113012024981650999'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-5-assignment.html' title='Week #5 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-113011839155843263</id><published>2005-10-23T18:16:00.000-07:00</published><updated>2006-11-13T18:54:26.933-08:00</updated><title type='text'>Week #5 - Observation Project 2</title><content type='html'>Observation Project 2&lt;br /&gt;&lt;br /&gt;Due to time constraints and the complexity of working on a device with large dimensions that requires a lot of mechanical force to move, our team decided on slightly altering the project. We simplified things by scaling our project down to a more manageable, much smaller size. Instead of one large umbrella, we are going to build a table-top installation utilizing the same concepts found in the original umbrella project. This installation will contain a matrix of 3x3 "miniature umbrellas" mimicing the proposed movement of our larger umbrella idea. These individual "miniature umbrellas" will collapse via solenoids and rotate 360 degrees with the help of a 1.5-3v AC motor. So, by this time you're asking where's the interactivity? Where's the input? Glad you asked. This matrix of "mini umbrellas" will receive continous analog input from weather sensors (wind direction, wind speed &amp; air temperature) placed outside a window or on the roof of the ITP building. A windvane will rotate a 360 degree pot, which will give us wind velocity (speed &amp;amp; direction). This information will be relayed to our Microcontroller which will be programmed to move our matrix of "mini umbrellas" against the direction of the wind. Solenoids will react with a tilting motion and motors will spin each umbrella causing our matrix to sway like tall grass on a gusty day. An optional thermistor will also capture temperature readings and control multi-color LED's attached to these "mini umbrellas" and change color according to outside temperature. The code on the PIC Microcontroller will also include a small degree of randomness to give each unit in our matrix a slightly unique, more natural motion.&lt;br /&gt;&lt;br /&gt;Here is a new diagram illustrating the windvane and the bio-mechanical matrix of mini umbrellas: &lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/diag1.jpg" border="0" /&gt;&lt;br /&gt;&lt;p align="center"&gt;Windvane connected to Potentiometer. Scissor-type joint pushed up and down by solenoid. Experimental wind sensor design (not going to be implemented).&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/diag2.jpg" border="0" /&gt;Miniature Matrix of Umbrellas.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-113011839155843263?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113011839155843263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/113011839155843263'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-5-observation-project-2.html' title='Week #5 - Observation Project 2'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112882555741287207</id><published>2005-10-08T18:39:00.000-07:00</published><updated>2006-11-13T18:54:26.787-08:00</updated><title type='text'>Week #4 - Observation Project 2</title><content type='html'>Observation Project 2&lt;br /&gt;&lt;em&gt;The Weatherproof Umbrella&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Sam came up with this brilliant number right before we met up at ITP. It was a windy, rainy, umbrella-breaking Saturday morning. Sam didn't like it when a gust of wind inverted his umbrella and exposed him to a vicious raindrop attack. I don't think anyone likes that feeling. And the problem is and has always been the umbrella's classic design. Yes, the design is good at shielding your body from rain, but because of its non-aerodynamic, parachute shape, it is constantly begging to fly away with a mighty wind. If you hold on tight and don't let it fly away, it will bend out of shape, rip, expose eye-gouging spokes and ultimately become so warped it ceases to function as a portable rain barrier device. So what do you do? You throw away your $5 investment because you're getting wet anyway. Here's the solution:&lt;br /&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/prototypeumbrella.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;This was Sam's rough sketch illustrating the principle.&lt;/p&gt;&lt;p&gt;Pressure sensors attached to each spoke ending of the umbrella will detect changing air pressure (wind) and trigger a mechanism that will shift the top towards the direction of the current wind. The umbrella shaft will have an adjustable joint of some sort (maybe a ball &amp;amp; socket) that will give it a maximum range of motion to compete with naturally changing wind directions. As of yet, we do not exactly know what mechanism we will use to accomplish this movement, but we do have a few options we would like to experiment with. Muscle wire or Nitinol (a nickle - titanium alloy) is great because it requires a very low voltage, is super-light and easy to manipulate. Muscle wire shortens in length when electrically stimulated and can lift thousands of times its own weight. Another possible candidate is the solenoid, which is an electro-mechanical device that when triggered can use a magnetic field to open/close metal levers. For powering purposes we can have a replaceable 9-volt inside the handle or a rechargeable battery that can be hooked up to a DC charger. We will experiment next week and see what works best. Of course, the entire unit must be water-proofed, especially whatever is not under the umbrella, like the exposed air pressure sensors.&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112882555741287207?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112882555741287207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112882555741287207'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-4-observation-project-2.html' title='Week #4 - Observation Project 2'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112872381842123979</id><published>2005-10-07T14:25:00.000-07:00</published><updated>2006-11-13T18:54:26.665-08:00</updated><title type='text'>Week #4 - Assignment</title><content type='html'>Assignment #4&lt;br /&gt;&lt;em&gt;Analog Input &amp; Output Using the Pic Microcontroller&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Last week's lab assignment demonstrated Analog In and Digital Out. For this week, both the Input and Output must be of an Analog nature. Using the same breadboard setup from last week, all I needed to add was a device capable of outputting Analog. For that I chose the cost-effective $2.59 Radio Shack 8-Ohm Mini Speaker (cat no. 273-092). It sounded awful. Anyway, I jammed it into my board and re-programmed the PIC Micro to sound off a different frequency through the speaker for each of the 7 LED's. So when I flipped ON my Rocker Switch, LED #1 lit up by default (as per preset ambient light conditions of my previous assignment) and this LED was now accompanied by an irritating "eeeeeeeeeee" sound. Depending on how much I eclipsed the Photosensor with my finger would cause LED's #2 - 7 to light up and at the same time increase the sound frequency. When LED #1 is on, you are listening to a freqout of 130hz and the frequency peaks at LED #7 @ 250hz. How did I get this 130 - 250hz frequency range you ask? By trial and error. I tested the freqout command with a variety of different frequency numbers, both high and low. 130-250hz in intervals of 20 gave me the best audible difference between my 7 step LED lighting sequence. Here is a quick breakdown of the syntax for the 'freqout command and how I used it:&lt;br /&gt;&lt;br /&gt;syntax:&lt;br /&gt;&lt;br /&gt;freqout Pin,Duration,Freq1,Freq2&lt;br /&gt;&lt;br /&gt;I used:&lt;br /&gt;&lt;br /&gt;freqout PORTC.2,20,130,130&lt;br /&gt;&lt;br /&gt;In my freqout example above, I am generating a single tone of 130hz to PORTC.2 for a duration of 20ms. Since my code is in a loop the tone is also in a loop.&lt;br /&gt;&lt;br /&gt;Unfortunately no one can be "told" what lab assignment #4 is. You have to see it for yourself.&lt;br /&gt;&lt;br /&gt;Here is a numbered diagram of components and methods used for my assignment, which is basically the same setup as the previous assignment, except that I am adding the Speaker (11) and not using the serial port.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/pcomp411.jpg" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;1&lt;/strong&gt;- Red Power and Black Ground wire coming from DC Power Supply (Jameco 12V, 1000mA, part no. 170245) and into my PC Prototyping Board (Jameco 6" board, part no. 20722). A 10 uf Capacitor immediately smoothens the incoming current before it passing through a Voltage Regulator (Jameco part no. 7805) and the incoming 12V is downgraded to 5V.&lt;br /&gt;&lt;strong&gt;2&lt;/strong&gt;- Power and Ground feed through a .1 uf Capacitor and supply the entire row. A Green LED paired with a 220 Ohm Resistor (1/4 watt) is used to indicate Power is ON.&lt;br /&gt;&lt;strong&gt;3&lt;/strong&gt;- Power and Ground are sent accross the Board to supply the row on the opposite side.&lt;br /&gt;&lt;strong&gt;4&lt;/strong&gt;- Rocker Switch (Radio Shack part no. 275-690) opens and closes Power to the Microchip (PicMicro 18452).&lt;br /&gt;&lt;strong&gt;5&lt;/strong&gt;- Power and Ground feed into the Microchip at appropriate pin locations (see &lt;a href="http://greg-b-physcomp.blogspot.com/#pin"&gt;schematic&lt;/a&gt; below for pin designations).&lt;br /&gt;&lt;strong&gt;6&lt;/strong&gt;- 10K Ohm Resistor (1/4 watt) feeds Power to the Master Reset pin.&lt;br /&gt;&lt;strong&gt;7&lt;/strong&gt;- A pair of 22pF Capacitors are used inline with a 4MHZ Clocking Crystal for Microchip.&lt;br /&gt;&lt;strong&gt;8&lt;/strong&gt;- Blue wire outputs programmed signal from selected Ports (RD0-RD6) on the Microchip.&lt;br /&gt;&lt;strong&gt;9&lt;/strong&gt;- 7 Red LED's are each paired with a 220 Ohm Resistor receive signal from Blue Wires.&lt;br /&gt;&lt;strong&gt;10&lt;/strong&gt;- Photoresistor (Model info ???) supplies Variable Resistance depending on the level of light hitting the photosensor. This variance is sent along the Blue Wire and into the Microcontroller's Analog Input (pin AN0).&lt;br /&gt;&lt;strong&gt;11&lt;/strong&gt;- Radio Shack 8-Ohm Mini Speaker (cat no. 273-092) for outputting beautiful audio tones via the freqout command w/ a pair of .1uf capacitors.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/pcomp41a.jpg" border="0" /&gt;&lt;/p&gt;&lt;p style="TEXT-ALIGN: center"&gt;Power is turned ON and Switch is OFF. Green LED shows power is coming to the board and Red LED indicates Photoresistor is working.&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/pcomp421.jpg" border="0" /&gt;&lt;/p&gt;&lt;div style="TEXT-ALIGN: center"&gt;Switch is Turned ON. LED #1 Turns ON as per ambient light conditions and the Speaker emits a low-frequency sound of 130hz.&lt;br /&gt;&lt;/div&gt;&lt;p style="TEXT-ALIGN: center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/pcomp431.jpg" border="0" /&gt;Finger is shadowing the Photosensor and the LED's look confused because of my camera's pulsing flash. The frequency of the sound intensifies as the LED's individually light up going East. &lt;/p&gt;&lt;p&gt;If you don't believe me, watch the video clip:&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.greg-b.com/itp/vid/pcomp4.wmv"&gt;http://www.greg-b.com/itp/vid/pcomp4.wmv&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip:&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;' Define ADCIN parameters&lt;br /&gt;DEFINE ADC_BITS 10 ' Set number of bits in result&lt;br /&gt;DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)&lt;br /&gt;DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS&lt;br /&gt;&lt;br /&gt;ADCvar VAR WORD ' Create variable to store result&lt;br /&gt;&lt;br /&gt;TRISA = %11111111 ' Set PORTA to all input&lt;br /&gt;ADCON1 = %10000010 ' Set PORTA analog and right justify result&lt;br /&gt;Pause 500 ' Wait .5 second&lt;br /&gt;&lt;br /&gt;'define oscillator @ 4mhz&lt;br /&gt;&lt;br /&gt;DEFINE OSC 4&lt;br /&gt;&lt;br /&gt;' make ports D0 - D6 output ports:&lt;br /&gt;&lt;br /&gt;output PORTD.0&lt;br /&gt;output PORTD.1&lt;br /&gt;output PORTD.2&lt;br /&gt;output PORTD.3&lt;br /&gt;output PORTD.4&lt;br /&gt;output PORTD.5&lt;br /&gt;output PORTD.6&lt;br /&gt;output PORTC.2 ' Speaker&lt;br /&gt;&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;ADCIN 0, ADCvar ' Read channel 0 to adval&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;gt; 380) THEN&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.5&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.0&lt;br /&gt;freqout PORTC.2,20,130,130&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 380) &amp;&amp;amp; (ADCvar &amp;gt; 377) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.5&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.1&lt;br /&gt;freqout PORTC.2,20,150,150&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 377) &amp;&amp;amp; (ADCvar &amp;gt; 375) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.5&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.2&lt;br /&gt;freqout PORTC.2,20,170,170&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 375) &amp;&amp;amp; (ADCvar &amp;gt; 372) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.5&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.3&lt;br /&gt;freqout PORTC.2,20,190,190&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 372) &amp;&amp;amp; (ADCvar &amp;gt; 370) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.5&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.4&lt;br /&gt;freqout PORTC.2,20,210,210&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 370) &amp;&amp;amp; (ADCvar &amp;gt; 367) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.6&lt;br /&gt;high PORTD.5&lt;br /&gt;freqout PORTC.2,20,230,230&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 367) THEN&lt;br /&gt;LOW PORTD.0&lt;br /&gt;LOW PORTD.1&lt;br /&gt;LOW PORTD.2&lt;br /&gt;LOW PORTD.3&lt;br /&gt;LOW PORTD.4&lt;br /&gt;LOW PORTD.5&lt;br /&gt;high PORTD.6&lt;br /&gt;freqout PORTC.2,20,250,250&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;goto main&lt;/strong&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112872381842123979?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112872381842123979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112872381842123979'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/10/week-4-assignment.html' title='Week #4 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112805038485753912</id><published>2005-09-29T20:16:00.000-07:00</published><updated>2006-11-13T18:54:26.490-08:00</updated><title type='text'>Week #3 - Assignment</title><content type='html'>Assignment #3&lt;br /&gt;&lt;em&gt;Analog Input and Digital Output using the PIC Microcontroller &lt;/em&gt;&lt;br /&gt;&lt;br /&gt;For this assignment I decided to combine the components used and methods learned from the previous 2 assignments. Using the same LED setup from Lab Assignment #2 and Photoresistor principle from Assignment #1, I was ready to devise a system that input Analog information to my Microcontroller and output the results Digitally. Using my Photoresistor, I could vary the voltage coming into my Microcontroller and then have it "do something" with that variance. Since I already had a row of 7 LED's hooked up to work with my Microcontroller, I made a simple program that turned the LED's ON or OFF depending on the amount of light coming to my Photoresistor. But before I could construct such a program and have it control my LED's, I needed numbers. I needed to know what data my Photoresistor was outputting at different light levels. How did I get these initial numbers you ask? Well, not by guessing, even though I knew that the range would be somewhere between 0 &amp; 1023. The accepted answer is by establishing a Serial connection between the Microcontroller and my PC. By soldering in a Serial Port and running a simple loop program, I could continually output digital info from my analog source (Photoresistor) and have the amount of resistance display as a changing number in Hyperterminal, a program that supported Serial Communication. This magical range of numbers that are being spat out are actually the result of the function "ADCvar" after it reads the varying voltage coming into Port ADCIN 0. Well, here's what I got:&lt;br /&gt;&lt;br /&gt;For undisturbed ambient light in the vicinity of the firmware lab I was getting a consistent range between 385 &amp;amp; 387. When I totally covered the Photoresistor with my finger the resistance was a lot greater, and thus the numbers in the Hyperterminal window were a lot lower, dropping between 368 &amp; 365. Great, I now have some relevant numbers to work with. With my variable resistor I was getting a range between 365 &amp;amp; 387. To be safe I trimmed the range to 367-383, that's a difference of 16. Since I was going to use my line of 7 LED's to display that variable range, I gave each LED a threshold to turn ON/OFF in increments of 2 or 3 (16/7= ~2). So starting with LED #1, which I wanted to be ON by default (as per the light conditions of the lab), I told the program to turn LED #1's Port ON when "ADCvar" was greater than 383 and at the same time turn all other LED Ports OFF. So with that said, in a fully-lit room I would only have the first LED in my sequence of 7 Turned ON when I flip my Rocker Switch and gave power to the Microcontroller. Now, for LED #2 to Turn ON, a faint shadow would have to cross the Photoresistor and change the resistance by a variable of 3, or less than 380 but greater than 377. LED #3 would follow that sequence and be the only LED that would be ON if the resistance number was less than 377 but greater than 375. This same pattern would continue for LED's #4-6 and terminate at LED #7, which would be ON only if my finger would cover the Photoresistor completely. Please refer to the code below to see how I did everything using technical programming jargon.&lt;br /&gt;&lt;br /&gt;Here is a numbered diagram of components and methods used for my assignment, which is basically the same setup as the previous assignment, except for the serial port (11) and photocell (10):&lt;br /&gt;&lt;p align="left"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/pcomp311.jpg" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;1&lt;/strong&gt;- Red Power and Black Ground wire coming from DC Power Supply (Jameco 12V, 1000mA, part no. 170245) and into my PC Prototyping Board (Jameco 6" board, part no. 20722). A 10 uf Capacitor immediately smoothens the incoming current before it passing through a Voltage Regulator (Jameco part no. 7805) and the incoming 12V is downgraded to 5V.&lt;br /&gt;&lt;strong&gt;2&lt;/strong&gt;- Power and Ground feed through a .1 uf Capacitor and supply the entire row. A Green LED paired with a 220 Ohm Resistor (1/4 watt) is used to indicate Power is ON.&lt;br /&gt;&lt;strong&gt;3&lt;/strong&gt;- Power and Ground are sent accross the Board to supply the row on the opposite side.&lt;br /&gt;&lt;strong&gt;4&lt;/strong&gt;- Rocker Switch (Radio Shack part no. 275-690) opens and closes Power to the Microchip (PicMicro 18452).&lt;br /&gt;&lt;strong&gt;5&lt;/strong&gt;- Power and Ground feed into the Microchip at appropriate pin locations (see &lt;a href="http://greg-b-physcomp.blogspot.com/#pin"&gt;schematic&lt;/a&gt; below for pin designations).&lt;br /&gt;&lt;strong&gt;6&lt;/strong&gt;- 10K Ohm Resistor (1/4 watt) feeds Power to the Master Reset pin.&lt;br /&gt;&lt;strong&gt;7&lt;/strong&gt;- A pair of 22pF Capacitors are used inline with a 4MHZ Clocking Crystal for Microchip.&lt;br /&gt;&lt;strong&gt;8&lt;/strong&gt;- Blue wire outputs programmed signal from selected Ports (RD0-RD6) on the Microchip.&lt;br /&gt;&lt;strong&gt;9&lt;/strong&gt;- 7 Red LED's are each paired with a 220 Ohm Resistor receive signal from Blue Wires.&lt;br /&gt;&lt;strong&gt;10&lt;/strong&gt;- Photoresistor (Model info ???) supplies Variable Resistance depending on the level of light hitting the photosensor. This variance is sent along the Blue Wire and into the Microcontroller's Analog Input (pin AN0).&lt;br /&gt;&lt;strong&gt;11&lt;/strong&gt;- DB9 Female Serial Connector. Blue Wires were soldered to pins 2 and 3, which are used for Sending &amp; Receiving Digital Info between the Microcontroller and a Black Wire was soldered to pin 5 for Ground. &lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/pcomp322.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;Power is turned ON and Switch is Turned ON. LED #1 Turns ON as per ambient light conditions.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/pcomp343.jpg" border="0" /&gt;Finger covers Photosensor. As light level decreases, Resistance increases and our Programmed Microcontroller activates LED #5.&lt;/p&gt;&lt;p align="left"&gt;Better yet, watch the video clip:&lt;br /&gt;&lt;a href="http://www.greg-b.com/itp/vid/pcomp3.wmv"&gt;http://www.greg-b.com/itp/vid/pcomp3.wmv&lt;/a&gt;&lt;/p&gt;&lt;p align="left"&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;'PicBasic Pro program to display result of&lt;br /&gt;'10-bit A/D conversion through serial at 9600 baud&lt;br /&gt;'Connect analog input to channel-0 (RA0) ' Define ADCIN parameters&lt;br /&gt;&lt;br /&gt;DEFINE ADC_BITS 10 ' Set number of bits in result&lt;br /&gt;DEFINE ADC_CLOCK 3 ' Set clock source (3=rc)&lt;br /&gt;DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS&lt;br /&gt;&lt;br /&gt;ADCvar VAR WORD ' Create variable to store result&lt;br /&gt;&lt;br /&gt;TRISA = %11111111 ' Set PORTA to all input&lt;br /&gt;ADCON1 = %10000010 ' Set PORTA analog and right justify result&lt;br /&gt;Pause 500 ' Wait .5 second&lt;br /&gt;&lt;br /&gt;'define oscillator @ 4mhz&lt;br /&gt;&lt;br /&gt;DEFINE OSC 4&lt;br /&gt;&lt;br /&gt;'make ports D0 - D6 output ports:&lt;br /&gt;&lt;br /&gt;output PORTD.0&lt;br /&gt;output PORTD.1&lt;br /&gt;output PORTD.2&lt;br /&gt;output PORTD.3&lt;br /&gt;output PORTD.4&lt;br /&gt;output PORTD.5&lt;br /&gt;output PORTD.6&lt;br /&gt;&lt;br /&gt;main:&lt;br /&gt;&lt;br /&gt;ADCIN 0, ADCvar ' Read channel 0 to adval&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;gt; 383) THEN&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.5&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.0&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 380) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.5&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.1&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 377) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.5&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.2&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 375) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.5&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.3&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 372) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.5&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.4&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 370) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.6&lt;br /&gt;high PORTD.5&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;if (ADCvar &amp;lt; 367) THEN&lt;br /&gt;low PORTD.0&lt;br /&gt;low PORTD.1&lt;br /&gt;low PORTD.2&lt;br /&gt;low PORTD.3&lt;br /&gt;low PORTD.4&lt;br /&gt;low PORTD.5&lt;br /&gt;high PORTD.6&lt;br /&gt;ENDIF&lt;br /&gt;&lt;br /&gt;goto main&lt;/strong&gt;&lt;/span&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112805038485753912?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112805038485753912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112805038485753912'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/09/week-3-assignment.html' title='Week #3 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112741693958754412</id><published>2005-09-22T12:15:00.000-07:00</published><updated>2006-11-13T18:54:26.351-08:00</updated><title type='text'>Week #2 - Observation Project</title><content type='html'>Observation Project&lt;br /&gt;&lt;em&gt;NW Corner of Waverly &amp; Broadway&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/broadwavs2.jpg" border="0" /&gt;My partner (Fazreen) and I found this crosswalk an attractive location for our observation project because of the awesome complexity of the space. This street corner is an adequate representation of what flows through the veins and arteries of NYC. Our subjects consist of an everlasting, everchanging flux of pedestrians &amp; motorists, chaotically jumping in and out of our metropolitan microcosm.&lt;br /&gt;&lt;br /&gt;Like any space, there are laws governing it. Obviously, we have the general laws of physics governing the earth, which puts restrictions on the subjects' movements within the space. And we also have civil rules (such as personal ethics &amp;amp; city laws) which govern the actions/interactions of our subjects with each other and with the space.&lt;br /&gt;&lt;br /&gt;From the info above, it can can be concluded that:&lt;br /&gt;&lt;br /&gt;- Subjects move at varying velocities -&lt;br /&gt;&lt;br /&gt;The experience within the space will vary depending on the velocity of the subject. Different speeds and different directions will produce different interpretations of the space. Because our space is rather small and finite, a motorcyclist zipping by in a straight line will not have enough time to absorb the detailed information that a zig-zagging, pit-stopping dogwalker can.&lt;br /&gt;&lt;br /&gt;Though the movement of our subjects is by all means chaotic, there is a general traffic pattern followed by the majority. The crosswalk signals and traffic lights dictate the commencement, direction and cessation of most of the movement across the street, putting motorists and pedestrians on an intermittent schedule. The sidewalk movement, however, is a bit more unpredictable and varies according to personal motives.&lt;br /&gt;&lt;br /&gt;- Subjects are always changing -&lt;br /&gt;&lt;br /&gt;Our space does not move and does not alter its shape. It is constant. In contrast, those passing through the space, never stay the same. Each one of our players is genetically, racially, religiously and emotionally different. And they are different every time they pass under the spotlight of our Broadway stage. Our space has no windows, no doors and is open to everyone. Therefore our sample size, just like our big city, is the personification of variance. Whatever methods or design we choose to implement for our project, they will have to explore the diversity of our space and illicit some sort of meaningful response from its inhabitants. &lt;/p&gt;&lt;p&gt;- One Possible Prototype -&lt;/p&gt;&lt;p&gt;One possible prototype we are considering is installing a device that can record "YES/NO" "TRUE/FALSE" statements from our subjects, which would be controlled by physically pressing 2 buttons. The device would be attached directly to the corner lightpost, with the 2 functional buttons set at eye-level. We could then hang a "TRUE/FALSE" question above the buttons and record data. For example, we could pose the following question: "How are you feeling today?" and our subjects would either press "Happy or Sad". By recording and analyzing the results over the course of a week, month or better yet, an entire year, we could make generalizations about the emotional status of NYC residents (e.g., what is the general consensus, when (what days, months, seasons) are people most happy/sad) . We can also look at any pertinent historical context that has occurred within our timeline and see how local and global events shift people's moods (e.g., political agendas, natural disasters). The "How are you feeling today?" question is just an example of a topic that I am personally interested in. We could ask our subjects a variety of questions and change them up regularly just to maintain their interest and keep them interacting with our device. And because the location is so convenient and easy to access/monitor, we could check our device daily to make sure it is operating correctly.&lt;/p&gt;&lt;p&gt;What sets this apart from an ordinary poll someone can take online is that ours requires a physical touch from someone who was really there at that specific moment. And that is a special quality that gives the collected data a genuine validity. The results are real feelings/opinions from real New Yorkers. Installing such a device would definitely alter the velocities of the subjects passing through our space and at the same time record valuable information we could all learn from. In the least bit, I think it would help break-up the congestion of students blocking the entrances and exits to the Tische building. Maybe this would give them something more constructive to do and somewhere less constricting to go. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112741693958754412?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112741693958754412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112741693958754412'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/09/week-2-observation-project.html' title='Week #2 - Observation Project'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112741654383014748</id><published>2005-09-22T12:00:00.000-07:00</published><updated>2006-11-13T18:54:26.181-08:00</updated><title type='text'>Week #2 - Assignment</title><content type='html'>&lt;p align="left"&gt;&lt;a href="http://photos1.blogger.com/blogger/3792/1572/1600/AAA.jpg"&gt;&lt;/a&gt;&lt;/p&gt;&lt;div align="left"&gt;Assignment #2&lt;br /&gt;&lt;em&gt;Digital Input and Output using the PIC Microcontroller&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;With my feet still wet from the first assignment (not sure how well wet feet and electricity mix), I quickly got to work on my second assignment with a fresh new breadboard. I like starting from scratch because it allows for more control over the layout configuration, plus I needed the practice. After soldering a new "rocker-style" switch and finishing my preliminary wiring, my next step was figuring out exactly what I wanted the Microcontroller to accomplish.&lt;br /&gt;&lt;br /&gt;Here's a breakdown of what is plugged into the breadboard:&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;/div&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/AAA1.jpg" border="0" /&gt;&lt;br /&gt;&lt;strong&gt;1&lt;/strong&gt;- Red Power and Black Ground wire coming from DC Power Supply (Jameco 12V, 1000mA, part no. 170245) and into my PC Prototyping Board (Jameco 6" board, part no. 20722). A 10 uf Capacitor immediately smoothens the incoming current before it passing through a Voltage Regulator (Jameco part no. 7805) and the incoming 12V is downgraded to 5V.&lt;br /&gt;&lt;strong&gt;2&lt;/strong&gt;- Power and Ground feed through a .1 uf Capacitor and supply the entire row. A Green LED paired with a 220 Ohm Resistor (1/4 watt) is used to indicate Power is ON.&lt;br /&gt;&lt;strong&gt;3&lt;/strong&gt;- Power and Ground are sent accross the Board to supply the row on the opposite side.&lt;br /&gt;&lt;strong&gt;4&lt;/strong&gt;- Rocker Switch (Radio Shack part no. 275-690) opens and closes Power to the Microchip (PicMicro 18452).&lt;br /&gt;&lt;strong&gt;5&lt;/strong&gt;- Power and Ground feed into the Microchip at appropriate pin locations (see &lt;a href="#pin"&gt;schematic&lt;/a&gt; below for pin designations).&lt;br /&gt;&lt;strong&gt;6&lt;/strong&gt;- 10K Ohm Resistor (1/4 watt) feeds Power to the Master Reset pin.&lt;br /&gt;&lt;strong&gt;7&lt;/strong&gt;- A pair of 22pF Capacitors are used inline with a 4MHZ Clocking Crystal for Microchip.&lt;br /&gt;&lt;strong&gt;8&lt;/strong&gt;- Blue wire outputs programmed signal from selected Ports (RD0-RD6) on the Microchip.&lt;br /&gt;&lt;strong&gt;9&lt;/strong&gt;- 7 Red LED's are each paired with a 220 Ohm Resistor receive signal from Blue Wires. &lt;p&gt;A big fan of simplicity, I decided on lining up a set of 7 Red LED's side-by-side in parallel and then programming the Microcontroller to perform a looping, sequential lighting pattern. &lt;/p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/IMG_1298AA.jpg" border="0" /&gt; &lt;p align="center"&gt;Power is connected, Green LED is ON. Switch is OFF.&lt;/p&gt;&lt;p align="left"&gt;The sequence would be initiated by flipping the Switch ON and begin with LED #1 turning ON and then OFF, then LED #2 ON and OFF, continuing through and up to the 7th and final LED. Once the final LED in the row turns ON and OFF, the pattern would continue in reverse sequence, all the way back to the first LED, and then loop forever. &lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/IMG_1301AA.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;The 5th Red LED in the sequence turns ON.&lt;/p&gt;&lt;p&gt;Better yet, watch the video clip: &lt;/p&gt;&lt;p align="left"&gt;&lt;a href="http://www.greg-b.com/itp/vid/pcomp2.wmv"&gt;http://www.greg-b.com/itp/vid/pcomp2.wmv&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Using Microcode Studio for editing, picBasic Pro compiler and ePIC programmer software , here's the code that I programmed onto the Microchip:&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style="color:#000000;"&gt;&lt;span style="font-size:78%;"&gt;'define oscillator @ 4mhz&lt;br /&gt;&lt;br /&gt;DEFINE OSC 4&lt;br /&gt;&lt;br /&gt;' make ports D0 - D6 output ports:&lt;br /&gt;&lt;br /&gt;output PORTD.0&lt;br /&gt;output PORTD.1&lt;br /&gt;output PORTD.2&lt;br /&gt;output PORTD.3&lt;br /&gt;output PORTD.4&lt;br /&gt;output PORTD.5&lt;br /&gt;output PORTD.6 &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/strong&gt;&lt;span style="font-size:78%;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="font-size:78%;color:#000000;"&gt;&lt;strong&gt;main:&lt;br /&gt;&lt;br /&gt;'turn each port on for 1/4 sec and then off for 1/4 sec&lt;br /&gt;&lt;br /&gt;high PORTD.0&lt;br /&gt;pause 250 ' pause 250 msec.&lt;br /&gt;low PORTD.0&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.1&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.1&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.2&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.2&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.3&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.3&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.4&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.4&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.5&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.5&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.6&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.6&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.5&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.5&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.4&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.4&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.3&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.3&lt;br /&gt;pause 250&lt;br /&gt;&lt;br /&gt;high PORTD.2&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.2&lt;br /&gt;pause 250&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:78%;color:#000000;"&gt;&lt;strong&gt;high PORTD.1&lt;br /&gt;pause 250&lt;br /&gt;low PORTD.1&lt;br /&gt;pause 250 &lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:78%;color:#000000;"&gt;&lt;strong&gt;goto main&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a name="pin"&gt;&lt;/a&gt;&lt;a name="4b"&gt;&lt;/a&gt;Here's the pin schematic for the 18F452:&lt;/p&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/pic1.jpg" border="0" /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112741654383014748?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112741654383014748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112741654383014748'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/09/week-2-assignment.html' title='Week #2 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112716116639284394</id><published>2005-09-19T13:18:00.000-07:00</published><updated>2006-11-13T18:54:26.007-08:00</updated><title type='text'>Week #1 - Readings</title><content type='html'>Reading Assignment&lt;br /&gt;Crawford's &lt;em&gt;The Art of Interactive Design&lt;/em&gt;, Chapters 1 &amp; 2&lt;br /&gt;&lt;br /&gt;In the introductory chapter, Crawford defines interactivity and cites examples of how the term has been historically misunderstood and misused. Corporations have been mislabeling and marketing "interactive rugs" for years and we, the poor consumers have been buying them by the square foot. So far, according to Crawford, nothing in this world is interactive, except maybe a conversation. And this can't be a general conversation. To be interactive it has to be a special conversation with specific rules. The conversation has to be between 2 brilliant people who are both excellent listeners, thinkers and speakers. Interactivity and interaction, according to Crawford have to be clearly dilineated and distanced from reactivity and reaction. Watching TV, reading a book, observing a painting in a museum, listening to music are not forms of interactivity. According to the author, these are only forms of audio/visual entertainment which we are merely reacting to. Even if you close a book which you are reading right now and fling it across the room as far as you can, you are still not interacting with the book. There is no interaction because the book lacks the flesh &amp;amp; brains to tell you how it felt to be thrown across your room.&lt;br /&gt;&lt;br /&gt;Chapter 2 discusses the importance of interactivity in society, how it helps to advance man's understanding of himself in the world. According to Crawford, we learn best and remember more when learning under the umbrella of interactivity. Quoting the elegantly phrased Chinese proverb Crawford uses, “I hear and I forget; I see and I remember; I do and I understand.” it is intuitively understood that introducing a mechanical, hands-on element to learning works best because it involves motor memory in addition to senses of hearing and sight. Taking it a step further, I believe if we pioneer a way to incorporate all of man's available senses and supertimulate them in our learning environment, the end result would produce the most accurate and long-lasting educational experiences our individual brains could handle. I guess that's the same reason why the bomb is the terrorist's weapon of choice. Those near the blast are blinded by the flash, deafened by the boom and asphyxiated by the smoke. It is the most vicious ball of sensory overload that I can imagine. It leads to fear at the faintest smell of something burning. Anyway, getting back to interactivity and the learning experience, the technological revolution has given unto man an exciting tool for permeating beneficial interactivity. I am speaking about the computer and its role in facilitating newer, faster and more accurate methods for communication, and thus interactivity.&lt;br /&gt;&lt;br /&gt;Reading Assignment&lt;br /&gt;Buxton's essay &lt;em&gt;Less is More (More or Less): Uncommon Sense and the Design of Computers&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Buxton is upset with the current rate of advancement of our personal computers. Besides size and speed the general design and functionality of the computer has remained for the most part unchanged during the last 20 years. Buxton puts a lot of emphasis on the peripherals that we plug into the computer and use to interact with it. Both, keyboard, monitor  and mouse have been around since the early 80's and to Buxton's chagrin, that fact hasn't helped the problem of bridging the gap between the virtual and physical world of the computer-user. Once again we see the importance of the sensory-motor experience and how advancing these input/output technologies can help lead interactivity to that much needed next level. Buxton then draws parallels between the functionality of what he calls "super appliances", or devices that attempt to consolidate a multitude of separate functions such as the "swiss army knife" and the home computer. Like the home computer, these "super appliances" are designed for multi-tasking, but are flawed because not every task can be completed in the same room or space. Thus, Buxton raises an interesting issue; the relationship between function and space. In this relationship, the user has to fumble about when performing these multi-tasks because they cannot fit them all in the single space of the "super appliance" or home computer. Buxton's proposition is to work this problem out by avoiding "all-in-one tools" and creating more specialized, "purpose-built" tools that can handle specific tasks in the immediate space they occupy. This "less is more", "specific is bettern than general" approach to technology is exemplified in the success of the simplistic and highly practical PDA device. Now, our cell phones can do everything, and this everything that they do can be accommodated in the single space that the phone exists. We can talk to each other, take photographs, listen to music, send email, organize our schedules, and infinitum etc's.,. Buxton would highly approve.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112716116639284394?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112716116639284394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112716116639284394'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/09/week-1-readings.html' title='Week #1 - Readings'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-16556216.post-112628992984517549</id><published>2005-09-09T11:18:00.000-07:00</published><updated>2006-11-13T18:54:25.811-08:00</updated><title type='text'>Week #1 - Assignment</title><content type='html'>Assignment #1&lt;br /&gt;&lt;em&gt;Basic Electronics&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;Let me tell you a secret, contrary to the title, there is nothing basic about electronics, especially if it's your first time working with a breadboard. So let's see, resistors, voltage regulators and LED's and a little wiring &amp; soldering. Sounds easy enough, huh? But ladies and gentlemen, reading about it or seeing it on paper is different than putting your own inexperienced hands to work in the lab. I lacked technique, and therefore I suffered. It took me 3hrs of inhaling lead-laced fumes to learn how to correctly solder the wires from my power adapter to my connector. 2 days later I stopped scratching my head and started using my hands more constructively. Maybe it was because the fumes had cleared up, or maybe it was the epiphany of figuring out the 2 different directions that power travels across the breadboard and then putting that knowledge to work.&lt;br /&gt;&lt;br /&gt;Here is a numbered diagram of components and methods used for my assignment:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/400/boardweek1.jpg" border="0" /&gt;&lt;strong&gt;1&lt;/strong&gt;- Red Power and Black Ground wire coming from DC Power Supply (Jameco 12V, 1000mA, part no. 170245) and into my PC Prototyping Board (Jameco 6" board, part no. 20722).&lt;br /&gt;&lt;strong&gt;2&lt;/strong&gt;- Voltage Regulator (Jameco part no. 7805) converts the incoming 12v into a manageable 5v.&lt;br /&gt;&lt;strong&gt;3&lt;/strong&gt;- Red Power (5V) and Black Ground feed into the entire row.&lt;br /&gt;&lt;strong&gt;4&lt;/strong&gt;- 220 Ohm Resistor (1/4 watt) lowers the power for the upcoming LED.&lt;br /&gt;&lt;strong&gt;5&lt;/strong&gt;- Green LED lights up when there is power.&lt;br /&gt;&lt;strong&gt;6&lt;/strong&gt;- My Switch. When turned on it allows current to pass from&lt;em&gt; #7-9&lt;/em&gt;. Otherwise there is a short when it is Off.&lt;br /&gt;&lt;strong&gt;7&lt;/strong&gt;- Power and Ground is sent across to the other side of the Breadboard and provides power to the opposite row.&lt;br /&gt;&lt;strong&gt;8&lt;/strong&gt;- Photoresistor (Model info ???) receives and conducts power from the Black Wire via Switch &lt;em&gt;#6&lt;/em&gt; when Switch is turned on. Variable Resistance is produced depending on the level of light hitting the photosensor.&lt;br /&gt;&lt;strong&gt;9&lt;/strong&gt;- Red LED receives the variable current via the Red Wire after it has passed through the Photoresistor. Brightness of this Red LED varies depending on the action of the Photoresistor.&lt;br /&gt;&lt;br /&gt;Here are some images from my very simplistic set up:&lt;/p&gt;&lt;div align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/P1010005.jpg" border="0" /&gt;&lt;/div&gt;&lt;p align="center"&gt;Power is Disconnected.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/P10100031.JPG" border="0" /&gt;Power Connected, Green LED lights up.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/P1010008.jpg" border="0" /&gt;Switch is turned ON, Red LED lights up.&lt;/p&gt;&lt;p align="center"&gt;&lt;img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://photos1.blogger.com/blogger/3792/1572/320/P1010007.jpg" border="0" /&gt;&lt;/p&gt;&lt;p align="center"&gt;Photosensitive resistor is activated by finger covering light. The affected Red LED appears Dimmer.&lt;/p&gt;&lt;p align="left"&gt;Better yet, watch the video clip: &lt;/p&gt;&lt;p align="left"&gt;&lt;a href="http://www.greg-b.com/itp/vid/pcomp1.wmv"&gt;http://www.greg-b.com/itp/vid/pcomp1.wmv&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/16556216-112628992984517549?l=greg-b-physcomp.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112628992984517549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/16556216/posts/default/112628992984517549'/><link rel='alternate' type='text/html' href='http://greg-b-physcomp.blogspot.com/2005/09/week-1-assignment.html' title='Week #1 - Assignment'/><author><name>Greg B.</name><uri>http://www.blogger.com/profile/16208522407348564544</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
