{"id":51,"date":"2007-04-24T23:48:29","date_gmt":"2007-04-25T06:48:29","guid":{"rendered":"http:\/\/itp.nyu.edu\/blogs\/bmy1\/2007\/04\/24\/final-project-surprise-surprise-surprise\/"},"modified":"2009-01-11T13:57:29","modified_gmt":"2009-01-11T20:57:29","slug":"final-project-surprise-surprise-surprise","status":"publish","type":"post","link":"https:\/\/yeeality.com\/blog\/2007\/04\/24\/final-project-surprise-surprise-surprise\/","title":{"rendered":"final project &#8211; surprise surprise surprise"},"content":{"rendered":"<p>what is up. charley and i broke through tonight. phwew!<\/p>\n<p><object width=\"400\" height=\"300\" data=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2747778&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" type=\"application\/x-shockwave-flash\"><param name=\"allowfullscreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2747778&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" \/><\/object><br \/>\n<a href=\"http:\/\/vimeo.com\/2747778\">light flight<\/a> from <a href=\"http:\/\/vimeo.com\/yeeality\">ben yee<\/a> on <a href=\"http:\/\/vimeo.com\">Vimeo<\/a>.<\/p>\n<p><object width=\"400\" height=\"300\"><param name=\"allowfullscreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"movie\" value=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2793982&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" \/><embed src=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2793982&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" type=\"application\/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"400\" height=\"300\"><\/embed><\/object><br \/><a href=\"http:\/\/vimeo.com\/2793982\">light flight<\/a> from <a href=\"http:\/\/vimeo.com\/yeeality\">ben yee<\/a> on <a href=\"http:\/\/vimeo.com\">Vimeo<\/a>.<\/p>\n<p><object width=\"400\" height=\"300\"><param name=\"allowfullscreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"movie\" value=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2793990&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" \/><embed src=\"http:\/\/vimeo.com\/moogaloop.swf?clip_id=2793990&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1\" type=\"application\/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"400\" height=\"300\"><\/embed><\/object><br \/><a href=\"http:\/\/vimeo.com\/2793990\">light flight guts<\/a> from <a href=\"http:\/\/vimeo.com\/yeeality\">ben yee<\/a> on <a href=\"http:\/\/vimeo.com\">Vimeo<\/a>.<\/p>\n<p>and here&#8217;s the working code we implemented<\/p>\n<blockquote><p>\/* code modified by Ben and Charley<br \/>\nfrom James and Christian&#8217;s Balloon Tree<br \/>\n*\/<\/p>\n<p>int photoSwitch = 2;<br \/>\nint motorPin0 = 3; \/\/ pin in hbridge to arduino for motor<br \/>\nint motorPin1 = 4; \/\/ pin in hbridge to arduino for motor<\/p>\n<p>int switchPin1 = 7; \/\/ pin for switch 1 to arduino<br \/>\nint switchPin2 = 8; \/\/ pin for switch 2 to arduino<\/p>\n<p>int state1 = 0; \/\/ initial state of switch 1 is open<br \/>\nint state2 = 0; \/\/ initial state of switch 2 is open<br \/>\nint motorPinSwap = 0; \/\/variable used to switch direction of motor<br \/>\nint motorPin0value = HIGH; \/\/ variable for motor direction<br \/>\nint motorPin1value = LOW; \/\/ variable for motor direction<\/p>\n<p>boolean previouslyPressed1 = false; \/\/BOOLEAN STATEMENT USED TO UNDERSTAND THE PREVIOUS STATE OF SWITCH1<br \/>\nboolean previouslyPressed2 = false; \/\/BOOLEAN STATEMENT USED TO UNDERSTAND THE PREVIOUS STATE OF SWITCH2<\/p>\n<p>void setup() {<br \/>\nSerial.begin(9600);<br \/>\npinMode(motorPin0, OUTPUT);<br \/>\npinMode(motorPin1, OUTPUT);<br \/>\n\/\/the switch is an input<br \/>\npinMode(photoSwitch, INPUT);<br \/>\npinMode(switchPin1, INPUT);<br \/>\npinMode(switchPin2, INPUT);<br \/>\n}<\/p>\n<p>void loop() {<\/p>\n<p>if  (digitalRead(photoSwitch) == HIGH) {<br \/>\ndigitalWrite(motorPin0,motorPin0value); \/\/starts motor in one direction using variable motorPin0value<br \/>\ndigitalWrite(motorPin1,motorPin1value); \/\/starts motor in one direction using variable motorPin1value<\/p>\n<p>\/\/<br \/>\nstate1 = digitalRead(switchPin1); \/\/READING THE STATE SWITCH1<br \/>\nSerial.print(motorPin0value,DEC); \/\/PRINT LINE<br \/>\nSerial.println(motorPin1value,DEC); \/\/PRINT LINE<br \/>\n\/\/********************************* IF STATEMENT FOR SWITCH1 ******************************<br \/>\nif(state1 == 1 &amp;&amp; previouslyPressed1 == false) \/\/IF STATEMENT IN ORDER TO CHANGE THE MOTORS DIRECTION<br \/>\n{ \/\/IF SWITCH1 IS TURNED ON, AND IT WAS NOT PREVIOUSLY PRESSED<br \/>\nmotorPinSwap = motorPin0value; \/\/THEN SWITCH THE PIN AND REVERSE THE DIRECTION OF THE MOTOR<br \/>\nmotorPin0value = motorPin1value; \/\/WHICH IN RETURN MEANS THE SWITCH AS BEEN PREVIOUSLY PRESSED<br \/>\nmotorPin1value = motorPinSwap; \/\/WHICH IS WHY IT IS NOW &#8220;TRUE&#8221;<\/p>\n<p>previouslyPressed1 = true;<br \/>\n}<br \/>\nelse if(state1 == 0) \/\/ELSE IF THE SWITCH IS NOT TURNED ON THAN IT HAS ALSO NOT<br \/>\npreviouslyPressed1 = false; \/\/BEEN PREVIOUSLY PRESSED<\/p>\n<p>\/\/<br \/>\nstate2 = digitalRead(switchPin2); \/\/READING A SECOND STATE USING SWITCH2<br \/>\nSerial.print(motorPin0value,DEC);<br \/>\nSerial.println (motorPin1value,DEC);<br \/>\n\/\/******************************************* IF STATEMENT FOR SWITCH2 **************************************<br \/>\nif(state2 == 1 &amp;&amp; previouslyPressed2 == false) \/\/IF STATEMENT IN ORDER TO CHANGE THE MOTORS DIRECTION<br \/>\n{<br \/>\nmotorPinSwap = motorPin0value;<br \/>\nmotorPin0value = motorPin1value;<br \/>\nmotorPin1value = motorPinSwap;<\/p>\n<p>previouslyPressed2 = true;<br \/>\n}<br \/>\nelse if(state2 == 0)<br \/>\npreviouslyPressed2 = false;<\/p>\n<p>}<br \/>\nelse {<br \/>\ndigitalWrite(motorPin0, HIGH);  \/\/ set leg 1 of the H-bridge high<br \/>\ndigitalWrite(motorPin1, HIGH);   \/\/ set leg 2 of the H-bridge<br \/>\n}<\/p>\n<p>}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>what is up. charley and i broke through tonight. phwew! light flight from ben yee on Vimeo. light flight from ben yee on Vimeo. light flight guts from ben yee on Vimeo. and here&#8217;s the working code we implemented \/* code modified by Ben and Charley from James and Christian&#8217;s Balloon Tree *\/ int photoSwitch [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[20],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-pcomp","tag-lightflight"],"_links":{"self":[{"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":3,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yeeality.com\/blog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}