{"id":2977,"date":"2022-01-29T06:30:37","date_gmt":"2022-01-29T14:30:37","guid":{"rendered":"https:\/\/www.donluc.com\/?p=2977"},"modified":"2022-01-29T06:30:37","modified_gmt":"2022-01-29T14:30:37","slug":"project-12-robotics-lithium-polymer-battery-charger-mk20","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=2977","title":{"rendered":"Project #12: Robotics &#8211; Lithium Polymer Battery Charger &#8211; Mk20"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-2977-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04a.png\" alt=\"Lithium Polymer Battery Charger\" width=\"720\" height=\"680\" class=\"alignnone size-full wp-image-2979\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04a-300x283.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\/01\/DL2201Mk04b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04b.png\" alt=\"Lithium Polymer Battery Charger\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-2980\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04b-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\/01\/DL2201Mk04c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04c.png\" alt=\"Lithium Polymer Battery Charger\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-2981\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2022\/01\/DL2201Mk04c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>USB\/DC Lithium Polymer Battery Charger 5-12V &#8211; 3.7\/4.2v Cells<\/strong><\/p>\n<p>Charge your single-cell lithium ion\/polymer battery any which way you like with this board. Other nice things about this charger include multiple LEDs for power &#038; charging status, including a charging LED which will blink when the battery is full. If the charger gets too hot from high-speed charging, it will slow down the charge rate automatically. You can easily adjust the charge rate up to 1.2A or down to 100mA. For use with Adafruit Lipoly\/LiIon batteries only. Other batteries may have different voltage, chemistry, polarity or pinout.<\/p>\n<ul>\n<li>Use USB or DC power &#8211; 5 to 12V input<\/li>\n<li>Charges one single-cell 3.7\/4.2v batteries with constant current\/constant voltage<\/li>\n<li>Three indicator LEDs &#8211; green for Power, orange for charging and red for error<\/li>\n<li>Charging LED will blink when the battery is full<\/li>\n<li>2 JST connections so you can keep the battery plugged in and powering your project<\/li>\n<li>Terminal block connections galore just solder in 3.5mm terminal blocks<\/li>\n<li>Default charge rate is about 500mA, but you can easily change this by soldering in a through-hole resistor on. The chip can do 100-1200 mA charging<\/li>\n<li>Safety timer will stop charging after about 14 hours<\/li>\n<li>The chip supports a standard 10K thermistor, which we have stuffed as a standard resistor. You can solder in a thermistor easily<\/li>\n<\/ul>\n<p><strong>DL2201Mk04<\/strong><\/p>\n<p>1 x Fio v3 &#8211; ATmega32U4<br \/>\n1 x Arduino Pro Mini 328 &#8211; 5V\/16MHz<br \/>\n1 x SparkFun FTDI Basic Breakout &#8211; 5V<br \/>\n1 x USB\/DC Lithium Polymer Battery Charger<br \/>\n2 x XBee S1<br \/>\n1 x XBee Explorer Regulated<br \/>\n1 x Lithium Ion Battery &#8211; 850mAh<br \/>\n1 x Lithium Ion Battery &#8211; 2500mAh<br \/>\n1 x Thumb Joystick<br \/>\n1 x SparkFun Thumb Joystick Breakout<br \/>\n1 x Slide Pot (Small)<br \/>\n1 x Slide Potentiometer Knob<br \/>\n1 x RGB Smart NeoPixel<br \/>\n2 x DRV8835 Dual Motor Driver Carrier<br \/>\n2 x Solarbotics RM2<br \/>\n2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes<br \/>\n2 x Pololu Mini Plastic Gearmotor Bracket Pair &#8211; Wide<br \/>\n1 x Half-Size Breadboard<br \/>\n2 x Adafruit Perma-Proto Quarter-Sized Breadboard<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>Fio v3 &#8211; ATmega32U4 &#8211; Transmitter<\/strong><\/p>\n<p><strong>XBee S1:<\/strong> Transmitter<\/p>\n<p><strong>CH Channel:<\/strong> C<br \/>\n<strong>PAN Id:<\/strong> 3333<br \/>\n<strong>SH Serial Number:<\/strong> 13A200<br \/>\n<strong>SL Serial Number:<\/strong> 40717A1F<br \/>\n<strong>CE Coordinator:<\/strong> Coordinator<br \/>\n<strong>BD:<\/strong> 9600<\/p>\n<p>RX0 &#8211; Digital 0<br \/>\nTX0 &#8211; Digital 1<br \/>\nPO0 &#8211; Analog A0<br \/>\nJY0 &#8211; Analog A1<br \/>\nJY1 &#8211; Analog A2<br \/>\nSE0 &#8211; Digital 16<br \/>\nVIN &#8211; +3.3V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2201Mk04t.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 - Lithium Polymer Battery Charger - Mk20\r\n01-04\r\nTransmitter\r\nDL2201Mk04t.ino\r\n1 x Fio v3 - ATmega32U4\r\n1 x XBee S1\r\n1 x Lithium Ion Battery - 850mAh\r\n1 x Thumb Joystick\r\n1 x SparkFun Thumb Joystick Breakout\r\n1 x Slide Pot (Small)\r\n1 x Slide Potentiometer Knob\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ EEPROM library to read and write EEPROM with unique ID for unit\r\n#include &lt;EEPROM.h&gt;\r\n\r\n\/\/ Communication\r\nunsigned long dTime = 200;\r\n\r\n\/\/ Slide Pot (Small)\r\n\/\/ Select the input pin for the slide pot\r\n\/\/ Power\r\nconst int iSP1 = A0;\r\n\/\/ Power to store the value\r\nint iPower = 0;\r\n\r\n\/\/ Connections to joystick\r\n\/\/ Vertical\r\nconst int VERT = A1;\r\n\/\/ Horizontal\r\nconst int HORIZ = A2;\r\n\/\/ Pushbutton\r\nconst int SEL = 16;\r\n\/\/ Initialize variables for analog and digital values\r\nint vertical;\r\nint horizontal;\r\nint select;\r\n\r\n\/\/ Software Version Information\r\n\/\/ Version\r\nString sver = &quot;12-20t&quot;;\r\n\/\/ Unit ID Information\r\n\/\/ UID\r\nString uid = &quot;&quot;;\r\n\r\nvoid loop()\r\n{\r\n\r\n  \/\/ Thumb Joystick\r\n  isThumbJoystick();\r\n    \r\n  \/\/ Process Message\r\n  isProcessMessage();\r\n\r\n  delay( dTime );\r\n  \r\n}\r\n<\/pre>\n<p><strong>getEEPROM.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ EEPROM\r\n\/\/ is UID\r\nvoid isUID()\r\n{\r\n  \r\n  \/\/ Is Unit ID\r\n  \/\/ UID\r\n  uid = &quot;&quot;;\r\n  for (int x = 0; x &lt; 5; x++)\r\n  {\r\n    uid = uid + char(EEPROM.read(x));\r\n  }\r\n  \r\n}\r\n<\/pre>\n<p><strong>getProcessMessage.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Process Message\r\n\/\/ isProcessMessage\r\nvoid isProcessMessage() {\r\n  \r\n   \/\/ Loop through serial buffer\r\n   \/\/ Print = &quot;&lt;&quot; + vertical + &quot;|&quot; + horizontal + &quot;|&quot; + select + &quot;|&quot; + iValue + &quot;|&quot; + sver + &quot;|&quot; + uid + &quot;*&quot;\r\n      \r\n   Serial1.print( &#039;&lt;&#039;  );\r\n   Serial1.print( vertical );\r\n   Serial1.print( &#039;|&#039; );\r\n   Serial1.print( horizontal );\r\n   Serial1.print( &#039;|&#039; );\r\n   Serial1.print( select );\r\n   Serial1.print( &#039;|&#039; );\r\n   Serial1.print( iPower );\r\n   Serial1.print( &#039;|&#039; );\r\n   Serial1.print( sver );\r\n   Serial1.print( &#039;|&#039; );\r\n   Serial1.print( uid );\r\n   Serial1.println( &#039;*&#039; );\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 520 for the vertical and horizontal values\r\n  \/\/ Will be 0-1023\r\n  vertical = analogRead(VERT);\r\n  \/\/ Will be 0-1023\r\n  horizontal = analogRead(HORIZ);\r\n  \/\/ Will be HIGH (1) if not pressed, and LOW (0) if pressed\r\n  select = digitalRead(SEL);\r\n  \/\/ Read the value\r\n  \/\/ Power be 0-1023\r\n  iPower = analogRead( iSP1 );\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  \/\/ EEPROM Unit ID\r\n  isUID();\r\n  \r\n  \/\/ Pause\r\n  delay(5);\r\n  \r\n  \/\/ Make the SEL line an input\r\n  pinMode(SEL, INPUT_PULLUP);\r\n  \r\n  \/\/ Open Serial1 port at 9600 baud\r\n  Serial1.begin( 9600 );\r\n\r\n  \/\/ Pause\r\n  delay(5);\r\n\r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Arduino Pro Mini 328 &#8211; 5V\/16MHz &#8211; Receiver<\/strong><\/p>\n<p><strong>XBee S1:<\/strong> Receiver<\/p>\n<p><strong>CH Channel:<\/strong> C<br \/>\n<strong>PAN Id:<\/strong> 3333<br \/>\n<strong>SH Serial Number:<\/strong> 13A200<br \/>\n<strong>SL Serial Number:<\/strong> 4076E2C5<br \/>\n<strong>CE Coordinator:<\/strong> End Device<br \/>\n<strong>BD:<\/strong> 9600<\/p>\n<p>RX0 &#8211; Digital 0<br \/>\nTX0 &#8211; Digital 1<br \/>\nM11 &#8211; Digital 2<br \/>\nM12 &#8211; Digital 3<br \/>\nM21 &#8211; Digital 4<br \/>\nM22 &#8211; Digital 5<br \/>\nNEO &#8211; Digital 6<br \/>\nVIN &#8211; +5V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2201Mk04r.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 - Lithium Polymer Battery Charger - Mk20\r\n01-04\r\nReceiver\r\nDL2201Mk04r.ino\r\n1 x Arduino Pro Mini 328 - 5V\/16MHz\r\n1 x SparkFun FTDI Basic Breakout - 5V\r\n1 x XBee S1\r\n1 x XBee Explorer Regulated\r\n1 x USB\/DC Lithium Polymer Battery Charger\r\n1 x Lithium Ion Battery - 2500mAh\r\n1 x RGB Smart NeoPixel\r\n2 x DRV8835 Dual Motor Driver Carrier\r\n2 x Solarbotics RM2\r\n2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes\r\n2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide\r\n1 x Half-Size Breadboard\r\n2 x Adafruit Perma-Proto Quarter-Sized Breadboard\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the library code:\r\n\/\/ EEPROM library to read and write EEPROM with unique ID for unit\r\n#include &lt;EEPROM.h&gt;\r\n\/\/ NeoPixels\r\n#include &lt;Adafruit_NeoPixel.h&gt;\r\n\r\n\/\/ Solarbotics RM2 -&gt; 1\r\n#define MOTOR1_IN1 2\r\n#define MOTOR1_IN2 3\r\n\/\/ Solarbotics RM2 -&gt; 2\r\n#define MOTOR2_IN1 4\r\n#define MOTOR2_IN2 5\r\n\r\n\/\/ Power be 0-1023\r\nint iPower = 0;\r\nString POW = &quot;&quot;;\r\n\/\/ Joystick was sitting around 520 for the vertical and horizontal values\r\n\/\/ Will be 0-1023\r\n\/\/ Vertical\r\nint vertical;\r\nString VER = &quot;&quot;;\r\n\/\/ Horizontal\r\n\/\/ Will be 0-1023\r\nint horizontal;\r\nString HOR = &quot;&quot;;\r\n\/\/ Select\r\n\/\/ Will be HIGH (1) if not pressed, and LOW (0) if pressed\r\nint select1 = 0;\r\nString SEL = &quot;&quot;;\r\nint firstClosingBracket = 0;\r\n\/\/ Map Vertical and Horizontal\r\nint mapVer = 0;\r\nint mapHor = 0;\r\nint iVer = 1;\r\nint iHor = 0;\r\n\r\n\/\/ NeoPixels\r\n\/\/ On digital pin 6\r\n#define PIN 6\r\n\/\/ NeoPixels NUMPIXELS = 1\r\n#define NUMPIXELS 1\r\n\/\/ Pixels\r\nAdafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);\r\n\/\/ Red\r\nint red = 0;\r\n\/\/ Green\r\nint green = 0;\r\n\/\/ Blue\r\nint blue = 0;\r\n\/\/ Neopix\r\nint iNeo = 0;\r\n\/\/ Value\r\nint zz = 0;\r\n\r\n\/\/ Process Message\r\n\/\/ Start\r\nbool bStart = false;\r\n\/\/ End\r\nbool bEnd   = false;\r\n\/\/ Variable to store the incoming byte\r\nint incb = 0;\r\n\/\/ Message\r\nString msg = &quot;&quot;;\r\n\/\/ Index\r\nbyte in = 0;\r\nint x = 0;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;12-20r&quot;;\r\n\/\/ Unit ID information\r\nString uid = &quot;&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Check for serial messages\r\n  isProcessMessage();\r\n\r\n}\r\n<\/pre>\n<p><strong>getEEPROM.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ EEPROM\r\n\/\/ isUID\r\nvoid isUID()\r\n{\r\n  \r\n  \/\/ Is Unit ID\r\n  uid = &quot;&quot;;\r\n  for (int x = 0; x &lt; 5; x++)\r\n  {\r\n    uid = uid + char(EEPROM.read(x));\r\n  }\r\n  \r\n}\r\n<\/pre>\n<p><strong>getNeopix.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ NeoPixels\r\n\/\/ Neopix\r\nvoid isNeopix() \r\n{ \r\n\r\n    \/\/ Pixels\r\n    pixels.setBrightness( 130 );\r\n    \/\/ Pixels color takes RGB values, from 0,0,0 up to 255,255,255\r\n    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); \r\n    \/\/ This sends the updated pixel color to the hardware\r\n    pixels.show(); \r\n    \/\/ Delay for a period of time (in milliseconds)\r\n    delay(50);     \r\n  \r\n}\r\n\/\/ isNUMPIXELS\r\nvoid isNUMPIXELS()\r\n{\r\n\r\n  \/\/ Neopix Value\r\n  switch ( zz ) {  \r\n    case 0:\r\n      \/\/ NeoPixels Green\r\n      \/\/ Red\r\n      red = 0;\r\n      \/\/ Green\r\n      green = 255;\r\n      \/\/ Blue\r\n      blue = 0;\r\n      \/\/ Neopix\r\n      iNeo = 0;   \r\n      isNeopix();\r\n      break;  \r\n    case 1:\r\n      \/\/ NeoPixels Blue\r\n      \/\/ Red\r\n      red = 0;\r\n      \/\/ Green\r\n      green = 0;\r\n      \/\/ Blue\r\n      blue = 255;\r\n      \/\/ Neopix\r\n      iNeo = 0;\r\n      isNeopix();\r\n      break;\r\n    case 2:\r\n      \/\/ NeoPixels Red\r\n      \/\/ Red\r\n      red = 255;\r\n      \/\/ Green\r\n      green = 0;\r\n      \/\/ Blue\r\n      blue = 0;\r\n      \/\/ Neopix\r\n      iNeo = 0;   \r\n      isNeopix();\r\n      break;\r\n    case 3:\r\n      \/\/ NeoPixels Yellow\r\n      \/\/ Red\r\n      red = 255;\r\n      \/\/ Green\r\n      green = 255;\r\n      \/\/ Blue\r\n      blue = 0;\r\n      \/\/ Neopix\r\n      iNeo = 0;\r\n      isNeopix();\r\n      break;\r\n    case 4:\r\n      \/\/ NeoPixels Magenta\r\n      \/\/ Red\r\n      red = 255;\r\n      \/\/ Green\r\n      green = 0;\r\n      \/\/ Blue\r\n      blue = 255;\r\n      \/\/ Neopix\r\n      iNeo = 0;\r\n      isNeopix();\r\n      break;\r\n    case 5:\r\n      \/\/ NeoPixels Cyan\r\n      \/\/ Red\r\n      red = 0;\r\n      \/\/ Green\r\n      green = 255;\r\n      \/\/ Blue\r\n      blue = 255;\r\n      \/\/ Neopix\r\n      iNeo = 0;\r\n      isNeopix();\r\n      break;\r\n    case 6:\r\n      \/\/ NeoPixels White\r\n      \/\/ Red\r\n      red = 255;\r\n      \/\/ Green\r\n      green = 255;\r\n      \/\/ Blue\r\n      blue = 255;\r\n      \/\/ Neopix\r\n      iNeo = 0;\r\n      isNeopix();    \r\n      break;\r\n  }\r\n  \r\n}\r\n\/\/ isNUMPIXELSoff\r\nvoid isNUMPIXELSoff()\r\n{\r\n\r\n   \/\/ Black Off\r\n   \/\/ NeoPixels\r\n   \/\/ Red\r\n   red = 0;\r\n   \/\/ Green\r\n   green = 0;\r\n   \/\/ Blue\r\n   blue = 0;\r\n   isNeopix();\r\n \r\n}\r\n<\/pre>\n<p><strong>getProcessMessage.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ ProcessMessage\r\n\/\/ isProcessMessage\r\nvoid isProcessMessage() {\r\n\r\n  \/\/ Loop through serial buffer one byte at a time until you reach * which will be end of message\r\n  while ( Serial.available() &gt; 0 ) \r\n  {\r\n      \r\n      \/\/ Read the incoming byte:\r\n      incb = Serial.read();\r\n      \r\n      \/\/ Start the message when the &#039;&lt;&#039; symbol is received\r\n      if(incb == &#039;&lt;&#039;)\r\n      {\r\n\r\n        \/\/ Start\r\n        bStart = true;\r\n        in = 0;\r\n        msg = &quot;&quot;;\r\n        \r\n      }\r\n      \/\/ End the message when the &#039;*&#039; symbol is received\r\n      else if(incb == &#039;*&#039;)\r\n      {\r\n        \r\n        \/\/ End\r\n        bEnd = true;\r\n        x = msg.length();\r\n        msg.remove( x , 1);\r\n        \/\/ Done reading\r\n        \r\n        break;\r\n      }\r\n      \/\/ Read the message\r\n      else\r\n      {\r\n        \r\n        \/\/ Message\r\n        msg = msg + char(incb);\r\n        in++;\r\n\r\n      }\r\n      \r\n   }\r\n\r\n   \/\/ Start - End\r\n   if( bStart &amp;&amp; bEnd)\r\n   {\r\n\r\n      \/\/ isRM2Motor =&gt; Message\r\n      isRM2Motor();\r\n      \r\n      \/\/ Start - End\r\n      in = 0;\r\n      msg = &quot;&quot;;\r\n      bStart = false;\r\n      bEnd = false;\r\n      vertical;\r\n      horizontal;\r\n      iPower;\r\n      \r\n   }\r\n\r\n}\r\n<\/pre>\n<p><strong>getRM2Motor.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ RM2 Motor\r\n\/\/ Setup RM2 Motor\r\nvoid isSetupRM2Motor() {\r\n\r\n  \/\/ Solarbotics RM2 -&gt; 1\r\n  pinMode(MOTOR1_IN1, OUTPUT);\r\n  pinMode(MOTOR1_IN2, OUTPUT);\r\n  \/\/ Solarbotics RM2 -&gt; 2\r\n  pinMode(MOTOR2_IN1, OUTPUT);\r\n  pinMode(MOTOR2_IN2, OUTPUT);\r\n  \r\n}\r\n\/\/ isRM2Motor\r\nvoid isRM2Motor() {\r\n\r\n  \/\/ msg = vertical + &quot;|&quot; + horizontal + &quot;|&quot; + select + &quot;|&quot; + iValue + &quot;|&quot; + sver + &quot;|&quot; + uid\r\n  firstClosingBracket = 0;\r\n  \/\/ Vertical\r\n  firstClosingBracket = msg.indexOf(&#039;|&#039;);\r\n  VER = msg;\r\n  VER.remove(firstClosingBracket);\r\n  vertical = VER.toInt();\r\n  \/\/ Horizontal\r\n  firstClosingBracket = firstClosingBracket + 1;\r\n  msg.remove(0, firstClosingBracket );\r\n  firstClosingBracket = msg.indexOf(&#039;|&#039;);\r\n  HOR = msg;\r\n  HOR.remove(firstClosingBracket);\r\n  horizontal = HOR.toInt();\r\n  \/\/ Select\r\n  firstClosingBracket = firstClosingBracket + 1;\r\n  msg.remove(0, firstClosingBracket );  \r\n  firstClosingBracket = msg.indexOf(&#039;|&#039;);\r\n  SEL = msg;\r\n  SEL.remove(firstClosingBracket);\r\n  select1 = SEL.toInt();\r\n  \/\/ Power\r\n  firstClosingBracket = firstClosingBracket + 1;\r\n  msg.remove(0, firstClosingBracket );    \r\n  firstClosingBracket = msg.indexOf(&#039;|&#039;);\r\n  POW = msg;\r\n  POW.remove(firstClosingBracket);\r\n  iPower = POW.toInt();\r\n\r\n  \/\/ Set the direction\r\n  \/\/ Joystick was sitting around 520 for the vertical and horizontal values\r\n  \/\/ Will be 0-1023\r\n  mapVer = map(vertical, 0, 1023, -512, 512);\r\n  mapHor = map(horizontal, 0, 1023, -512, 512);\r\n  \/\/ Power\r\n  iPower = map(iPower, 0, 1023, 30, 200);\r\n\r\n  \/\/ Vertical and Horizontal \r\n  if ( mapVer == -512 ) {\r\n\r\n      \/\/ Down\r\n      \/\/ NeoPixels Blue\r\n      zz = 1;\r\n      isNUMPIXELS();\r\n      iVer = 1;\r\n    \r\n  } else if ( mapVer == 512 ) {\r\n\r\n      \/\/ Up\r\n      \/\/ NeoPixels Green\r\n      zz = 0;\r\n      isNUMPIXELS();\r\n      iVer = 2;\r\n \r\n  } else if ( mapHor == -512 ) {\r\n\r\n      \/\/ Left\r\n      \/\/ NeoPixels Yellow\r\n      zz = 3;\r\n      isNUMPIXELS();\r\n      iVer = 3;\r\n    \r\n  } else if ( mapHor == 512 ) {\r\n\r\n      \/\/ Right\r\n      \/\/ NeoPixels Magenta\r\n      zz = 4;\r\n      isNUMPIXELS();\r\n      iVer = 4;\r\n \r\n  } else {\r\n\r\n    \/\/ Stop\r\n    \/\/ NeoPixels Red\r\n    zz = 2;\r\n    isNUMPIXELS();\r\n    iVer = 5;\r\n    \r\n  }\r\n\r\n  \/\/ XBee Car\r\n  switch ( iVer ) {\r\n    case 1:\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 1 Forward\r\n      digitalWrite(MOTOR1_IN1, LOW);\r\n      analogWrite(MOTOR1_IN2, iPower);\r\n      delay(10);\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 2 Forward\r\n      digitalWrite(MOTOR2_IN1, LOW);\r\n      analogWrite(MOTOR2_IN2, iPower);\r\n      delay(10);\r\n\r\n      break;\r\n    case 2:\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 1 Backward\r\n      digitalWrite(MOTOR1_IN2, LOW);\r\n      analogWrite(MOTOR1_IN1, iPower);\r\n      delay(10);\r\n      \r\n      \/\/ Solarbotics RM2 -&gt; 2 Backward\r\n      digitalWrite(MOTOR2_IN2, LOW);\r\n      analogWrite(MOTOR2_IN1, iPower);\r\n      delay(10);\r\n\r\n      break;\r\n    case 3:\r\n\r\n      \/\/ Right\r\n      \/\/ Solarbotics RM2 -&gt; 1 Forward\r\n      digitalWrite(MOTOR1_IN1, LOW);\r\n      analogWrite(MOTOR1_IN2, iPower);\r\n      delay(10);\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 2 Backward\r\n      digitalWrite(MOTOR2_IN2, LOW);\r\n      analogWrite(MOTOR2_IN1, iPower);\r\n      delay(10);\r\n\r\n      break;\r\n    case 4:\r\n\r\n      \/\/ Left\r\n      \/\/ Solarbotics RM2 -&gt; 1 Backward\r\n      digitalWrite(MOTOR1_IN2, LOW);\r\n      analogWrite(MOTOR1_IN1, iPower);\r\n      delay(10);\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 2 Forward\r\n      digitalWrite(MOTOR2_IN1, LOW);\r\n      analogWrite(MOTOR2_IN2, iPower);\r\n      delay(10);\r\n      \r\n      break;\r\n    case 5:\r\n\r\n      \/\/ Stop\r\n      \/\/ NeoPixels Red\r\n      \/\/zz = 2;\r\n      \/\/isNUMPIXELS();\r\n      \/\/ Solarbotics RM2 -&gt; 1\r\n      digitalWrite(MOTOR1_IN1, LOW);\r\n      analogWrite(MOTOR1_IN2, 0);\r\n      delay(10);\r\n\r\n      \/\/ Solarbotics RM2 -&gt; 2 \r\n      digitalWrite(MOTOR2_IN1, LOW);\r\n      analogWrite(MOTOR2_IN2, 0);\r\n      delay(10); \r\n      \r\n      break;\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  \/\/ Open the serial port at 9600 bps:\r\n  Serial.begin( 9600 );\r\n\r\n  \/\/ Pause\r\n  delay(5);\r\n\r\n  \/\/ EEPROM Unit ID\r\n  isUID();\r\n  \r\n  \/\/ Pause\r\n  delay(5);\r\n\r\n  \/\/ Setup Solarbotics RM2 Motor\r\n  isSetupRM2Motor();\r\n\r\n  \/\/ Pause\r\n  delay(5);\r\n  \r\n  \/\/ NeoPixels\r\n  \/\/ This initializes the NeoPixel library\r\n  pixels.begin();\r\n  \/\/ Delay for a period of time (in milliseconds)\r\n  delay(50);\r\n  \/\/ isNUMPIXELS Off\r\n  isNUMPIXELSoff();\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>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>Research &#038; Development (R &#038; D)<\/li>\n<li>Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc&#8230;)<\/li>\n<li>Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc&#8230;)<\/li>\n<li>Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc&#8230;)<\/li>\n<li>Social Media Programming &#038; Integration (Facebook, Twitter, YouTube, Pinterest, etc&#8230;)<\/li>\n<li>Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc&#8230;)<\/li>\n<li>Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc&#8230;)<\/li>\n<li>eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc&#8230;)<\/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<li>DOS, Windows, OSX, Linux, iOS, Android, Multi-OS<\/li>\n<li>Linux-Apache-PHP-MySQL<\/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 #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; USB\/DC Lithium Polymer Battery Charger 5-12V &#8211; 3.7\/4.2v Cells Charge your single-cell lithium ion\/polymer battery any which way you like with this board. Other nice things about this charger include multiple LEDs for power &#038; &#8230; <a title=\"Project #12: Robotics &#8211; Lithium Polymer Battery Charger &#8211; Mk20\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=2977\" aria-label=\"Read more about Project #12: Robotics &#8211; Lithium Polymer Battery Charger &#8211; Mk20\">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,47,50,38,59,5,46,58,10,43],"tags":[86,6,92,102,4,200,19,85,202,24,103,9,27,95,109,33,100],"class_list":["post-2977","post","type-post","status-publish","format-standard","hentry","category-robotics-projerts","category-adafruit","category-arduino","category-digitalelectronics","category-fritzing","category-microcontrollers","category-pololu","category-arduino-programming","category-projects","category-sparkfun","tag-adafruit","tag-arduino","tag-battery","tag-components","tag-consultant","tag-dc-motor","tag-electronics","tag-fritzing","tag-lithium-polymer-battery-charger","tag-microcontroller","tag-pololu","tag-programming","tag-projects-2","tag-robotic","tag-sparkfun","tag-technology","tag-xbee"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2977","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=2977"}],"version-history":[{"count":2,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2977\/revisions"}],"predecessor-version":[{"id":2983,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/2977\/revisions\/2983"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}