{"id":2087,"date":"2016-11-09T15:17:43","date_gmt":"2016-11-09T22:17:43","guid":{"rendered":"http:\/\/blogs.ischool.berkeley.edu\/i262\/?p=2087"},"modified":"2016-11-11T11:28:42","modified_gmt":"2016-11-11T18:28:42","slug":"beatbots","status":"publish","type":"post","link":"https:\/\/blogs.ischool.berkeley.edu\/i262\/2016\/11\/09\/beatbots\/","title":{"rendered":"BeatBots!"},"content":{"rendered":"<p>Update: Video Link!\u00a0https:\/\/goo.gl\/photos\/qU17V29jDkocHKya6<\/p>\n<p>Description:<\/p>\n<p>Our instrument is a group of five robots that each have their own percussive abilities. They are 1.) a four armed tap-bot that has four servos that tap tap tap on things, 2.) a two-armed spinning bot that hits things with it&#8217;s metal hands to make noise, 3.) a rolling pinecone that makes a rumbling noise on it&#8217;s surface, 4.) a shepard with a tap-tapping staff, and 5.) a scraper-bot that uses a bristly brush to scrape things and make noise.<\/p>\n<p>We mounted 4\/5 of them on a turning lazy susan, with the intention of making customization possible by changing the things on which the robots are tapping. (We could rotate the lazy susan to change what object each robot was tapping on.)<\/p>\n<p>Our robots are controlled by a control board with 5 pots. They control: 1.) the tempo of the music that our bots make, 2.) the pattern with which the pine cone rolls, 3.) the pattern with which the scraper scrapes, 4.) the pattern with which the shepard taps, and 5.) the speed with which the spinny bot spins.<\/p>\n<p>Challenges included: 1.) Getting the robots to tap with similar patterns \/\/ with some semblance of coherent synchrony, 2.) getting the different settings of the pots to have noticeably different sounds.<\/p>\n<p>Materials Used:<br \/>\n&#8211; 2 Arduinos<br \/>\n&#8211; 4 Micro-servos<br \/>\n&#8211; 3 normal servos<br \/>\n&#8211; 3D printed plastic<br \/>\n&#8211; lots! of jumper wires<br \/>\n&#8211; machine screws \/ nuts<br \/>\n&#8211; beer bottle<br \/>\n&#8211; 3 soda cans<br \/>\n&#8211; pine cone<br \/>\n&#8211; chopsticks<br \/>\n&#8211; 5 pots<br \/>\n&#8211; laser cut control board, pinecone eyes, lazy susan parts<br \/>\n&#8211; construction paper<br \/>\n&#8211; foam ball<br \/>\n&#8211; clay<br \/>\n&#8211; DC motor<br \/>\n&#8211; metal wire<br \/>\n&#8211; metal bolts\/nuts from Dan&#8217;s bed<br \/>\n&#8211; wire brush<br \/>\n&#8211; metal marbles<br \/>\n&#8211; chipotle tin<br \/>\n&#8211; cardboard scrapey surface w\/ packaging material<br \/>\n&#8211; diode<br \/>\n&#8211; resistors<br \/>\n&#8211; breadboard<br \/>\n&#8211; 3 battery packs<br \/>\n&#8211; rubber bands<\/p>\n<p>Code:<\/p>\n<pre>#include &lt;Servo.h&gt; \r\n\r\nServo myservoR;\r\nServo myservoRp;\r\nServo myservoL;\r\nServo myservoLp;\r\nServo servoLeah;\r\nServo servoAndrew;\r\nServo servoJake;\r\n \r\nint deltaPot = 0;\r\n\r\nint leahPot = 1; \r\nint leahBeat = 0;\r\n\r\nint andrewPot = 2; \r\nint andrewBeat = 0;\r\n \r\nint danielPot = 3;\r\nint danielBeat = 0;\r\n\r\nint jakePot = 4;\r\nint jakeBeat = 0;\r\n\r\nint pos = 0; \/\/ variable to store servo position \r\n\r\n\r\n\r\nvoid setup() \r\n{ \r\n Serial.begin(9600); \/\/ setup serial\r\n myservoR.attach(4); \/\/Rightmost arm from point of view of the crab\r\n myservoRp.attach(5); \/\/Right-sub-prime (right arm of the left crab)\r\n myservoL.attach(6); \/\/Leftmost arm from point of view of the crab\r\n myservoLp.attach(7);\/\/ \"Left-sub-prime\" (left arm of the right crab)\r\n servoLeah.attach(8);\r\n servoAndrew.attach(9);\r\n servoJake.attach(10);\r\n}\r\n \r\nvoid loop() {\r\n\r\n int delta = potCipher(analogRead(deltaPot))*2; \/\/speed of the hammering\r\n Serial.print(\"delta: \");\r\n Serial.println(delta);\r\n\r\n servoAndrew.write(80); \/\/ARMS UP!!!\r\n servoJake.write(80);\r\n servoLeah.write(80); \r\n myservoR.write(80); \r\n myservoL.write(100); \r\n myservoLp.write(100);\r\n myservoRp.write(80);\r\n\r\n delay(1000);\r\n \/\/PLAY! \r\n andrewBeat = potCipher(analogRead(andrewPot));\r\n Serial.print(\"andrewBeat: \");\r\n Serial.println(andrewBeat);\r\n\r\n danielBeat = potCipher(analogRead(danielPot));\r\n Serial.print(\"danielBeat: \");\r\n Serial.println(danielBeat);\r\n \r\n jakeBeat = potCipher(analogRead(jakePot));\r\n Serial.print(\"jakeBeat: \");\r\n Serial.println(jakeBeat);\r\n\r\n leahBeat = potCipher(analogRead(leahPot));\r\n Serial.print(\"leahBeat: \");\r\n Serial.println(leahBeat);\r\n \r\n for (int i=0; i &lt;= 400; i++){\r\n servoAndrew.write(getArmLoc(pos, andrewBeat)); \r\n servoLeah.write(getArmLoc(pos, leahBeat)); \r\n servoJake.write(getArmLoc(pos, jakeBeat));\r\n myservoR.write(abs(abs(80-pos)-80)); \/\/This series SHOULD do 16th-notes, approximately... but it sounds a bit off, so my math might be wrong\r\n myservoL.write(abs(abs(80-(abs(pos-60)))+100)); \r\n myservoLp.write(abs(abs(80-(abs(pos-80)))+100));\r\n myservoRp.write(abs(abs(40-pos)-80)); \r\n pos += delta;\r\n\r\n if (pos &gt;= 160) pos=0;\r\n delay(35);\r\n }\r\n delay(0);\r\n\r\n}\r\n\r\nint getArmLoc(int pos, int beatType) {\r\n if (beatType == 1) {\r\n return abs(abs(80-pos)-80);\r\n }\r\n else if (beatType == 2) {\r\n return abs(abs(40-pos)-80);\r\n }\r\n else if (beatType == 3) {\r\n return abs(abs(80-(abs(pos-60)))+100);\r\n }\r\n else if (beatType == 4) {\r\n return abs(abs(80-(abs(pos-80)))+100);\r\n }\r\n}\r\n\r\n\r\n\/\/ returns a potSection value based on the position of the pot\r\nint potCipher(int potVal) {\r\n int potSection;\r\n if (potVal &gt;= 0 &amp;&amp; potVal &lt;= 205) {\r\n potSection = 0; \r\n }\r\n else if (potVal &gt;= 206 &amp;&amp; potVal &lt;= 410) {\r\n potSection = 1;\r\n }\r\n else if (potVal &gt;= 411 &amp;&amp; potVal &lt;= 615) {\r\n potSection = 2;\r\n }\r\n else if (potVal &gt;= 615 &amp;&amp; potVal &lt;= 820) {\r\n potSection = 3;\r\n }\r\n else {\r\n potSection = 4;\r\n }\r\n return potSection;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Update: Video Link!\u00a0https:\/\/goo.gl\/photos\/qU17V29jDkocHKya6 Description: Our instrument is a group of five robots that each have their own percussive abilities. They are 1.) a four armed tap-bot that has four servos that tap tap tap on things, 2.) a two-armed spinning &hellip; <a href=\"https:\/\/blogs.ischool.berkeley.edu\/i262\/2016\/11\/09\/beatbots\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3270,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65219,1],"tags":[66762,66684,66677,65219,66733,66768],"class_list":["post-2087","post","type-post","status-publish","format-standard","hentry","category-lab09","category-uncategorized","tag-adam-hutz","tag-daniel","tag-jakepetterson","tag-lab09","tag-leahr","tag-qchong"],"_links":{"self":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts\/2087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/users\/3270"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/comments?post=2087"}],"version-history":[{"count":0,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/posts\/2087\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/media?parent=2087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/categories?post=2087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ischool.berkeley.edu\/i262\/wp-json\/wp\/v2\/tags?post=2087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}