The Alpha Geek – Geeking Out

Components

Project #12: Robotics – Pololu Ball Caster – Mk22

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Pololu Ball Caster

——

Pololu Ball Caster

——

Pololu Ball Caster

——

Pololu Ball Caster with 1 Inch Plastic Ball and Ball Bearings

This ball caster uses a 1 inch diameter plastic ball and has an overall height of 1.1 inches (29 mm). The two-part housing snaps together to securely enclose the ball and three ball bearings that minimize friction between the ball and the ABS housing.

This ball caster kit includes a two-part black ABS housing, a 1 inch diameter POM plastic ball, three 3 mm × 7 mm × 3 mm ball bearings, and three dowel pins used to hold the ball bearings. When assembled, the ball caster is capable of rolling in any direction with low friction, making it suitable for use as a third contact point for wheeled, differential-drive robots weighing up to around ten pounds.

The base piece of the housing has holes for three mounting screws and slots for ball bearings. The second part of the housing snaps into the base piece to secure the ball and ball bearings. The assembled ball caster has an overall height of 1.1 inches (29 mm).

DL2202Mk02

1 x Fio v3 – ATmega32U4
1 x Arduino Pro Mini 328 – 5V/16MHz
1 x SparkFun FTDI Basic Breakout – 5V
1 x USB/DC Lithium Polymer Battery Charger
1 x Mountable Slide Switch
2 x XBee S1
1 x XBee Explorer Regulated
1 x Lithium Ion Battery – 850mAh
1 x Lithium Ion Battery – 2500mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
1 x Steren Model 155
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
15 x Standoff – Metal – #4-40 – 3/8 inch
33 x Screw – #4-40 – 1/4 inch
3 x Nut – Nylon Locknut – #4-40
1 x Pololu Ball Caster – 1 Inch Plastic Ball
1 x HDPE – Black on White – 6 inches x 12 inches x 0.25 inch
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2202Mk02t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Pololu Ball Caster - Mk22
02-02
Transmitter
DL2202Mk02t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-22t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Arduino Pro Mini 328 – 5V/16MHz – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
NEO – Digital 6
VIN – +5V
GND – GND

DL2202Mk02r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Pololu Ball Caster - Mk22
02-02
Receiver
DL2202Mk02r.ino
1 x Arduino Pro Mini 328 - 5V/16MHz
1 x SparkFun FTDI Basic Breakout - 5V
1 x XBee S1
1 x XBee Explorer Regulated
1 x USB/DC Lithium Polymer Battery Charger
1 x Mountable Slide Switch
1 x Lithium Ion Battery - 2500mAh
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
1 x Steren Model 155
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
15 x Standoff - Metal - #4-40 - 3/8 inch
33 x Screw - #4-40 - 1/4 inch
3 x Nut - Nylon Locknut - #4-40
1 x Pololu Ball Caster - 1 Inch Plastic Ball
1 x HDPE - Black on White - 6 inches x 12 inches x 0.25 inch
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select1 = 0;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 1;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-22r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isRM2Motor => Message
      isRM2Motor();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select1 = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  // Power
  iPower = map(iPower, 0, 1023, 30, 200);

  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
  } else if ( mapVer == 512 ) {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 2;
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);

      break;
    case 2:

      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);
      
      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 3:

      // Right
      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 4:

      // Left
      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);
      
      break;
    case 5:

      // Stop
      // NeoPixels Red
      //zz = 2;
      //isNUMPIXELS();
      // Solarbotics RM2 -> 1
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, 0);
      delay(10);

      // Solarbotics RM2 -> 2 
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, 0);
      delay(10); 
      
      break;
 }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // Setup Solarbotics RM2 Motor
  isSetupRM2Motor();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – Steren 155 – Mk21

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Steren 155

——

Steren 155

——

Steren 155

——

Perforated Phenolic Plate

So you finish your electronics projects, such as printed circuits. We know that designing a prototype or electronic project can be a complicated task if you do not have the necessary items to carry it out, so with us you it a phenolic plates of a face, two sided or perforated, ferric chloride, auto-adherable tracks, leaves thermal transfer or permanent ink markers so that your circuits are perfect.

Steren Model 155

Bakelite phenolic plate with copper, 4.5 cm x 4.5 cm, engraved and perforated with 164 orifices for components and 4 for fixing the plate. Ideal for projects or prototypes.

DL2202Mk01

