{"id":3459,"date":"2023-06-10T05:57:29","date_gmt":"2023-06-10T12:57:29","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3459"},"modified":"2023-06-10T05:57:29","modified_gmt":"2023-06-10T12:57:29","slug":"project-12-robotics-9dof-mk27","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3459","title":{"rendered":"Project #12: Robotics &#8211; 9DOF &#8211; Mk27"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3459-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #Robotics #Magnetometer #Accelerometer #Gyroscope #MicroOLED # #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\/06\/DL2305Mk03a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03a.png\" alt=\"9DOF\" width=\"720\" height=\"447\" class=\"alignnone size-full wp-image-3461\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03a-300x186.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\/06\/DL2305Mk03b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03b.png\" alt=\"9DOF\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3462\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03b-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\/06\/DL2305Mk03c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03c.png\" alt=\"9DOF\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3463\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/06\/DL2305Mk03c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>SparkFun 9 Degrees of Freedom &#8211; Sensor Stick<\/strong><\/p>\n<p>The SparkFun 9DOF Sensor Stick is a very small sensor board with 9 degrees of freedom. It includes the ADXL345 accelerometer, the HMC5883L magnetometer, and the ITG-3200 MEMS gyro. The &#8220;Stick&#8221; has a simple I2C interface and a mounting hole for attaching it to your project. Also, the board is a mere allowing it to be easily mounted in just about any application.<\/p>\n<p><strong>DL2305Mk03<\/strong><\/p>\n<p>1 x SparkFun RedBoard Qwiic<br \/>\n1 x ProtoScrewShield<br \/>\n1 x SparkFun 9 Degrees of Freedom &#8211; Sensor Stick<br \/>\n1 x SparkFun Micro OLED Breakout (Qwiic)<br \/>\n1 x Thumb Joystick<br \/>\n1 x SparkFun Thumb Joystick Breakout<br \/>\n2 x Pololu DRV8834 Low-Voltage Stepper Motor Driver Carrier<br \/>\n2 x Electrolytic Decoupling Capacitors &#8211; 100uF\/25V<br \/>\n2 x Pololu Stepper Motor Bipolar, 2.8V, 1.7 A\/Phase<br \/>\n2 x Pololu Universal Aluminum Mounting Hub for 5mm Shaft, M3 Holes<br \/>\n1 x SparkFun Solderable Breadboard &#8211; Large<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>SparkFun RedBoard Qwiic<\/strong><\/p>\n<p>SDA &#8211; Analog A5<br \/>\nSCL &#8211; Analog A4<br \/>\nJH &#8211; Analog A0<br \/>\nJV &#8211; Analog A1<br \/>\nJS &#8211; Digital 2<br \/>\nDIR &#8211; Digital 7<br \/>\nSPR &#8211; Digital 8<br \/>\nDIL &#8211; Digital 9<br \/>\nSPL &#8211; Digital 10<br \/>\nLED &#8211; Digital 13<br \/>\nVIN &#8211; +3.3V<br \/>\nVIN &#8211; +5V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2305Mk03p.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 #12: Robotics - 9DOF - Mk27\r\n12-27\r\nDL2305Mk03p.ino\r\n1 x SparkFun RedBoard Qwiic\r\n1 x ProtoScrewShield\r\n1 x SparkFun 9 Degrees of Freedom - Sensor Stick\r\n1 x SparkFun Micro OLED Breakout (Qwiic)\r\n1 x Thumb Joystick\r\n1 x SparkFun Thumb Joystick Breakout\r\n2 x Pololu DRV8834 Low-Voltage Stepper Motor Driver Carrier\r\n2 x Electrolytic Decoupling Capacitors - 100uF\/25V\r\n2 x Pololu Stepper Motor Bipolar, 2.8V, 1.7 A\/Phase\r\n2 x Pololu Universal Aluminum Mounting Hub for 5mm Shaft, M3 Holes\r\n1 x SparkFun Solderable Breadboard - Large\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\/\/ DRV8834 Stepper Motor Driver\r\n#include &lt;BasicStepperDriver.h&gt;\r\n#include &lt;MultiDriver.h&gt;\r\n\/\/ Wire communicate with I2C \/ TWI devices\r\n#include &lt;Wire.h&gt;\r\n\/\/ SparkFun Micro OLED\r\n#include &lt;SFE_MicroOLED.h&gt;\r\n\/\/ Accelerometer\r\n#include &lt;ADXL345.h&gt;\r\n\/\/ Magnetometer\r\n#include &lt;HMC58X3.h&gt;\r\n\/\/ MEMS Gyroscope\r\n#include &lt;ITG3200.h&gt;\r\n\/\/ Debug\r\n#include &quot;DebugUtils.h&quot;\r\n\/\/ FreeIMU\r\n#include &lt;CommunicationUtils.h&gt;\r\n#include &lt;FreeIMU.h&gt;\r\n\r\n\/\/ DRV8834 Stepper Motor Driver\r\n\/\/ Stepper motor steps per revolution.\r\n\/\/ Most steppers are 200 steps or 1.8 degrees\/step\r\n#define MOTOR_STEPS 200\r\n\/\/ Target RPM for X axis stepper motor\r\n#define MOTOR_X_RPM 800\r\n\/\/ Target RPM for Y axis stepper motor\r\n#define MOTOR_Y_RPM 800\r\n\/\/ Since microstepping is set externally,\r\n\/\/ make sure this matches the selected mode\r\n\/\/ If it doesn&#039;t, the motor will move at a\r\n\/\/ different RPM than chosen\r\n\/\/ 1=full step, 2=half step etc.\r\n#define MICROSTEPS 1\r\n\/\/ X Stepper motor\r\n#define DIR_X 7\r\n#define STEP_X 8\r\n\/\/ Y Stepper motor\r\n#define DIR_Y 9\r\n#define STEP_Y 10\r\n\/\/ BasicStepperDriver\r\nBasicStepperDriver stepperX(MOTOR_STEPS, DIR_X, STEP_X);\r\nBasicStepperDriver stepperY(MOTOR_STEPS, DIR_Y, STEP_Y);\r\n\/\/ Pick one of the two controllers below\r\n\/\/ each motor moves independently\r\nMultiDriver controller(stepperX, stepperY);\r\n\r\n\/\/ Joystick\r\n#define JH A0\r\n#define JV A1\r\n#define JS 2\r\n\r\n\/\/ Variable for reading the button\r\nint JSState = 0;\r\n\/\/ Adjusted Value\r\nint adjustedValue = 0;\r\nint adjustedValue2 = 0;\r\n\r\n\/\/ LED Yellow\r\nint iLED = 13;\r\n\r\n\/\/ SparkFun Micro OLED\r\n#define PIN_RESET 9\r\n#define DC_JUMPER 1\r\n\/\/ I2C declaration\r\nMicroOLED oled(PIN_RESET, DC_JUMPER);\r\n\r\n\/\/ Set the FreeIMU object\r\nFreeIMU my3IMU = FreeIMU();\r\n\r\n\/\/ Yaw Pitch Roll\r\nfloat ypr[3];\r\nfloat Yaw = 0;\r\nfloat Pitch = 0;\r\nfloat Roll = 0;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;12-27&quot;;\r\n\r\nvoid loop() {\r\n  \r\n  \/\/ Button\r\n  isButton();\r\n\r\n  \/\/ Joystick\r\n  isThumbJoystick();\r\n  \r\n  \/\/ Stepper\r\n  isStepper();\r\n\r\n  \/\/ isFreeIMU\r\n  isFreeIMU();\r\n\r\n  \/\/ Micro OLED\r\n  isMicroOLED();\r\n \r\n}\r\n<\/pre>\n<p><strong>getButton.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Button\r\n\/\/ Button Setup\r\nvoid isButtonSetup() {\r\n  \r\n  \/\/ Make the button line an input\r\n  pinMode(JS, INPUT_PULLUP);\r\n  \/\/ Initialize digital pin iLED as an output\r\n  pinMode(iLED, OUTPUT);\r\n  \r\n}\r\n\r\n\/\/ Button\r\nvoid isButton(){\r\n\r\n  \/\/ Read the state of the button\r\n  JSState = digitalRead(JS);\r\n\r\n  \/\/ Check if the button is pressed.\r\n  \/\/ If it is, the JSState is HIGH:\r\n  if (JSState == HIGH) {\r\n    \r\n    \/\/ Button\r\n    \/\/ Turn the LED on HIGH \r\n    digitalWrite(iLED, HIGH);\r\n    \r\n  } else {\r\n    \r\n    \/\/ Button\r\n    \/\/ Turn the LED on LOW \r\n    digitalWrite(iLED, LOW);\r\n    \r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>getFreeIMU.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ FreeIMU\r\n\/\/ isFreeIMUSetup\r\nvoid isFreeIMUSetup(){\r\n\r\n  \/\/ Pause\r\n  delay(5);\r\n  \/\/ Initialize IMU\r\n  my3IMU.init();\r\n  \/\/ Pause\r\n  delay(5);\r\n  \r\n}\r\n\/\/ isFreeIMU\r\nvoid isFreeIMU(){\r\n\r\n  \/\/ FreeIMU\r\n  \/\/ Yaw Pitch Roll\r\n  my3IMU.getYawPitchRoll(ypr);\r\n  \/\/ Yaw\r\n  Yaw = ypr[0];\r\n  \/\/ Pitch\r\n  Pitch = ypr[1];\r\n  \/\/ Roll\r\n  Roll = ypr[2];\r\n\r\n}\r\n<\/pre>\n<p><strong>getMicroOLED.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ SparkFun Micro OLED\r\n\/\/ Micro OLED Setup\r\nvoid isMicroOLEDSetup() {\r\n\r\n  \/\/ Initialize the OLED\r\n  oled.begin();\r\n  \/\/ Clear the display&#039;s internal memory\r\n  oled.clear(ALL);\r\n  \/\/ Display what&#039;s in the buffer (Splash Screen SparkFun)\r\n  oled.display();\r\n\r\n  \/\/ Delay 1000 ms\r\n  delay(1000);\r\n\r\n  \/\/ Clear the buffer.\r\n  oled.clear(PAGE);\r\n  \r\n}\r\n\/\/ Micro OLED\r\nvoid isMicroOLED() {\r\n\r\n  \/\/ Text Display FreeIMU\r\n  \/\/ Clear the display\r\n  oled.clear(PAGE);\r\n  \/\/ Set cursor to top-left\r\n  oled.setCursor(0, 0);\r\n  \/\/ Set font to type 0\r\n  oled.setFontType(0);\r\n  \/\/ Horizontal\r\n  oled.print(&quot;H: &quot;);\r\n  oled.print( adjustedValue );\r\n  \/\/ Vertical\r\n  oled.setCursor(0, 11);\r\n  oled.print(&quot;V: &quot;);\r\n  oled.print( adjustedValue2 );\r\n  \/\/ Yaw\r\n  oled.setCursor(0, 21);\r\n  oled.print(&quot;Y: &quot;);\r\n  oled.print(Yaw);\r\n  \/\/ Pitch\r\n  oled.setCursor(0, 31);\r\n  oled.print(&quot;P: &quot;);\r\n  oled.print(Pitch);\r\n  \/\/ Roll\r\n  oled.setCursor(0, 41);\r\n  oled.print(&quot;R: &quot;);\r\n  oled.print(Roll);\r\n  oled.display();\r\n\r\n}\r\n<\/pre>\n<p><strong>getStepper.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Stepper\r\n\/\/ isStepperSetup\r\nvoid isStepperSetup() {    \r\n  \r\n  \/\/ Set stepper target motors RPM.\r\n  stepperX.begin(MOTOR_X_RPM, MICROSTEPS);\r\n  stepperY.begin(MOTOR_Y_RPM, MICROSTEPS);\r\n\r\n}\r\n\/\/ Stepper\r\nvoid isStepper() {\r\n\r\n  \/\/ Stepper =&gt; Controller rotate\r\n  controller.rotate(adjustedValue, adjustedValue2);\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 JH\r\n  \/\/ Horizontal\r\n  \/\/ Joystick Pot Values JH\r\n  int potValue = analogRead(JH);\r\n  int potValues = 0;\r\n  \/\/ Adjusted Value\r\n  potValues = map(potValue, 0, 1023, 1000, -1000);\r\n  if (potValues &gt; 300) {\r\n\r\n    adjustedValue = potValues;\r\n\r\n  } else if (potValues &lt; -300) {\r\n\r\n    adjustedValue = potValues;\r\n\r\n  } else {\r\n\r\n    adjustedValue = 0;\r\n\r\n  }\r\n\r\n  \/\/ Joystick JV\r\n  \/\/ Vertical\r\n  \/\/ Joystick Pot Values JV\r\n  int potValue2 = analogRead(JV);\r\n  int potValues2 = 0;\r\n  \/\/ Adjusted Value2\r\n  potValues2 = map(potValue2, 0, 1023, 1000, -1000);\r\n  if (potValues2 &gt; 300) {\r\n\r\n    adjustedValue2 = potValues2;\r\n\r\n  } else if (potValues2 &lt; -300) {\r\n\r\n    adjustedValue2 = potValues2;\r\n\r\n  } else {\r\n\r\n    adjustedValue2 = 0;\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  \/\/ Wire communicate with I2C \/ TWI devices\r\n  Wire.begin();\r\n\r\n  \/\/ Setup Micro OLED\r\n  isMicroOLEDSetup();\r\n\r\n  \/\/ isFreeIMUSetup\r\n  isFreeIMUSetup();\r\n   \r\n  \/\/ Button Setup\r\n  isButtonSetup();\r\n  \r\n  \/\/ DRV8834 Stepper Motor Driver\r\n  isStepperSetup();\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 #Robotics #Magnetometer #Accelerometer #Gyroscope #MicroOLED # #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; SparkFun 9 Degrees of Freedom &#8211; Sensor Stick The SparkFun 9DOF Sensor Stick is a very small sensor board with 9 degrees of freedom. It includes the ADXL345 accelerometer, the HMC5883L magnetometer, and the ITG-3200 &#8230; <a title=\"Project #12: Robotics &#8211; 9DOF &#8211; Mk27\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3459\" aria-label=\"Read more about Project #12: Robotics &#8211; 9DOF &#8211; Mk27\">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":[94,50,49,38,59,5,46,58,10,43],"tags":[286,251,6,102,4,87,19,85,252,246,24,103,9,27,95,109,96,33,34],"class_list":["post-3459","post","type-post","status-publish","format-standard","hentry","category-robotics-projerts","category-arduino","category-consultant","category-digitalelectronics","category-fritzing","category-microcontrollers","category-pololu","category-arduino-programming","category-projects","category-sparkfun","tag-9dof","tag-accelerometer","tag-arduino","tag-components","tag-consultant","tag-display","tag-electronics","tag-fritzing","tag-gyroscope","tag-magnetometer","tag-microcontroller","tag-pololu","tag-programming","tag-projects-2","tag-robotic","tag-sparkfun","tag-stepper","tag-technology","tag-video-blog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3459","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=3459"}],"version-history":[{"count":1,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3459\/revisions"}],"predecessor-version":[{"id":3464,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3459\/revisions\/3464"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}