{"id":710,"date":"2017-04-05T15:45:45","date_gmt":"2017-04-05T15:45:45","guid":{"rendered":"https:\/\/zhutarduino.wordpress.com\/?page_id=710"},"modified":"2017-04-05T15:45:45","modified_gmt":"2017-04-05T15:45:45","slug":"how-to-build-a-arduino-bluetooth-joystick-to-control-your-robot-part-1","status":"publish","type":"page","link":"https:\/\/thezhut.com\/?page_id=710","title":{"rendered":"How To Build A ARDUINO Bluetooth Joystick to control your robot Part 1"},"content":{"rendered":"<h1>This tutorial will show you how to build a Bluetooth joystick to control your robot or other ARDUINO projects..<\/h1>\n<h1>click on video below for full tutorial&#8230;<\/h1>\n<p><iframe loading=\"lazy\" title=\"How To Build A ARDUINO Bluetooth Joystick to control your robot Part 1\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/o-MiJg2SEsA?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><\/p>\n<h2><\/h2>\n<p><iframe loading=\"lazy\" title=\"How To Make Two ARDUINO Boards Bluetooth Communicate With Each Other\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/3WR2-HT_MiQ?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><\/p>\n<p><a href=\"https:\/\/youtu.be\/9OlceW1W1yU:\/\/\">https:\/\/youtu.be\/9OlceW1W1yU:\/\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Arduino code for master board:<\/h2>\n<p>int joy1;<br \/>\n\/\/int joy2;<br \/>\nint val;<br \/>\n#define button 3<br \/>\nvoid setup() {<br \/>\nSerial.begin(9600);<br \/>\npinMode(button, INPUT);<br \/>\n}<\/p>\n<p>void loop() {<br \/>\nval = digitalRead(button);<br \/>\nif (val == HIGH)<br \/>\n{<br \/>\nSerial.write(200);<br \/>\ndelay(500);<br \/>\n}<br \/>\njoy1 = analogRead(A2);<br \/>\njoy1 = map(joy1,0,1023,5,175);<br \/>\nSerial.write(joy1);<br \/>\ndelay(10);<\/p>\n<p>\/\/Serial.println(joy1); \/\/ for testing<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n<h2 style=\"top:222px;\">Arduino code for slave\u00a0board:<\/h2>\n<p>&nbsp;<\/p>\n<p>#include &lt;Servo.h&gt;<br \/>\nServo s1; \/\/ name servo 1<\/p>\n<p>#define led 2 \/\/ led on pin D2<br \/>\nint pos = 0; \/\/ button pos<br \/>\nint val; \/\/val from bluetooth<br \/>\nvoid setup() {<br \/>\nSerial.begin(9600);<br \/>\ns1.attach(3); \/\/ attach servo to pin D3<\/p>\n<p>pinMode(led, OUTPUT);<\/p>\n<p>}<\/p>\n<p>void loop() {<br \/>\nif (Serial.available() &gt; 0)<br \/>\n{<br \/>\nval = Serial.read();<br \/>\nif (val == 200 &amp;&amp; pos == 0)<br \/>\n{<br \/>\ndigitalWrite(led, HIGH);<br \/>\npos = 1;<br \/>\n}<br \/>\nelse if (val == 200 &amp;&amp; pos == 1)<br \/>\n{<br \/>\ndigitalWrite(led, LOW);<br \/>\npos = 0;<br \/>\n}<br \/>\nelse if (val &gt;= 0 &amp;&amp; val &lt;= 175)<br \/>\n{<br \/>\ns1.write(val);<\/p>\n<p>}<br \/>\n}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to build a Bluetooth joystick to control your robot or other ARDUINO projects.. click on video below for full tutorial&#8230; &nbsp; Arduino code for master board: int joy1; \/\/int joy2; int val; #define button &hellip; <a href=\"https:\/\/thezhut.com\/?page_id=710\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":10,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-710","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=710"}],"version-history":[{"count":0,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/710\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/thezhut.com\/index.php?rest_route=\/wp\/v2\/pages\/10"}],"wp:attachment":[{"href":"https:\/\/thezhut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}