1 x Fio v3 – ATmega32U4
1 x Arduino Pro Mini 328 – 5V/16MHz
1 x SparkFun FTDI Basic Breakout – 5V
1 x USB/DC Lithium Polymer Battery Charger
1 x Mountable Slide Switch
2 x XBee S1
1 x XBee Explorer Regulated
1 x Lithium Ion Battery – 850mAh
1 x Lithium Ion Battery – 2500mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
1 x Steren Model 155
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

DL2202Mk01t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Steren 155 - Mk21
02-01
Transmitter
DL2202Mk01t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-21t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Arduino Pro Mini 328 – 5V/16MHz – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
NEO – Digital 6
VIN – +5V
GND – GND

DL2202Mk01r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Steren 155 - Mk21
02-01
Receiver
DL2202Mk01r.ino
1 x Arduino Pro Mini 328 - 5V/16MHz
1 x SparkFun FTDI Basic Breakout - 5V
1 x XBee S1
1 x XBee Explorer Regulated
1 x USB/DC Lithium Polymer Battery Charger
1 x Mountable Slide Switch
1 x Lithium Ion Battery - 2500mAh
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
1 x Steren Model 155
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select1 = 0;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 1;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-21r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isRM2Motor => Message
      isRM2Motor();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select1 = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  // Power
  iPower = map(iPower, 0, 1023, 30, 200);

  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
  } else if ( mapVer == 512 ) {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 2;
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);

      break;
    case 2:

      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);
      
      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 3:

      // Right
      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 4:

      // Left
      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);
      
      break;
    case 5:

      // Stop
      // NeoPixels Red
      //zz = 2;
      //isNUMPIXELS();
      // Solarbotics RM2 -> 1
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, 0);
      delay(10);

      // Solarbotics RM2 -> 2 
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, 0);
      delay(10); 
      
      break;
 }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // Setup Solarbotics RM2 Motor
  isSetupRM2Motor();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – Lithium Polymer Battery Charger – Mk20

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Lithium Polymer Battery Charger

——

Lithium Polymer Battery Charger

——

Lithium Polymer Battery Charger

——

USB/DC Lithium Polymer Battery Charger 5-12V – 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 & 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.

  • Use USB or DC power – 5 to 12V input
  • Charges one single-cell 3.7/4.2v batteries with constant current/constant voltage
  • Three indicator LEDs – green for Power, orange for charging and red for error
  • Charging LED will blink when the battery is full
  • 2 JST connections so you can keep the battery plugged in and powering your project
  • Terminal block connections galore just solder in 3.5mm terminal blocks
  • 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
  • Safety timer will stop charging after about 14 hours
  • The chip supports a standard 10K thermistor, which we have stuffed as a standard resistor. You can solder in a thermistor easily

DL2201Mk04

1 x Fio v3 – ATmega32U4
1 x Arduino Pro Mini 328 – 5V/16MHz
1 x SparkFun FTDI Basic Breakout – 5V
1 x USB/DC Lithium Polymer Battery Charger
2 x XBee S1
1 x XBee Explorer Regulated
1 x Lithium Ion Battery – 850mAh
1 x Lithium Ion Battery – 2500mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2201Mk04t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Lithium Polymer Battery Charger - Mk20
01-04
Transmitter
DL2201Mk04t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-20t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Arduino Pro Mini 328 – 5V/16MHz – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
NEO – Digital 6
VIN – +5V
GND – GND

——

DL2201Mk04r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Lithium Polymer Battery Charger - Mk20
01-04
Receiver
DL2201Mk04r.ino
1 x Arduino Pro Mini 328 - 5V/16MHz
1 x SparkFun FTDI Basic Breakout - 5V
1 x XBee S1
1 x XBee Explorer Regulated
1 x USB/DC Lithium Polymer Battery Charger
1 x Lithium Ion Battery - 2500mAh
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select1 = 0;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 1;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-20r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isRM2Motor => Message
      isRM2Motor();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select1 = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  // Power
  iPower = map(iPower, 0, 1023, 30, 200);

  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
  } else if ( mapVer == 512 ) {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 2;
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);

      break;
    case 2:

      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);
      
      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 3:

      // Right
      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 4:

      // Left
      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);
      
      break;
    case 5:

      // Stop
      // NeoPixels Red
      //zz = 2;
      //isNUMPIXELS();
      // Solarbotics RM2 -> 1
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, 0);
      delay(10);

      // Solarbotics RM2 -> 2 
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, 0);
      delay(10); 
      
      break;
 }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // Setup Solarbotics RM2 Motor
  isSetupRM2Motor();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – LiPower Boost Converter – Mk19

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

