Thursday, September 11, 2008

Fixing Physical Computing Homework

Thanks Kevin it seems to work :)

My brother Kevin, who lives in Florida and works as a Flash developer, had an idea about how to fix my code. He sent me a snippet of the void loop() section and I swapped it in and then rearranged the variables.

His idea was to check the switchState on every iteration of the for loop. Since switchState would only return 0 or 1(no or yes), he added the value of switchState to the lower of the two LED pins(pin 3) which were in pins 3 and 4.

Code snippet:
void loop() {
for (int i=10; i >= 1; i--){
// read the switch input at the beginning of
// each loop iteration
switchState = digitalRead(switchPin);
digitalWrite((ledPin + switchState), HIGH);
delay(i*(i*10));
digitalWrite((ledPin + switchState), LOW);
delay(i*(i*10));
}

Here is a video:


Physical Computing Week 1 Homework FIXED from Matt Richard on Vimeo.

2 comments:

  1. Cool! Glad it worked! By the way, the e360mag.net site is about three years old... The site that I am concentrating on is www.e360live.com or you can check out some of the launchpages: www.e360live.com/launchpage, www.e360live.com/rxp, or www.e360live.com/cocacolahiphop to name a few).

    ReplyDelete
  2. I have been a herpes carrier for 2 years and I tried every possible means of curing but all of no useful until I saw a health promotion on a herbalist from West Africa who prepares herbal medicines to cure all sorts of diseases including #HSV and many others sickness but look at me today am very much happy and healthy, I'm telling you today don't lose hope keep trying God is with you, If you needs Dr.Chala help contact him on his email dr.chalaherbalhome@gmail.com or you can visit his website on http://drchalaherbalhome.godaddysites.com or https://mywa.link/dr.chalaherbalhome

    ReplyDelete