{"id":91,"date":"2024-10-24T22:51:15","date_gmt":"2024-10-25T02:51:15","guid":{"rendered":"https:\/\/wp.stgeorges.bc.ca\/joez\/?p=91"},"modified":"2024-10-24T22:51:15","modified_gmt":"2024-10-25T02:51:15","slug":"robotics-project-arduino-8ball","status":"publish","type":"post","link":"https:\/\/wp.stgeorges.bc.ca\/joez\/2024\/10\/24\/robotics-project-arduino-8ball\/","title":{"rendered":"Robotics project (Arduino 8Ball)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Decide what your device will do.\u00a0 Will it move something?\u00a0 Will it sense something and react to what it senses?\u00a0 Will it move itself?\u00a0 Don&#8217;t be too ambitious!\u00a0 The point of this is to demonstrate (or learn) skills, not to compete with Boston Dynamics (yet!).\u00a0\u00a0<\/li>\n<\/ol>\n\n\n\n<ol class=\"wp-block-list\"><\/ol>\n\n\n\n<p>2. Plan your device.\u00a0 What will it do?\u00a0 What components will you need?\u00a0 How will the components connect with each other?<\/p>\n\n\n\n<p>3. Ensure that you can connect your computer to the Arduino board.\u00a0\u00a0<\/p>\n\n\n\n<p>4. Program the Arduino to do what you need it to.<\/p>\n\n\n\n<p>To demonstrate these skills I have created a Magic 8Ball using the Arduino platform.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Description of Robot<\/h2>\n\n\n\n<p>This robot will use the Arduino tilt sensor and LCD screen to detect tilting just like a real magic 8ball and depict its answer. To use the lcd screen one must attach a 220 ohm resistor and a potentiometer is needed to control the brightness of the screen. Along with other basic parts such as jumper wires the actual breadboard and Arduino Uno board.<\/p>\n\n\n\n<p>Here is the total list:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 LCD screen<\/li>\n\n\n\n<li>1 Tilt Switch<\/li>\n\n\n\n<li>1 10k-ohm (or 10k\u03a9) Resistor with the following coloured bands: brown, black, orange, gold<\/li>\n\n\n\n<li>1 220-ohm (or 220 \u03a9) Resistor with the following coloured bands: red, red, brown, gold<\/li>\n\n\n\n<li>1 Potentiometer<\/li>\n\n\n\n<li>A large amount of jumper wires<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Construction<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"419\" src=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/image-19.png\" alt=\"\" class=\"wp-image-92\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/image-19.png 552w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/image-19-300x228.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n\n\n\n<p>Credit: <a href=\"https:\/\/uviclibraries.github.io\/arduino\/virtual_workshop_children\/lucky_8-ball.html\">https:\/\/uviclibraries.github.io\/arduino\/virtual_workshop_children\/lucky_8-ball.html<\/a><\/p>\n\n\n\n<p>Making this robot somewhat hard as a large amount of wiring is needed and getting just one wire incorrect will make it so that the screen either doesn&#8217;t turn on or it will depict a bunch of nonsense. My pictures aren&#8217;t the exact same as the picture above but the idea is the same.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-1024x768.jpg\" alt=\"\" class=\"wp-image-93\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-1024x768.jpg 1024w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-300x225.jpg 300w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-768x576.jpg 768w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-1536x1152.jpg 1536w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-min-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-768x1024.jpg\" alt=\"\" class=\"wp-image-94\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-768x1024.jpg 768w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-225x300.jpg 225w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-1152x1536.jpg 1152w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-1536x2048.jpg 1536w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusion-2-min-scaled.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-768x1024.jpg\" alt=\"\" class=\"wp-image-95\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-768x1024.jpg 768w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-225x300.jpg 225w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-1152x1536.jpg 1152w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-1536x2048.jpg 1536w, https:\/\/wp.stgeorges.bc.ca\/joez\/wp-content\/uploads\/sites\/17\/2024\/10\/fusionb-3-min-scaled.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code Explaination<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;LiquidCrystal.h&gt; \nLiquidCrystal lcd(12,11,5,4,3,2);\nconst int switchPin = 6; \nint switchState = 0; \nint prevSwitchState = 0; \nint reply;\n\t\nvoid setup(){ \n    pinMode(switchPin, INPUT);\n    lcd.begin(16, 2); \n    lcd.print(\"Ask the \"); \n    lcd.setCursor(0, 1); \n    lcd.print(\"Crystal Ball!\"); \n}\n\nvoid loop(){ \n    switchState = digitalRead(switchPin);\n    if(switchState != prevSwitchState){ \n        if(switchState == LOW){ \n            reply = random(8); \/\/pick a number from 0 to 7\n            lcd.clear(); \n            lcd.setCursor(0, 0); \n            lcd.print(\"The ball says: \"); \n            lcd.setCursor(0,1 );\n            switch(reply){ \n                case 0: lcd.print(\"Yes\");\n                break; \n                case 1: lcd.print(\"Most likely\"); \n                break; \n                case 2: lcd.print(\"Certainly\"); \n                break; \n                case 3: lcd.print(\"Outlook good\"); \n                break; \n                case 4: lcd.print(\"Unsure\"); \n                break; \n                case 5: lcd.print(\"Ask again\"); \n                break; \n                case 6: lcd.print(\"Doubtful\"); \n                break;\n                case 7: lcd.print(\"No\"); \n                break; \n            } \/\/end of switch \n        } \/\/end of nested if() \n    } \/\/end of outer if()\n    \/\/update the tilt switch status \n    prevSwitchState = switchState;  \n} \/\/end of loop()<\/code><\/pre>\n\n\n\n<p>The code used for this robot isn&#8217;t too much and it isn&#8217;t too hard to understand. But an explanation for this code is as follows:<\/p>\n\n\n\n<p>The first couple lines identifies the ports that the LCD and tilt switch are plugged into. The lines below set what the screen says when the program starts. And all the lines below that generate a random number and that number is tied to message that is displayed onto the screen when the tilt sensor is triggered. And that&#8217;s pretty much it a pretty simple code line for a really cool robot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Product and Conclusion<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"October 24, 2024\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/inbAy6pLpwk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>In conclusion, this project was probably the hardest that I had to tackle as I had the least amount of experience in Arduino compared to CAD and Coding. And as you can see components are a bit loose causing the tilt sensor to sometimes not trigger which is why you see me holding down the tilt sensor and potentiometer. Overall this project is really cool and helped me learn a lot about robotics. And if you can get your hands on the components I recommend you try this project out.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: 2. Plan your device.\u00a0 What will it do?\u00a0 What components will you need?\u00a0 How will the components connect with each other? 3. Ensure that you can connect your computer to the Arduino board.\u00a0\u00a0 4. Program the Arduino to do what you need it to. To demonstrate these skills I have created a Magic 8Ball [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/comments?post=91"}],"version-history":[{"count":1,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":96,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/posts\/91\/revisions\/96"}],"wp:attachment":[{"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/joez\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}