LiPower Boost Converter

——

LiPower Boost Converter

——

LiPower Boost Converter

——

LiPower Boost Converter

The LiPower board is based on the incredibly versatile TPS61200 boost converter. The board is configured to be used with a LiPo battery, has solder jumper selectable 5V and 3.3V output, and an under voltage protection of 2.6V. However, the board can also be used as a general purpose buck and boost regulator with an input voltage as low as 0.3V. With such a low input voltage and quiescent current, the board also works well in energy harvesting applications that use low input voltages.

XBee Explorer Regulated

The XBee Explorer Regulated takes care of the 3.3V regulation, signal conditioning, and basic activity indicators. It translates the 5V serial signals to 3.3V so that you can connect a 5V system to any XBee module. The board was conveniently designed to mate directly with Arduino Pro boards for wireless bootloading and USB based configuration. This unit works with all XBee modules including the Series 1 and Series 2.5, standard and Pro versions. Plug an XBee into this breakout and you will have direct access to the serial and programming pins on the XBee unit and will be able to power the XBee with 5V.

DL2201Mk03

1 x Fio v3 – ATmega32U4
1 x Arduino Pro Mini 328 – 5V/16MHz
1 x SparkFun FTDI Basic Breakout – 5V
1 x LiPower Boost Converter
2 x XBee S1
1 x XBee Explorer Regulated
2 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2201Mk03t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - LiPower Boost Converter - Mk19
01-03
DL2201Mk03t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-19t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Arduino Pro Mini 328 – 5V/16MHz – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
NEO – Digital 6
VIN – +5V
GND – GND

——

DL2201Mk03r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - LiPower Boost Converter - Mk19
01-03
DL2201Mk03r.ino
1 x Arduino Pro Mini 328 - 5V/16MHz
1 x SparkFun FTDI Basic Breakout - 5V
1 x XBee S1
1 x XBee Explorer Regulated
1 x LiPower Boost Converter
1 x Lithium Ion Battery - 850mAh
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select1 = 0;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 1;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-19r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isRM2Motor => Message
      isRM2Motor();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select1 = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  // Power
  iPower = map(iPower, 0, 1023, 30, 200);

  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
  } else if ( mapVer == 512 ) {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 2;
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);

      break;
    case 2:

      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);
      
      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 3:

      // Right
      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 4:

      // Left
      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);
      
      break;
    case 5:

      // Stop
      // NeoPixels Red
      //zz = 2;
      //isNUMPIXELS();
      // Solarbotics RM2 -> 1
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, 0);
      delay(10);

      // Solarbotics RM2 -> 2 
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, 0);
      delay(10); 
      
      break;
 }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // Setup Solarbotics RM2 Motor
  isSetupRM2Motor();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – DC Motor – Mk18

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #ArduinoProMini #XBee #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

DC Motor

——

DC Motor

——

DC Motor

——

DC Motor

A DC motor is any of a class of rotary electrical motors that converts direct current electrical energy into mechanical energy. The most common types rely on the forces produced by magnetic fields. Nearly all types of DC motors have some internal mechanism, either electromechanical or electronic, to periodically change the direction of current in part of the motor.

DC motors were the first form of motor widely used, as they could be powered from existing direct-current lighting power distribution systems. A DC motor’s speed can be controlled over a wide range, using either a variable supply voltage or by changing the strength of current in its field windings. Small DC motors are used in tools, toys, and appliances. The universal motor can operate on direct current but is a lightweight brushed motor used for portable power tools and appliances. Larger DC motors are currently used in propulsion of electric vehicles, elevator and hoists, and in drives for steel rolling mills. The advent of power electronics has made replacement of DC motors with AC motors possible in many applications.

DL2201Mk02

1 x Fio v3 – ATmega32U4
1 x Arduino Pro Mini 328 – 5V/16MHz
1 x SparkFun FTDI Basic Breakout – 5V
2 x XBee S1
1 x XBee Explorer Regulated
1 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2201Mk02t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - DC Motor - Mk18
01-02
DL2201Mk02t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-18t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Arduino Pro Mini 328 – 5V/16MHz – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
NEO – Digital 6
VIN – +5V
GND – GND

——

