{"id":3240,"date":"2022-11-12T05:50:22","date_gmt":"2022-11-12T13:50:22","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3240"},"modified":"2022-11-12T05:50:22","modified_gmt":"2022-11-12T13:50:22","slug":"project-24-rtos-bluetooth-mk03","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3240","title":{"rendered":"Project #24 &#8211; RTOS &#8211; Bluetooth &#8211; Mk03"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3240-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #ESP32 #RTOS #FreeRTOS #Bluetooth #ThumbJoystick #Keyboard #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04a.png\" alt=\"Bluetooth\" width=\"720\" height=\"483\" class=\"alignnone size-full wp-image-3242\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04a-300x201.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\/2022\/11\/DL2210Mk04b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04b.png\" alt=\"Bluetooth\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3243\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04b-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\/2022\/11\/DL2210Mk04c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04c.png\" alt=\"Bluetooth\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3244\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/11\/DL2210Mk04c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Joystick<\/strong><\/p>\n<p>A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. Joysticks are often used to control video games, and usually have one or more push-buttons whose state can also be read by the computer. A popular variation of the joystick used on modern video game consoles is the analog stick. Joysticks are also used for controlling machines such as cranes, trucks, underwater unmanned vehicles, wheelchairs, surveillance cameras, and zero turning radius lawn mowers. This is a joystick very similar to the analog joysticks on PS2 controllers. Directional movements are simply two potentiometers, one for each axis. Pots are 10k Ohm each. This joystick also has a select button that is actuated when the joystick is pressed down.<\/p>\n<p><strong>DL2210Mk04<\/strong><\/p>\n<p>1 x Adafruit HUZZAH32 \u2013 ESP32 Feather<br \/>\n1 x Lithium Ion Battery &#8211; 2500mAh<br \/>\n1 x Thumb Joystick<br \/>\n1 x SparkFun Thumb Joystick Breakout<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>ESP32 Feather<\/strong><\/p>\n<p>JY0 &#8211; Analog A0<br \/>\nJY1 &#8211; Analog A5<br \/>\nSE0 &#8211; Digital 12<br \/>\nLED &#8211; Digital 13<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2210Mk04p.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 #24 - RTOS - Bluetooth - Mk03\r\n24-03\r\nDL2210Mk04p.ino\r\n1 x Adafruit HUZZAH32 \u2013 ESP32 Feather\r\n1 x Lithium Ion Battery - 2500mAh\r\n1 x Thumb Joystick\r\n1 x SparkFun Thumb Joystick Breakout\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ FreeRTOS ESP32\r\n#if CONFIG_FREERTOS_UNICORE\r\n#define ARDUINO_RUNNING_CORE 0\r\n#else\r\n#define ARDUINO_RUNNING_CORE 1\r\n#endif\r\n\/\/ ESP32 BLE Keyboard\r\n#include &lt;BleKeyboard.h&gt;\r\n\r\n\/\/ ESP32 BLE Keyboard\r\nBleKeyboard bleKeyboard;\r\n\r\n\/\/ Connections to joystick\r\n\/\/ Vertical\r\nconst int VERT = A0;\r\n\/\/ Horizontal\r\nconst int HORIZ = A5;\r\n\/\/ Pushbutton\r\nconst int SEL = 12;\r\n\/\/ Initialize variables for analog and digital values\r\nint vertical;\r\nint horizontal;\r\nint selec;\r\n\r\n\/\/ Led Built In\r\n#ifndef LED_BUILTIN\r\n#define LED_BUILTIN 13\r\n#endif\r\n\r\n\/\/ Define two tasks for Blink\r\nvoid isTaskBlink( void *pvParameters );\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;24-03&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ ESP32 BLE Keyboard\r\n  if(bleKeyboard.isConnected()) {\r\n\r\n    \/\/ Thumb Joystick\r\n    isThumbJoystick();\r\n\r\n  }\r\n\r\n  \/\/ Delay\r\n  delay( 1000 );\r\n  \r\n}\r\n<\/pre>\n<p><strong>getTasks.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Tasks\r\n\/\/ Setup Task\r\nvoid isSetupTask(){\r\n\r\n  \/\/ Now set up two tasks to run independently\r\n  \/\/ TaskBlink\r\n  xTaskCreatePinnedToCore(\r\n    isTaskBlink\r\n    ,  &quot;TaskBlink&quot;   \/\/ A name just for humans\r\n    ,  1024  \/\/ This stack size can be checked &amp; adjusted by reading.\r\n    ,  NULL\r\n    ,  2  \/\/ Priority, with 2 being the highest, and 0 being the lowest.\r\n    ,  NULL \r\n    ,  ARDUINO_RUNNING_CORE);\r\n\r\n  \/\/ Now the task scheduler, which takes over control of scheduling individual tasks,\r\n  \/\/ is automatically started.\r\n  \r\n}\r\n\/\/ This is a Task Blink\r\nvoid isTaskBlink(void *pvParameters)\r\n{\r\n  \r\n  (void) pvParameters;\r\n\r\n  \/\/ Blink\r\n  \/\/ Turns on an LED on for 2 second, then off for 2 second, repeatedly\r\n\r\n  \/\/ Initialize digital LED_BUILTIN on pin 13 as an output.\r\n  pinMode(LED_BUILTIN, OUTPUT);\r\n\r\n  \/\/ A Task shall never return or exit\r\n  for (;;) \r\n  {\r\n    \r\n    \/\/ Turn the LED on (HIGH is the voltage level)\r\n    digitalWrite(LED_BUILTIN, HIGH);\r\n    \/\/ One tick delay in between reads\r\n    vTaskDelay(2000);\r\n    \/\/ Turn the LED off by making the voltage LOW\r\n    digitalWrite(LED_BUILTIN, LOW);\r\n    \/\/ One tick delay in between reads\r\n    vTaskDelay(2000);\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  \/\/ Read all values from the joystick\r\n  \/\/ Joystick was sitting around 2047 for the vertical and horizontal values\r\n  \/\/ Will be 0-4095\r\n  \/\/ Vertical\r\n  vertical = analogRead(VERT);\r\n  if (vertical == 4095) {\r\n\r\n    \/\/ Volume Up\r\n    bleKeyboard.write(KEY_MEDIA_VOLUME_UP);\r\n    \r\n  } else if (vertical == 0) {\r\n\r\n    \/\/ Volume Down\r\n    bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN);\r\n    \r\n  }\r\n  \/\/ Horizontal\r\n  \/\/ Will be 0-4095\r\n  horizontal = analogRead(HORIZ);\r\n  if (horizontal == 4095) {\r\n\r\n    \/\/ Previous Track\r\n    bleKeyboard.write(KEY_MEDIA_PREVIOUS_TRACK);\r\n    \r\n  } else if (horizontal == 0) {\r\n\r\n    \/\/ Next Track\r\n    bleKeyboard.write(KEY_MEDIA_NEXT_TRACK);\r\n    \r\n  }\r\n  \/\/ Will be HIGH (1) if not pressed, and LOW (0) if pressed\r\n  selec = digitalRead(SEL);\r\n  if (selec == 0) {\r\n\r\n    \/\/ Play\/Pause media key\r\n    bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);\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  \/\/ Make the SEL line an input\r\n  pinMode(SEL, INPUT_PULLUP);\r\n\r\n  \/\/ ESP32 BLE Keyboard\r\n  bleKeyboard.begin();\r\n\r\n  \/\/ Setup Task\r\n  isSetupTask();\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>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 and E-Mentor<\/strong><\/p>\n<ul>\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>J. Luc Paquin \u2013 Curriculum Vitae &#8211; 2022 English &#038; Espa\u00f1ol<\/strong><br \/>\nhttps:\/\/www.jlpconsultants.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Web:<\/strong> https:\/\/www.jlpconsultants.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/channel\/UC5eRjrGn1CqkkGfZy0jxEdA<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 #ESP32 #RTOS #FreeRTOS #Bluetooth #ThumbJoystick #Keyboard #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Joystick A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. Joysticks are often used to control video &#8230; <a title=\"Project #24 &#8211; RTOS &#8211; Bluetooth &#8211; Mk03\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3240\" aria-label=\"Read more about Project #24 &#8211; RTOS &#8211; Bluetooth &#8211; Mk03\">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":[236,47,50,49,38,80,59,5,58,82,10,43],"tags":[86,6,92,242,102,4,19,83,243,85,24,9,84,27,244,109,34],"class_list":["post-3240","post","type-post","status-publish","format-standard","hentry","category-rtos","category-adafruit","category-arduino","category-consultant","category-digitalelectronics","category-esp32","category-fritzing","category-microcontrollers","category-arduino-programming","category-program-esp32","category-projects","category-sparkfun","tag-adafruit","tag-arduino","tag-battery","tag-bluetooth","tag-components","tag-consultant","tag-electronics","tag-esp32","tag-freertos","tag-fritzing","tag-microcontroller","tag-programming","tag-programming-esp32","tag-projects-2","tag-rtos","tag-sparkfun","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3240","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=3240"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3240\/revisions"}],"predecessor-version":[{"id":3706,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3240\/revisions\/3706"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}