{"id":3404,"date":"2023-04-08T05:39:38","date_gmt":"2023-04-08T12:39:38","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3404"},"modified":"2023-04-08T05:39:38","modified_gmt":"2023-04-08T12:39:38","slug":"project-26-radio-frequency-gamepad-mk12","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3404","title":{"rendered":"Project #26 &#8211; Radio Frequency &#8211; Gamepad &#8211; Mk12"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3404-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Gamepad #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03a.png\" alt=\"Gamepad\" width=\"720\" height=\"573\" class=\"alignnone size-full wp-image-3406\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03a-300x239.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03b.png\" alt=\"Gamepad\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3407\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03b-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03c.png\" alt=\"Gamepad\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3408\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/04\/DL2303Mk03c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p><strong>Gamepad<\/strong><\/p>\n<p>A gamepad is a type of video game controller held in two hands, where the fingers are used to provide input. They are typically the main input device for video game consoles. Gamepads generally feature a set of buttons handled with the right thumb and a direction controller handled with the left. The direction controller has traditionally been a four-way digital cross, also named a joypad, or alternatively a D-pad, and never called arrow keys, but most modern controllers additionally feature one or more analog sticks.<\/p>\n<p><strong>DL2303Mk03<\/strong><\/p>\n<p>1 x SparkFun Thing Plus &#8211; ESP32 WROOM<br \/>\n1 x SparkFun Joystick Shield Kit<br \/>\n1 x Thumb Joystick<br \/>\n1 x SparkFun Thumb Joystick Breakout<br \/>\n1 x Terminal Block Breakout FeatherWing<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>SparkFun Thing Plus &#8211; ESP32 WROOM<\/strong><\/p>\n<p>LJH &#8211; Analog A3<br \/>\nLJV &#8211; Analog A2<br \/>\nLJS &#8211; Digital 12<br \/>\nRJH &#8211; Analog A1<br \/>\nRJV &#8211; Analog A0<br \/>\nRJS &#8211; Digital 21<br \/>\nLD1 &#8211; Digital 16<br \/>\nLD2 &#8211; Digital 18<br \/>\nLD3 &#8211; Digital 19<br \/>\nLD4 &#8211; Digital 17<br \/>\nLT &#8211; Digital 5<br \/>\nLED &#8211; LED_BUILTIN<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2303Mk03p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/* ***** Don Luc Electronics \u00a9 *****\r\nSoftware Version Information\r\nProject #26 - Radio Frequency - Gamepad - Mk12\r\n26-12\r\nDL2303Mk03p.ino\r\n1 x SparkFun Thing Plus - ESP32 WROOM\r\n1 x SparkFun Joystick Shield Kit\r\n1 x Thumb Joystick\r\n1 x SparkFun Thumb Joystick Breakout\r\n1 x Terminal Block Breakout FeatherWing\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ Arduino\r\n#include &lt;Arduino.h&gt;\r\n\/\/ ESP32 BLE Gamepad\r\n#include &lt;BleGamepad.h&gt;\r\n\r\n\/\/ ESP32 BLE Gamepad\r\nBleGamepad bleGamepad;\r\n\r\n\/\/ Left Joystick\r\n#define LJH A3\r\n#define LJV A2\r\n#define LJS 12\r\n\r\n\/\/ Right Joystick\r\n#define RJH A1\r\n#define RJV A0\r\n#define RJS 21\r\n\r\n\/\/ D-pad\r\n#define LD1 16\r\n#define LD2 18\r\n#define LD3 19\r\n#define LD4 17\r\n\r\n\/\/ LT \r\n#define LT 5\r\n\r\n\/\/ Number of pot samples to take (to smooth the values)\r\nconst int numberOfPotSamples = 5;\r\n\/\/ Delay in milliseconds between pot samples\r\nconst int delayBetweenSamples = 2;\r\n\/\/ Additional delay in milliseconds between HID reports\r\nconst int delayBetweenHIDReports = 5;\r\n\/\/ Delay in milliseconds between button press\r\nconst int debounceDelay = 10;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;26-12&quot;;\r\n\r\nvoid loop() {\r\n  \r\n  \/\/ Bluetooth Serial (ESP32SPP)\r\n  isBluetooth();\r\n\r\n  \/\/ Delay\r\n  delay(500);\r\n  \r\n}\r\n<\/pre>\n<p><strong>getBluetooth.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Bluetooth\r\n\/\/ isBluetooth\r\nvoid isBluetooth() {\r\n\r\n  \/\/ ESP32 BLE Gamepad\r\n  if(bleGamepad.isConnected()) \r\n  {\r\n\r\n    \/\/ Button\r\n    isButton();\r\n\r\n    \/\/ Joystick\r\n    isThumbJoystick();\r\n\r\n    \/\/ Serial\r\n    Serial.println(&quot; *&quot;);\r\n\r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>getGames.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Games\r\n\/\/ Set Inputs\r\nvoid setInputs() {\r\n  \r\n  \/\/ Make the button line an input\r\n  pinMode(LJS, INPUT_PULLUP);\r\n  pinMode(RJS, INPUT_PULLUP);\r\n  pinMode(LD1, INPUT_PULLUP);\r\n  pinMode(LD2, INPUT_PULLUP);\r\n  pinMode(LD3, INPUT_PULLUP);\r\n  pinMode(LD4, INPUT_PULLUP);\r\n  pinMode(LT, INPUT_PULLUP);\r\n  \r\n  \/\/ Initialize digital pin LED_BUILTIN as an output.\r\n  pinMode(LED_BUILTIN, OUTPUT);\r\n  \/\/ Turn the LED on HIGH \r\n  digitalWrite(LED_BUILTIN, HIGH);\r\n\r\n}\r\n\r\n\/\/ Button\r\nvoid isButton(){\r\n  \r\n  \/\/ Left Joystick\r\n  if (digitalRead(LJS) == LOW) {\r\n\r\n    bleGamepad.press(LJS);\r\n    delay(debounceDelay);\r\n    bleGamepad.release(LJS);\r\n    Serial.print(&quot; LJS&quot;);\r\n      \r\n  }\r\n\r\n  \/\/ Right Joystick\r\n  if (digitalRead(RJS) == LOW) {\r\n    \r\n    bleGamepad.press(RJS);\r\n    delay(debounceDelay);\r\n    bleGamepad.release(RJS);\r\n    Serial.print(&quot; RJS&quot;);\r\n    \r\n  }\r\n\r\n  \/\/ LT\r\n  if (digitalRead(LT) == LOW) {\r\n    \r\n    bleGamepad.press(LT);\r\n    delay(debounceDelay);\r\n    bleGamepad.release(LT);\r\n    Serial.print(&quot; LT&quot;);\r\n    \r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>getThumbJoystick.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Thumb Joystick\r\nvoid isThumbJoystick() {\r\n\r\n  \/\/ Joystick LJH\r\n  \/\/ Joystick Pot Values LJH\r\n  int potValues[numberOfPotSamples];\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n    potValues[i] = analogRead(LJH);\r\n    delay(delayBetweenSamples);\r\n    \r\n  }\r\n  int potValue = 0;\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n    potValue += potValues[i];\r\n    \r\n  }\r\n  \/\/ Value \/ Pot Samples\r\n  potValue = potValue \/ numberOfPotSamples;\r\n  \/\/ Serial\r\n  Serial.print(&quot; LJH: &quot;);\r\n  Serial.print(potValue);\r\n  \/\/ Adjusted Value\r\n  int adjustedValue = map(potValue, 0, 4095, 127, -127);\r\n  \r\n  \/\/ Joystick LJV\r\n  \/\/ Joystick Pot Values LJV\r\n  int potValues2[numberOfPotSamples];\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n    potValues2[i] = analogRead(LJV);\r\n    delay(delayBetweenSamples);\r\n    \r\n  }\r\n  int potValue2 = 0;\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n    \r\n    potValue2 += potValues2[i];\r\n    \r\n  }\r\n  \/\/ Value2 \/ Pot Samples\r\n  potValue2 = potValue2 \/ numberOfPotSamples;\r\n  \/\/ Serial\r\n  Serial.print(&quot; LJV: &quot;);\r\n  Serial.print(potValue2);\r\n  \/\/ Adjusted Value2\r\n  int adjustedValue2 = map(potValue2, 0, 4095, 127, -127);\r\n  \r\n  \/\/ Joystick RJH\r\n  \/\/ Joystick Pot Values RJH\r\n  int potValues3[numberOfPotSamples];\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n    potValues3[i] = analogRead(RJH);\r\n    delay(delayBetweenSamples);\r\n    \r\n  }\r\n  int potValue3 = 0;\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n      potValue3 += potValues3[i];\r\n      \r\n  }\r\n  \/\/ Value3 \/ Pot Samples\r\n  potValue3 = potValue3 \/ numberOfPotSamples;\r\n  \/\/ Serial\r\n  Serial.print(&quot; RJH: &quot;);\r\n  Serial.print(potValue3);\r\n  \/\/ Adjusted Value3\r\n  int adjustedValue3 = map(potValue3, 0, 4095, 255, 0);\r\n\r\n  \/\/ Joystick RJV\r\n  \/\/ Joystick Pot Values RJV\r\n  int potValues4[numberOfPotSamples];\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n    potValues4[i] = analogRead(RJV);\r\n    delay(delayBetweenSamples);\r\n    \r\n  }\r\n  int potValue4 = 0;\r\n  for (int i = 0 ; i &lt; numberOfPotSamples ; i++) {\r\n      \r\n      potValue4 += potValues4[i];\r\n  \r\n  }\r\n  \/\/ Value4 \/ Pot Samples\r\n  potValue4 = potValue4 \/ numberOfPotSamples;\r\n  \/\/ Serial\r\n  Serial.print(&quot; RJV: &quot;);\r\n  Serial.print(potValue4);\r\n  \/\/ Adjusted Value4\r\n  int adjustedValue4 = map(potValue4, 0, 4095, 255, 0);\r\n\r\n  bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_CENTERED);\r\n  delay(delayBetweenHIDReports);\r\n\r\n  \/\/ D-pad\r\n  \/\/ LD1\r\n  if (digitalRead(LD1) == LOW){\r\n      \r\n    bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_UP);\r\n    Serial.print(&quot; DPAD_UP&quot;);\r\n\r\n  }\r\n  \r\n  \/\/ LD2\r\n  if (digitalRead(LD2) == LOW){\r\n    \r\n    bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_LEFT);\r\n    Serial.print(&quot; DPAD_LEFT&quot;);\r\n  \r\n  }\r\n  \r\n  \/\/ LD3\r\n  if (digitalRead(LD3) == LOW){\r\n      \r\n    bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_DOWN);\r\n    Serial.print(&quot; DPAD_DOWN&quot;);\r\n  \r\n  }\r\n  \r\n  \/\/ LD4\r\n  if (digitalRead(LD4) == LOW){\r\n      \r\n    bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_RIGHT);\r\n    Serial.print(&quot; DPAD_RIGHT&quot;);\r\n\r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Setup\r\nvoid setup()\r\n{\r\n\r\n  \/\/ Serial\r\n  Serial.begin(115200);\r\n  Serial.println(&quot;Starting BLE work!&quot;);\r\n  \r\n  \/\/ Set Inputs\r\n  setInputs();\r\n\r\n  \/\/ ESP32 BLE Gamepad\r\n  bleGamepad.begin();\r\n\r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>People can contact us:<\/strong> https:\/\/www.donluc.com\/?page_id=1927<\/p>\n<p><strong>Technology Experience<\/strong><\/p>\n<ul>\n<li>Programming Language<\/li>\n<li>Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc&#8230;)<\/li>\n<li>IoT<\/li>\n<li>Wireless (Radio Frequency, Bluetooth, WiFi, Etc&#8230;)<\/li>\n<li>Robotics<\/li>\n<li>Camera and Video Capture Receiver Stationary, Wheel\/Tank and Underwater Vehicle<\/li>\n<li>Unmanned Vehicles Terrestrial and Marine<\/li>\n<li>Machine Learning<\/li>\n<li>RTOS<\/li>\n<li>Research &#038; Development (R &#038; D)<\/li>\n<\/ul>\n<p><strong>Instructor, E-Mentor, STEAM, and Arts-Based Training<\/strong><\/p>\n<ul>\n<li>Programming Language<\/li>\n<li>IoT<\/li>\n<li>PIC Microcontrollers<\/li>\n<li>Arduino<\/li>\n<li>Raspberry Pi<\/li>\n<li>Espressif<\/li>\n<li>Robotics<\/li>\n<\/ul>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>Luc Paquin \u2013 Curriculum Vitae &#8211; 2023<\/strong><br \/>\nhttps:\/\/www.donluc.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/@thesass2063<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212; #DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Gamepad #SparkFunThingPlusESP32WROOM #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Gamepad A gamepad is a type of video game controller held in two hands, where the fingers are used to provide input. They are typically the main input device for video game consoles. Gamepads generally feature a set &#8230; <a title=\"Project #26 &#8211; Radio Frequency &#8211; Gamepad &#8211; Mk12\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3404\" aria-label=\"Read more about Project #26 &#8211; Radio Frequency &#8211; Gamepad &#8211; Mk12\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[247,47,49,38,80,59,5,82,10,43],"tags":[86,6,102,4,19,83,85,279,24,9,84,264,109,33,34],"class_list":["post-3404","post","type-post","status-publish","format-standard","hentry","category-radio-frequency","category-adafruit","category-consultant","category-digitalelectronics","category-esp32","category-fritzing","category-microcontrollers","category-program-esp32","category-projects","category-sparkfun","tag-adafruit","tag-arduino","tag-components","tag-consultant","tag-electronics","tag-esp32","tag-fritzing","tag-gamepad","tag-microcontroller","tag-programming","tag-programming-esp32","tag-radio-frequency","tag-sparkfun","tag-technology","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3404"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3404\/revisions"}],"predecessor-version":[{"id":3677,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3404\/revisions\/3677"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}