DL2201Mk02r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - DL2201Mk02r - Mk18
01-02
DL2201Mk02r.ino
1 x Arduino Pro Mini 328 - 5V/16MHz
1 x SparkFun FTDI Basic Breakout - 5V
1 x XBee S1
1 x XBee Explorer Regulated
1 x RGB Smart NeoPixel
2 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
1 x Half-Size Breadboard
2 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select1 = 0;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 1;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-18r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isRM2Motor => Message
      isRM2Motor();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select1 = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  // Power
  iPower = map(iPower, 0, 1023, 30, 200);

  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
  } else if ( mapVer == 512 ) {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 2;
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);

      break;
    case 2:

      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);
      
      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 3:

      // Right
      // Solarbotics RM2 -> 1 Forward
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Backward
      digitalWrite(MOTOR2_IN2, LOW);
      analogWrite(MOTOR2_IN1, iPower);
      delay(10);

      break;
    case 4:

      // Left
      // Solarbotics RM2 -> 1 Backward
      digitalWrite(MOTOR1_IN2, LOW);
      analogWrite(MOTOR1_IN1, iPower);
      delay(10);

      // Solarbotics RM2 -> 2 Forward
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, iPower);
      delay(10);
      
      break;
    case 5:

      // Stop
      // NeoPixels Red
      //zz = 2;
      //isNUMPIXELS();
      // Solarbotics RM2 -> 1
      digitalWrite(MOTOR1_IN1, LOW);
      analogWrite(MOTOR1_IN2, 0);
      delay(10);

      // Solarbotics RM2 -> 2 
      digitalWrite(MOTOR2_IN1, LOW);
      analogWrite(MOTOR2_IN2, 0);
      delay(10); 
      
      break;
 }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // Setup Solarbotics RM2 Motor
  isSetupRM2Motor();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – DRV8835 Dual Motor Driver – Mk17

——

#DonLucElectronics #DonLuc #Robotics #Arduino #ArduinoUNO #DCMotor #MotorDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

DRV8835 Dual Motor Driver

——

DRV8835 Dual Motor Driver

——

DRV8835 Dual Motor Driver

——

DRV8835 Dual Motor Driver Carrier

This tiny breakout board for TI’s DRV8835 dual motor driver can deliver 1.2 A per channel continuously (1.5 A peak) to a pair of DC motors, and it supports two possible control interfaces for added flexibility of use: IN/IN and PHASE/ENABLE. With an operating voltage range from 0 V to 11 V and built-in protection against reverse-voltage, under-voltage, over-current, and over-temperature, this driver is a great solution for powering up to two small, low-voltage motors. The carrier board has the form factor of a 14-pin DIP package, which makes it easy to use with standard solderless breadboards and 0.1 inch perfboards.

Solarbotics RM2 (High-Power Motor for GM2/3/8/9)

This high-power brushed DC motor fits in the GM2/3/8/9 series of gear motors, offering approximately 3 times the speed, twice the torque and quadruple the power-draw. Retrofitting the gear motor is easy – just remove the motor retainer strap, transfer the pinion gear, and reinstall – that’s it.

DL2201Mk01

1 x Arduino UNO
1 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair – Wide
2 x Rotary Potentiometer – 10k Ohm
2 x Knob
1 x Half-Size Breadboard
1 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO

M11 – Digital 2
M12 – Digital 3
M21 – Digital 4
M22 – Digital 5
PO0 – Analog A0
PO1 – Analog A1
VIN – +5V
GND – GND

——

DL2201Mk01p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - DRV8835 Dual Motor Driver - Mk17
01-01
DL2201Mk01p.ino
1 x Arduino UNO
1 x DRV8835 Dual Motor Driver Carrier
2 x Solarbotics RM2
2 x Pololu Universal Aluminum Mounting Hub 3mm Shaft, #4-40 Holes
2 x Pololu Mini Plastic Gearmotor Bracket Pair - Wide
2 x Rotary Potentiometer - 10k Ohm
2 x Knob
1 x Half-Size Breadboard
1 x Adafruit Perma-Proto Quarter-Sized Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:

// Solarbotics RM2 -> 1
#define MOTOR1_IN1 2
#define MOTOR1_IN2 3
// Solarbotics RM2 -> 2
#define MOTOR2_IN1 4
#define MOTOR2_IN2 5

// Rotary Potentiometer -> 1
int s1 = A0;
// Speed -> 1
int s1s = 0;
// Rotary Potentiometer -> 2
int s2 = A1;
// Speed -> 2
int s2s = 0;

// Software Version Information
String sver = "12-17p";
// Unit ID information
String uid = "";

