{"id":4386,"date":"2014-09-20T15:11:37","date_gmt":"2014-09-20T19:11:37","guid":{"rendered":"http:\/\/mti.code.arc.cmu.edu\/2014\/?p=4386"},"modified":"2014-09-20T15:11:37","modified_gmt":"2014-09-20T19:11:37","slug":"ping-pong-raspberry-pi","status":"publish","type":"post","link":"http:\/\/mti.code.arc.cmu.edu\/2014\/?p=4386","title":{"rendered":"Ping Pong Raspberry Pi"},"content":{"rendered":"<p><iframe loading=\"lazy\" width=\"500\" height=\"281\" src=\"\/\/www.youtube.com\/embed\/-h6_5xliUH4\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4394\" src=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/photo-500x375.jpg\" alt=\"photo\" width=\"500\" height=\"375\" srcset=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/photo-500x375.jpg 500w, http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/photo-300x225.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4404\" src=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/1-500x369.jpg\" alt=\"1\" width=\"500\" height=\"369\" srcset=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/1-500x369.jpg 500w, http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/1-300x221.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4405\" src=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/2-500x370.jpg\" alt=\"2\" width=\"500\" height=\"370\" srcset=\"http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/2-500x370.jpg 500w, http:\/\/mti.code.arc.cmu.edu\/2014\/wp-content\/uploads\/2014\/09\/2-300x222.jpg 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<p><strong>Concept: <\/strong>The main concept was to create a ping pong game using openFrameworks, raspberry pi, and 3 inputs from sensors or buttons.<\/p>\n<p><strong>Process: <\/strong>I began with using one button to change the color of an ellipse from red to green when pushed. Next I added in a rectangle to move up and down when the button is pressed, I also changed the code of the ellipse to add speed to its x and y directions. When the ellipse hits the edges of the preset window it bounces off at an angle. When I got that to run I added a second button and another rectangle to be moved up and down by the push of the button. Finally I attached a potentiometer to increase the ellipses speed when the potentiometer is moved (digitalWrite set on HIGH).<\/p>\n<p><strong>Lessons Learned:<\/strong> This was my first time working with a raspberry pi, and openFrameworks. I have been familiar with Arduino, and Processing 2.0, but it was a new experience to work in openFrameworks which allows to work in unison the elements of the other programs. In order for me to understand openFrameworks I went step by step to add elements to the program to expand upon. In processing I would be able to make a rectangle in Center Mode, but errors kept occurring so I couldnt utilize this in openFrameworks. Next I tried to create collisions by determining the distance between the center of the ellipse and the length of the pong paddles. In Processing 2.0 I would just use dist() to determine this number, but in openFrameworks I had trouble using this command to work for me. I also found out that to create collisions one should use the gravity tool, but I couldnt figure out how to use this function also.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Concept: The main concept was to create a ping pong game using openFrameworks, raspberry pi, and 3 inputs from sensors or buttons. Process: I began with using one button to change the color of an ellipse from red to green when pushed. Next I added in a rectangle to move up and down when the [&hellip;]<\/p>\n","protected":false},"author":143,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"coauthors":[101],"class_list":["post-4386","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/posts\/4386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/users\/143"}],"replies":[{"embeddable":true,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4386"}],"version-history":[{"count":10,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/posts\/4386\/revisions"}],"predecessor-version":[{"id":4406,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=\/wp\/v2\/posts\/4386\/revisions\/4406"}],"wp:attachment":[{"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4386"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4386"},{"taxonomy":"author","embeddable":true,"href":"http:\/\/mti.code.arc.cmu.edu\/2014\/index.php?rest_route=%2Fwp%2Fv2%2Fcoauthors&post=4386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}