void loop() {

  // RM2 Motor
  isRM2Motor();

}

getRM2Motor.ino

// RM2 Motor
// Setup RM2 Motor
void isSetupRM2Motor() {

  // Solarbotics RM2 -> 1
  pinMode(MOTOR1_IN1, OUTPUT);
  pinMode(MOTOR1_IN2, OUTPUT);
  // Solarbotics RM2 -> 2
  pinMode(MOTOR2_IN1, OUTPUT);
  pinMode(MOTOR2_IN2, OUTPUT);
  
}
// isRM2Motor
void isRM2Motor() {

  // Rotary Potentiometer -> 1
  s1s = analogRead( s1 );
  s1s = map(s1s, 0, 1023, 0, 200);
  // Rotary Potentiometer -> 2
  s2s = analogRead( s2 );  
  s2s = map(s2s, 0, 1023, 0, 200);

  // Solarbotics RM2 -> 1 Forward
  digitalWrite(MOTOR1_IN1, LOW);
  analogWrite(MOTOR1_IN2, s1s);
  delay(10);

  // Solarbotics RM2 -> 2 Backward
  digitalWrite(MOTOR2_IN2, LOW);
  analogWrite(MOTOR2_IN1, s2s);
  delay(10);

}

setup.ino

// Setup
void setup() {

  // Solarbotics RM2 Motor
  isSetupRM2Motor();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – EasyDriver – Mk16

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #XBee #Stepper #EasyDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

EasyDriver

——

EasyDriver

——

EasyDriver

——

Stepper Motor

A stepper motor, also known as step motor or stepping motor, is a brushless DC electric motor that divides a full rotation into a number of equal steps. The motor’s position can be commanded to move and hold at one of these steps without any position sensor for feedback, as long as the motor is correctly sized to the application in respect to torque and speed. Switched reluctance motors are very large stepping motors with a reduced pole count, and generally are closed-loop commutated.

EasyDriver – Stepper Motor Driver

The EasyDriver is a simple to use stepper motor driver, compatible with anything that can output a digital 0 to 5V pulse. The EasyDriver requires a 6V to 30V supply to power the motor and can power any voltage of stepper motor. The EasyDriver has an on board voltage regulator for the digital interface that can be set to 5V. Connect a 4-wire stepper motor and a microcontroller and you’ve got precision motor control! EasyDriver drives bi-polar motors, and motors wired as bi-polar.

DL2112Mk06

2 x Fio v3 – ATmega32U4
2 x XBee S1
2 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x RGB Smart NeoPixel
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

DL2112Mk06t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - XBee S1 - Transmitter - Mk16
12-06
DL2112Mk06t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 200;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-16t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Fio v3 – ATmega32U4 – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number:
4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
DR0 – Digital 2
ST0 – Digital 3
DR1 – Digital 4
ST1 – Digital 5
NEO – Digital 6
VIN – +3.3V
GND – GND

DL2112Mk06r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - EasyDriver - Mk16
12-06
DL2112Mk06r.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x RGB Smart NeoPixel
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>
// NeoPixels
#include <Adafruit_NeoPixel.h>

// 2 x EasyDriver - 2 x Stepper
// EasyDriver Right
int dirPinR = 2;
// stepPin Right
int stepPinR = 3;
// EasyDriver Left
int dirPinL = 4;
// stepPin Left
int stepPinL = 5;
// Microsteps
int i = 0;
// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;
int iVer = 0;
int iHor = 0;

// NeoPixels
// On digital pin 6
#define PIN 6
// NeoPixels NUMPIXELS = 1
#define NUMPIXELS 1
// Pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// Red
int red = 0;
// Green
int green = 0;
// Blue
int blue = 0;
// Neopix
int iNeo = 0;
// Value
int zz = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-16r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getNeopix.ino

// NeoPixels
// Neopix
void isNeopix() 
{ 

    // Pixels
    pixels.setBrightness( 130 );
    // Pixels color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); 
    // This sends the updated pixel color to the hardware
    pixels.show(); 
    // Delay for a period of time (in milliseconds)
    delay(50);     
  
}
// isNUMPIXELS
void isNUMPIXELS()
{

  // Neopix Value
  switch ( zz ) {  
    case 0:
      // NeoPixels Green
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;  
    case 1:
      // NeoPixels Blue
      // Red
      red = 0;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 2:
      // NeoPixels Red
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;   
      isNeopix();
      break;
    case 3:
      // NeoPixels Yellow
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 0;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 4:
      // NeoPixels Magenta
      // Red
      red = 255;
      // Green
      green = 0;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 5:
      // NeoPixels Cyan
      // Red
      red = 0;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();
      break;
    case 6:
      // NeoPixels White
      // Red
      red = 255;
      // Green
      green = 255;
      // Blue
      blue = 255;
      // Neopix
      iNeo = 0;
      isNeopix();    
      break;
  }
  
}
// isNUMPIXELSoff
void isNUMPIXELSoff()
{

   // Black Off
   // NeoPixels
   // Red
   red = 0;
   // Green
   green = 0;
   // Blue
   blue = 0;
   isNeopix();
 
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial1.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial1.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {

        // Start
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        // End
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        // Message
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isStepper => Message
      isStepper();
      
      // Start - End
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getStepper.ino

// Stepper
// isStepperSetup
void isStepperSetup() {

  // 2 x EasyDriver
  pinMode(dirPinR, OUTPUT);
  pinMode(stepPinR, OUTPUT);
  pinMode(dirPinL, OUTPUT);
  pinMode(stepPinL, OUTPUT);

}
// isStepper
void isStepper() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  select = SEL.toInt();
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // EasyDriver Right
  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  
  // Vertical and Horizontal 
  if ( mapVer == -512 ) {

    // Horizontal 
    if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
    } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
    } else {

      // Down
      // NeoPixels Blue
      zz = 1;
      isNUMPIXELS();
      iVer = 1;
    
    }
    
  } else if ( mapVer == 512 ) {

    // Horizontal 
    if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
    } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
    } else {

      // Up
      // NeoPixels Green
      zz = 0;
      isNUMPIXELS();
      iVer = 4;
      iVer = 2;
    
    }
 
  } else if ( mapHor == -512 ) {

      // Left
      // NeoPixels Yellow
      zz = 3;
      isNUMPIXELS();
      iVer = 3;
    
  } else if ( mapHor == 512 ) {

      // Right
      // NeoPixels Magenta
      zz = 4;
      isNUMPIXELS();
      iVer = 4;
 
  } else {

    // Stop
    // NeoPixels Red
    zz = 2;
    isNUMPIXELS();
    iVer = 5;
    
  }

  // XBee Car
  switch ( iVer ) {
    case 1:

      // 2 x EasyDriver - Up
      // Set the direction LOW
      digitalWrite(dirPinR, LOW);
      delay(5);
      digitalWrite(dirPinL, LOW);
      delay(5);

      break;
    case 2:

      // Stepper 2 - Back
      // Set the direction HIGH
      digitalWrite(dirPinR, HIGH);
      delay(5);
      digitalWrite(dirPinL, HIGH);
      delay(5);

      break;
    case 3:

      // Stepper 3 - Right
      digitalWrite(dirPinR, LOW);
      delay(5);
      digitalWrite(dirPinL, HIGH);
      delay(5);

      break;
    case 4:

      // Stepper 4 - Left
      digitalWrite(dirPinR, HIGH);
      delay(5);
      digitalWrite(dirPinL, LOW);
      delay(5);
      break;
    case 5:

      // Stop
      // NeoPixels Red
      zz = 2;
      isNUMPIXELS();
      iVer = 5;
      break;
    default:
    
      // Stop
      // NeoPixels Red
      zz = 2;
      isNUMPIXELS();
      iVer = 5;
      
  }

  if ( iVer == 5 ) {

    // Stepper Stop
    // 2 x EasyDriver
    // Set the direction
    digitalWrite(dirPinR, LOW);
    delay(5);
    // Set the direction
    digitalWrite(dirPinL, LOW);
    delay(5);
    // This LOW
    digitalWrite(stepPinR, LOW);
    digitalWrite(stepPinL, LOW);
    
  } else {

     // Iterate for 200 microsteps
     for (i = 0; i<200; i++)
     { 

        // This LOW to HIGH change is what creates the
        digitalWrite(stepPinR, LOW);
        // "Rising Edge" so the easydriver knows to when to step.
        digitalWrite(stepPinR, HIGH);
        // This delay time is close to top speed.
        delayMicroseconds(iPower);
        // This LOW to HIGH change is what creates the
        digitalWrite(stepPinL, LOW);
        // "Rising Edge" so the easydriver knows to when to step.
        digitalWrite(stepPinL, HIGH);
        // This delay time is close to top speed.
        delayMicroseconds(iPower);

     }
    
  }
 
}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial1.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // 2 x EasyDriver
  isStepperSetup();

  // Pause
  delay(5);
  
  // NeoPixels
  // This initializes the NeoPixel library
  pixels.begin();
  // Delay for a period of time (in milliseconds)
  delay(50);
  // isNUMPIXELS Off
  isNUMPIXELSoff();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – Vertical – Mk15

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #XBee #Stepper #EasyDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Vertical

——

Vertical

——

Vertical

——

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. A joystick, also known as the control column, is the principal control device in the cockpit of many civilian and military aircraft, either as a centre stick or side-stick. It often has supplementary switches to control various aspects of the aircraft’s flight.

Pololu Adjustable Step-Up Voltage Regulator U1V11A

This compact U1V11A switching step-up voltage regulator efficiently boosts input voltages as low as 0.5 V to an adjustable output voltage between 2 V and 5.25 V. Unlike most boost regulators, the U1V11A offers a true shutdown option that turns off power to the load, and it automatically switches to a linear down-regulation mode when the input voltage exceeds the output.

DL2112Mk05

2 x Fio v3 – ATmega32U4
2 x XBee S1
2 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x LED Green
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2112Mk05t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - XBee S1 - Transmitter - Mk15
12-05
DL2112Mk05t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 50;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-15t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Fio v3 – ATmega32U4 – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
DR0 – Digital 2
ST0 – Digital 3
DR1 – Digital 4
ST1 – Digital 5
LED – Digital 6
VIN – +3.3V
GND – GND

——

DL2112Mk05r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Vertical - Mk15
12-05
DL2112Mk04r.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x LED Green
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// LED Green
int iLEDGreen = 6;

// 2 x EasyDriver - 2 x Stepper
// EasyDriver Right
int dirPinR = 2;
// stepPin Right
int stepPinR = 3;
// EasyDriver Left
int dirPinL = 4;
// stepPin Left
int stepPinL = 5;
// Microsteps
int i = 0;
// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-15r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial1.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial1.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {
        
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        msg = msg + char(incb);
        in++;
        //Serial.println( msg );

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isStepper => msg
      isStepper();
      
      digitalWrite(iLEDGreen, HIGH);
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getStepper.ino

// Stepper
// isStepperSetup
void isStepperSetup() {

  // 2 x EasyDriver
  pinMode(dirPinR, OUTPUT);
  pinMode(stepPinR, OUTPUT);
  pinMode(dirPinL, OUTPUT);
  pinMode(stepPinL, OUTPUT);

}
// isStepper
void isStepper() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // EasyDriver Right
  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  
  // Vertical
  if ( mapVer <= 12 ) {

    // Set the direction HIGH
    digitalWrite(dirPinR, HIGH);
    delay(5);
    digitalWrite(dirPinL, HIGH);
    delay(5);
    
  } else {

    // Set the direction LOW
    digitalWrite(dirPinR, LOW);
    delay(5);
    digitalWrite(dirPinL, LOW);
    delay(5);
    
  }

  // Iterate for 200 microsteps
  for (i = 0; i<200; i++)
  { 

     // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, LOW);
     // "Rising Edge" so the easydriver knows to when to step.
     digitalWrite(stepPinR, HIGH);
     // This delay time is close to top speed.
     delayMicroseconds(iPower);
     // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, LOW);
     // "Rising Edge" so the easydriver knows to when to step.
     digitalWrite(stepPinL, HIGH);
     // This delay time is close to top speed.
     delayMicroseconds(iPower);

 }
   
}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial1.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // 2 x EasyDriver
  isStepperSetup();

  // Pause
  delay(5);
  
  // LED Green
  pinMode(iLEDGreen, OUTPUT);
  digitalWrite(iLEDGreen, LOW);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #12: Robotics – Transmitter and Receiver – Mk14

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #XBee #XBeeS1 #Transmitter #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Transmitter and Receiver

——

Transmitter and Receiver

——

Transmitter and Receiver

——

Serial

Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port, and some have several. Fio v3 ATmega32U4 board, Serial1 pins, 0(RX), 1(TX). On Fio v3 ATmega32U4, pins 0 and 1 are used for communication with the computer. Connecting anything to these pins can interfere with that communication, including causing failed uploads to the board. You can use the Arduino environment’s built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to begin(). Serial communication on pins TX/RX uses TTL logic levels 3.3V . Don’t connect these pins directly to an RS232 serial port, they operate at +/- 12V and can damage your Arduino board.

DL2112Mk04

2 x Fio v3 – ATmega32U4
2 x XBee S1
2 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x LED Green
1 x Half-Size Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

DL2112Mk04t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - XBee S1 - Transmitter - Mk14
12-04
DL2112Mk04t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 50;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-14t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Fio v3 – ATmega32U4 – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
LED – Digital 6
VIN – +3.3V
GND – GND

DL2112Mk04r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Receiver - Mk14
12-04
DL2112Mk04r.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x LED Green
1 x Half-Size Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// LED Green
int iLEDGreen = 6;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-14r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {
   
  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial1.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial1.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {
        
        bStart = true;
        in = 0;
        msg = "";
        // Done reading
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        msg = msg + char(incb);
        in++;

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {
    
      digitalWrite(iLEDGreen, HIGH);
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      
   }

}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial1.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // LED Green
  pinMode(iLEDGreen, OUTPUT);
  digitalWrite(iLEDGreen, LOW);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #20: CircuitPython – Audio Out WAV – Mk02

——

#DonLucElectronics #DonLuc #METROM0Express #CircuitPython #Sound #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Audio Out WAV

——

Audio Out WAV

——

Audio Out WAV

——

Play a Wave File

You can use any supported wave file you like. CircuitPython supports mono or stereo, at 22 KHz sample rate, or less, and 16-bit WAV format. The METRO M0 Express boards support only mono. The reason for mono is that there’s only one analog output on those boards. The 22 KHz or less because the CircuitPython can’t handle more data than that, and also it will not sound much better, and the DAC output is 10-bit so anything over 16-bit will just take up room without better quality. Since the WAV file must fit on the CircuitPython file system, it must be under 2 MB.

HamletUMk01.wav -> 1316 KB

We’re going to play the wave file for 10 seconds, pause it, wait for a button to be pressed, and then resume the file to play through to the end. Then it loops back to the beginning and starts again. First we create the button object, assign it to pin A1, and set it as an input with a pull-up.

Now we will ask the audio playback system to load the wave data from the file HamletUMk01.wav and finally request that the audio is played through the A0 analog output pin. The audio file is now ready to go, and can be played at any time with play. Inside our loop, we start by playing the file.

DL2112Mk02

1 x Adafruit METRO M0 Express
1 x SparkFun Audio Jack Breakout
1 x Audio Jack 3.5mm
1 x Hamburger Mini Speaker
1 x Tactile Button
1 x 10K potentiometer
1 x Knob
1 x 100uF 16V Electrolytic Capacitors
1 x SparkFun Cerberus USB Cable

Adafruit METRO M0 Express

AUD – Analog A0
BUT – Analog A1
VIN – +3.3V
VIN – +5V
GND – GND

code.py

"""
***** Don Luc Electronics © *****
Software Version Information
Project #20: CircuitPython – Audio Out WAV – Mk02
12-02
DL2112Mk02
code.py
1 x Adafruit METRO M0 Express
1 x SparkFun Audio Jack Breakout
1 x Audio Jack 3.5mm
1 x Hamburger Mini Speaker
1 x Tactile Button
1 x 10K potentiometer
1 x Knob
1 x 100uF 16V Electrolytic Capacitors
1 x SparkFun Cerberus USB Cable
"""
# Module
import time
import board
import digitalio
# audiocore -> WaveFile
from audiocore import WaveFile

try:
    from audioio import AudioOut
except ImportError:
    try:
        from audiopwmio import PWMAudioOut as AudioOut
    except ImportError:
        # Not always supported by every board.
        pass  

# Button A1
button = digitalio.DigitalInOut(board.A1)
button.switch_to_input(pull=digitalio.Pull.UP)

# William Shakespeare - Hamlet
wave_file = open("HamletUMk01.wav", "rb")
wave = WaveFile(wave_file)
# audio -> A0
audio = AudioOut(board.A0)

while True:
    # Play
    audio.play(wave)

    # This allows you to do other things while the audio plays.
    t = time.monotonic()
    # -> 10 second
    while time.monotonic() - t < 10:
        pass

    audio.pause()
    print("Waiting for button press to continue.")
    while button.value:
        pass
    # Resume    
    audio.resume()
    while audio.playing:
        pass
    # Done    
    print("Done")

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc...)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc...)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc...)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc...)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc...)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc...)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc...)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc...)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae - 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Categories
Archives