Menu
Microbots
0
  • Learn
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
    • All Products
  • Community
    • Education
    • Software
  • About
    • Our Story
    • Reach Out
    • FAQs
  • English
  • Your Cart is Empty
Microbots
  • Learn
  • Shop
    • Maker-Modules
    • Maker-Packs
    • Tools & Gears
    • Robots & Displays
    • All Products
  • Community
    • Education
    • Software
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

DriveCell

Using DriveCell to Control Buzzing

Using DriveCell to Control Buzzing

DriveCell isn’t just for driving motors and actuators—it can also make them generate sound and vibrations. By sending a signal through the audible frequency range, DriveCell can create different tones that can be played on devices like piezo buzzers, CoilPads, FlatFlaps, and even motors. Making it useful for alert systems or interactive responses. In this guide, we’ll explore how DriveCell can generate buzzing tones, how to wire it, and how to use it for various applications, from piezo buzzers to CoilPad and motor vibrations.

How Buzzing Works with DriveCell

Buzzing is achieved by sending rapid electrical pulses to a device, causing it to oscillate within the audible frequency range (~20Hz–20kHz). DriveCell allows control over these pulses using PWM (Pulse Width Modulation), letting you generate tones, alerts and vibrations.

Wiring a Buzzer or Actuator to DriveCell

Basic Connection for a Buzzer or Actuator

Here’s how to wire a buzzer, CoilPad, or FlatFlap to DriveCell:

  1. Connect DriveCell Output Pins to the Device:
    • OUT1 → Device Positive (+)
    • OUT2 → Device Negative (-)
  2. Connect DriveCell Input Pins to the Microcontroller:
    • IN1 → Any digital pin
    • IN2 → Another digital pin
  3. Power Connections:
    • VCC → 5V maximum
    • GND → Common ground with the microcontroller

Controlling Buzzing with DriveCell Library

To generate buzzing tones, DriveCell provides Arduino-compatible functions for buzzing tones.

1. Installing the Library

  1. Open Arduino IDE
  2. Go to Library Manager
  3. Search for DriveCell and install it

2. Code Example for Generating a Buzzing 

The following example makes a buzzer, CoilPad, or FlatFlap buzz using DriveCell's library built-in function:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell myDriveCell(IN1_pin1, IN1_pin2);

void setup() {
  myDriveCell.Init(); /* Initialize DriveCell */
}

void loop() {
  myDriveCell.Buzz(100);  /* Buzz at 100 microseconds */
  delay(500);
  myDriveCell.Tone();  /* Play a fixed tone with varying frequencies */
  delay(500);
}

3. Understanding the Functions

  • Buzz(duration) → Generates a buzzing effect:
    • duration → Tone frequency in microseconds (adjust to change intensity)
  • Tone() → Plays a fixed tone built into the library

⚠ Note: Some sounds can also be played on DC motors, but check the datasheet and avoid running high-frequency buzzing on brushed motors continuously, as it may cause excessive wear.

Conclusion

The tiny DriveCell module makes buzzing simple! Check out the DriveCell GitHub Repository for more code examples and technical documentation!

Read More

Using DriveCell to Control High-Power LEDs

Using DriveCell to Control High-Power LEDs

High-power LEDs are widely used in lighting projects, from flashlights to light strips and signal indicators. Typically, a single transistor is used to switch or dim high-power LEDs, but DriveCell, a tiny H-Bridge module which is packaged into the smallest module, can provide an alternative while handling up to 1.8A of continuous current.

In this guide, we’ll explore how DriveCell can be used to control high-power LEDs or single-color LED strips, discuss wiring configurations, and demonstrate a fading effect using its library.

Why Use DriveCell for High-Power LEDs?

DriveCell is built around the DRV8837 H-Bridge which has four transistors in the shape of an 'H' to allow bi-directional current. You only require one transistor to dim the brightness of high-power LEDs - But if you're looking for a tiny solution DriveCell can handles up to 1.8A continuous current with an easy integration with microcontrollers.

DriveCell Specifications for High-Power LED Control

Before connecting your LED, it's essential to understand DriveCell’s electrical limitations:

  • Operating Voltage: 1.8V to 5V (suitable for LED applications)
  • Maximum Continuous Current: 1.8A (sufficient for most high-power LEDs or small LED strips)
  • Built-in Protections: Overcurrent, undervoltage lockout, and thermal shutdown

Note: When it comes to lighting, DriveCell is only ideal for controlling the brightness of single-color LED strips or individual high-power LEDs.

Wiring a High-Power LED to DriveCell

Basic Connection for One LED

Here’s how to wire a single LED or LED strip to DriveCell:

  1. Connect DriveCell Output Pins to the LED:
    • LED Positive (+) → OUT1
    • LED Negative (-) → Connect to Ground or OUT2 (while forcing it to ground with the input pin)
  2. Connect DriveCell Input Pins to the Microcontroller:
    • IN1 → Connect to your Microcontroller (any digital PWM-capable pin)
    • IN2 → Connect to your Microcontroller (any digital PWM-capable pin)
  3. Power Connections:
    • VCC → LED Voltage (e.g. 5V)
    • GND → Common ground with the Microcontroller

Controlling LED Brightness with DriveCell

To adjust LED brightness dynamically, DriveCell provides a software library. Below is an example of a fading effect.

1. Installing the Library

  1. Open Arduino IDE
  2. Go to Library Manager
  3. Search for DriveCell and install it

2. Code Example for LED Brightness Control

The following example demonstrates how to fade an LED in and out using DriveCell:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell LED(IN1_pin1, IN1_pin2); /* Pin2 will output the PWM signal, and Pin3 will be connected to 0V */

uint16_t led_brightness = 0;
bool led_brightness_flag = 1;

void setup() {
  LED.Init(); /* Initialize the LED */
}

void loop() {
  delay(10); /* Adjust this delay to change the fading speed */
  
  if (led_brightness_flag == 1) {
    if (led_brightness < 100U) {
      led_brightness++;
    } else {
      led_brightness_flag = 0;
    }
  } else {
    if (led_brightness > 1U) {
      led_brightness--;
    } else {
      led_brightness_flag = 1;
    }
  }
  
  LED.Drive(0, led_brightness); /* Output the new brightness level */
}

3. Understanding the Code

  • Init() → Initializes DriveCell and sets up the input pins
  • Drive(direction, brightness) → Controls LED brightness:
    • direction → 0 (fixed polarity for LEDs)
    • brightness → Dimming level (0 to 100%)

This code gradually increases and decreases the brightness of the LED, creating a smooth fading effect.

⚠ Note: The Drive() function is only compatible with ESP32 and CodeCell, as it uses a high-speed PWM timer.

Below is another example that can be used with other microcontrollers like the Arduino Uno:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell myLED(IN1_pin1, IN1_pin2);

void setup() {
  myLED.Init();
}

void loop() {
    myLED.Run(1000); // Blink LED on and off every 1 second
}

This example simply turns the LED on and off every second.

Conclusion

The tiny DriveCell module makes high-power LED control simple and easy to use! Check out the DriveCell GitHub Repository for more code examples and technical documentation!

Read More

Using DriveCell to Control Magnetic Actuators

Using DriveCell to Control Magnetic Actuators

Magnetic actuators, like the CoilPad and FlatFlap, use planar PCB coils to generate a small magnetic field to interact with magnets, converting electrical into mechanical energy. DriveCell is perfect for driving these actuators, because of its small size and easy to use library.

Understanding Magnetic Actuators & Why They Need DriveCell

What Are Magnetic Actuators?

Magnetic actuators work by passing current through a coil, which creates a magnetic field that interacts with nearby magnets. This allows them to vibrate or oscillate.

Unlike traditional DC motors, magnetic actuators require rapid polarity switching and precise control to function effectively, which is why H-Bridge drivers like DriveCell are required.

Why Use an H-Bridge Driver Like DriveCell?

Since magnetic actuators rely on alternating current directions, a standard transistor circuit won’t be enough. The DRV8837 H-Bridge in DriveCell allows current to flow in both directions, enabling full control over the polarity and intensity of the magnetic field.

DriveCell Specifications for Magnetic Actuators

Before connecting your actuators, it's essential to understand DriveCell’s electrical limitations:

  • Operating Voltage: 1.8V to 5V 
  • Maximum Continuous Current: 1.8A 
  • H-Bridge Chip: DRV8837, allowing polarity switching & PWM control
  • Built-in Protections: Overcurrent, undervoltage lockout, and thermal shutdown

Note: Both the CoilPad and the FlatFlap consume around 200mA - this means you can connect up 8 actuators in parallel, driving them using a single DriveCell.

Wiring a Magnetic Actuator to DriveCell

Basic Connection for One Actuator

Here’s how to solder/wire a single CoilPad or FlatFlap actuator to DriveCell:

  1. Connect DriveCell Output Pins to the Actuator:
    • OUT1 → Actuator Terminal 1
    • OUT2 → Actuator Terminal 2
  2. Connect DriveCell Input Pins to the Microcontroller:
    • IN1 → Any digital PWM-capable pin
    • IN2 → Another digital PWM-capable pin
  3. Power Connections:
    • VCC → 5V (or up to 11V based on your actuator requirements)
    • GND → Common ground with the microcontroller

Parallel Connection for Multiple Actuators

You can connect multiple actuators in parallel:

  • OUT1 → Both Actuator 1 and Actuator 2 terminal-1
  • OUT2 → Both Actuator 1 and Actuator 2 terminal-2

This setup will drive both actuators in sync, making them activate simultaneously.

Controlling Magnetic Actuators with DriveCell Library

To simplify actuator control, DriveCell provides a software library. Below are the key functions you’ll need:

1. Installing the Library

  1. Open Arduino IDE
  2. Go to Library Manager
  3. Search for DriveCell and install it

2. Code Example

The following example demonstrates how to control two actuators with different intensities:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell Actuator1(IN1_pin1, IN1_pin2);
DriveCell Actuator2(IN2_pin1, IN2_pin2);

void setup() {
  Actuator1.Init();
  Actuator2.Init();
}

void loop() {
  delay(3000);
      Actuator1.Drive(1, 40); // Activate Actuator1 North-Polarity at 40% power
      Actuator2.Drive(1, 80); // Activate Actuator2 North-Polarity at 80% power
  delay(3000);
      Actuator1.Drive(0, 50); // Activate Actuator1 South-Polarity at 50% power
      Actuator2.Drive(1, 50); // Activate Actuator2 North-Polarity at 50% power
  delay(3000);
      Actuator1.Drive(0, 0); // Deactivate Actuator1
      Actuator2.Drive(0, 100); // Activate Actuator2 South-Polarity at 100% power
}

Understanding the Functions:

  • Init() → Initializes DriveCell and sets up the input pins
  • Drive(direction, power) → Controls actuator:
    • direction → 1 (north) / 0 (south)
    • power → Magnetic-field strength (0 to 100%)

Here's another example where we configure two FlatFlaps and flap them at different speeds:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell FlatFlap1(IN1_pin1, IN1_pin2);
DriveCell FlatFlap2(IN2_pin1, IN2_pin2);

uint16_t flap_counter = 0;

void setup() {
  FlatFlap1.Init();
  FlatFlap2.Init();

  FlatFlap1.Tone();
  FlatFlap2.Tone();
}

void loop() {
  delay(1);
  flap_counter++;
  if (flap_counter < 2000U) {
    FlatFlap1.Run(0, 100, 100);
    FlatFlap2.Run(0, 100, 100);
  }
  else if (flap_counter < 8000U) {
    FlatFlap1.Run(1, 100, 1000);
    FlatFlap2.Run(1, 100, 1000);
  } else {
    flap_counter = 0U;
    FlatFlap1.Drive(0, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(0, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Drive(0, 100);
    FlatFlap2.Drive(0, 100);
    delay(500);
    FlatFlap1.Drive(1, 100);
    FlatFlap2.Drive(1, 100);
    delay(500);
    FlatFlap1.Tone();
    FlatFlap2.Tone();
  }
}

Understanding the Functions:

  • Run(smooth, power, speed_ms) → Oscillate the FlatFlap in either a square wave or a smoother PWM wave.
    • smooth → 1 (pwm wave) / 0 (square wave)
    • power → Magnetic-field strength (0 to 100%)
    • power → Flipping speed in milliseconds

⚠ Note: The Run() & Drive() function uses a high-speed PWM timer, making it compatible only with CodeCell and ESP32-based devices.

Below is another example that can be used with other microcontrollers like the Arduino Uno:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell myActuator(IN1_pin1, IN1_pin2);

void setup() {
  myActuator.Init();
}

void loop() {
    myActuator.Run(1000); // Activate actuator for 1 second, then reverse
}

This example activates the actuator in North-polarity for 1 second before reversing polarity, creating an oscillating square wave movement.

Conclusion

The tiny DriveCell module makes magnetic-actuator control simple and easy to use! Check out the DriveCell GitHub Repository for more code examples and technical documentation!

Read More

Using DriveCell to Control DC Motors

Using DriveCell to Control DC Motors

When working with brushed DC motors, controlling their speed and direction is key to building functional robotics, automation systems, and interactive projects. DriveCell is a tiny compact motor driver based on the DRV8837 H-Bridge, simplifies this process by providing an easy-to-use library. In this guide, we'll explore how DriveCell works, how to control a DC motor, and how to connect multiple motors efficiently.

Understanding Brushed DC Motors & Why They Need a DriveCell

A brushed DC motor is a simple type of electric motor where current flows through a set of brushes and a commutator to create rotational motion. It operates based on the principle of electromagnetic induction, which generates a magnetic field inside the motor, pushing it into continuous rotation.

Unlike servo motors or stepper motors, brushed DC motors require two input signals to control their movement:

  • Direction control by reversing the current flow
  • Speed control via PWM (Pulse Width Modulation)

This is where H-Bridge drivers like the DRV8837 in DriveCell come into play. The H-Bridge circuit allows current to flow in both directions, enabling bidirectional motor control with just two input pins.

DriveCell Specifications

Before connecting your motors, it's essential to understand the DriveCell's electrical limitations:

  • Operating Voltage: 1.8V to 5V (suitable for small motors)
  • Maximum Continuous Current: 1.8A
  • H-Bridge Chip: DRV8837, handling motor direction & speed
  • Built-in Protections: Overcurrent, undervoltage lockout, and thermal shutdown

If your motor requires less than 0.5A, you can also connect two motors in parallel and drive them using a single DriveCell.

Wiring a DC Motor to DriveCell

Basic Connection for One Motor

Here’s how to wire a single DC motor to DriveCell:

  1. Connect DriveCell Output Pins to the Motor:
    • OUT1 → Motor Terminal 1
    • OUT2 → Motor Terminal 2
  2. Connect DriveCell Input Pins to the Microcontroller:
    • IN1 → Any digital PWM-capable pin
    • IN2 → Another digital PWM-capable pin 
  3. Power Connections:
    • VCC → 5V or less
    • GND → Common ground with the microcontroller

Parallel Connection for Two Motors

If your motors consume less than 500mA each, you can connect two motors in parallel:

  • OUT1 → Both Motor 1 and Motor 2 terminals
  • OUT2 → Both Motor 1 and Motor 2 terminals

This setup will drive both motors synchronously, making them spin in the same direction at the same speed.

 

Controlling the Motor with DriveCell Library

To make motor control simple, DriveCell provides an software library. Below are the key functions you’ll need:

1. Installing the Library

  1. Open Arduino IDE
  2. Go to Library Manager
  3. Search for DriveCell and install it

2. Code Example

The following example demonstrates how to control two motors at different speeds:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6

DriveCell Motor1(IN1_pin1, IN1_pin2);
DriveCell Motor2(IN2_pin1, IN2_pin2);

void setup() {
  Motor1.Init();
  Motor2.Init();
}

void loop() {
  delay(3000);   
      Motor1.Drive(1, 40); // Move Forward at 40% speed
      Motor2.Drive(1, 80); // Move Forward at 80% speed
  delay(3000);   
      Motor1.Drive(0, 50); // Move Backward at 50% speed
      Motor2.Drive(0, 50); // Move Backward at 50% speed
  delay(3000);   
      Motor1.Drive(0, 0); // Set to 0% speed
      Motor2.Drive(0, 100); // Move Backward at 100% speed 
}

⚠ Note: The Drive() function in this example uses a high-speed PWM timer, making it compatible only with CodeCell and other ESP32-based devices.

Below is another example that can be used with other microcontrollers like the Arduino Uno:

#include <DriveCell.h>

#define IN1_pin1 2
#define IN1_pin2 3

DriveCell myDriveCell(IN1_pin1, IN1_pin2);

void setup() {
  myDriveCell.Init();
}

void loop() {
    myDriveCell.Run(1000); // Run motor forward for 1 second, then reverse
}

This example will spin the motor in one direction for 1 second and then reverse its direction, creating a simple oscillating motion.

Conclusion

The tiny DriveCell module makes DC motor control simple and easy to use! Check out the DriveCell GitHub Repository for more code examples and technical documentation!

Read More

Understanding DriveCell Circuitry

Understanding DriveCell Circuitry

When working with small electronics projects that involve motors or actuators, controlling speed and direction can be a challenge. This is where DriveCell steps in. Packed into a fingertip-sized module, DriveCell simplifies motor control by utilizing a tiny H-Bridge chip, the DRV8837, making it an ideal solution for robotics, actuators, and even LED control. In this post, we’ll dive into the circuitry behind DriveCell and how it works.

The Heart of DriveCell: DRV8837 H-Bridge

At the core of DriveCell is the DRV8837 chip, an H-Bridge driver designed to handle low-power DC motors and actuators. An H-Bridge is a circuit configuration composed of four transistors arranged in an "H" shape, allowing for bidirectional control of a motor by reversing the current flow. The DRV8837 integrates this functionality into a compact form, offering:

  • Motor Speed & Direction Control via two input pins
  • PWM (Pulse Width Modulation) Support for fine-tuned control
  • Overcurrent Protection, Undervoltage Lockout, and Thermal Shutdown for safety
  • Maximum continuous output current of 1.8A, making it suitable for powering small but powerful dc motors or for powering multiple in parallel actuators like the CoilPad

Although the DRV8837 simplifies motor control, the DriveCell module takes it a step further by providing an easy-to-use software library that abstracts complex programming, making motor control accessible even to beginners.

Understanding DriveCell's Pinout & Functionality

The DriveCell module operates based on the state of its two input pins (IN1 and IN2) to control current flow through its output pins: 

  • Forward Current: IN1 = VCC/PWM, IN2 = GND → Motor spins forward
  • Reverse Current: IN1 = GND, IN2 = VCC/PWM → Motor spins in reverse
  • Off State: IN1 = GND, IN2 = GND → Motor stops

For added clarity, an onboard LED provides visual feedback, indicating the direction of the output.

Why Choose DriveCell?

DriveCell is designed to be compact, efficient, and easy to integrate into various projects. Here’s why it stands out:

  • Ultra-compact size – about the size of a fingertip
  • Castellated pins for easy soldering and integration into custom PCBs
  • Seamless compatibility with Arduino, CodeCell, and other microcontrollers
  • No need for complex H-Bridge configurations – just a simple function call

Getting Started with DriveCell

To start using DriveCell, follow these steps:

1. Wiring DriveCell to Your Circuit

Solder the output pins to your motor or actuator and the input/power pins to your microcontroller. The input pins determine the state of the output pins:

    • Setting IN1 high makes OUT1 high

    • Setting IN2 high makes OUT2 high
    • Typically, IN1 and IN2 are set in opposite polarities to allow current to flow through the motor

The VCC must be connected to a maximum supply voltage of 5V. 

2. Coding with the DriveCell Library

While wiring one of the input pins to VCC will instantly activate DriveCell, we recommend using the DriveCell Library for automatic control. This library makes DriveCell highly flexible and programmable.

Steps to Install the Library:

  1. Open Arduino IDE
  2. Go to Library Manager and search for “DriveCell”
  3. Click Install
  4. Load the example sketches to start experimenting!

3. Keeping things tiny

Use our CodeCell module which is designed to be pin-to-pin compatible with DriveCell. With CodeCell, you can add wireless control and interactive sensing, unlocking new possibilities for your projects.

Conclusion

DriveCell simplifies the complexities of motor control with a compact design. Whether you’re building a tiny robot or a magnetic actuator, DriveCell provides an easy way to get started.

Check out the DriveCell Schematics here to explore its circuit design in detail and start integrating it into your next project!

Read More

DriveCell Basics: Your First Steps

DriveCell Basics: Your First Steps

DriveCell is a tiny but powerful device that helps you easily control motors, actuators, and high-power LED lights for your DIY projects. DriveCell makes controlling these components easy, even if you're new to programming or electronics. 

In this tutorial we will explain:

  • What is a DriveCell and how does it work?
  • Getting started with its Arduino software library
  • Control two dc-motors and drive them at different speed
  • Make the DriveCell more interactive with the CodeCell sensors

What is DriveCell?
Imagine you want to make a small robot and control its motor's speed and direction. This can be complex for beginners and usually would require bulky modules. DriveCell simplifies this process because:

  • It’s a super small driver (just about the size of your fingertip)
  • Can be easily soldered with castellated pins
  • Works with Arduino microcontrollers and has easy to use functions that directly let you control motors, actuators, and LEDs without diving into complicated programming.

How Does DriveCell Work?
DriveCell utilizes an on-board DRV8837 H-bridge chip to control current flow through the output pins, controlled by the state of the input pins:

  • Forward Current: IN1 = VCC/PWM, IN2 = GND
  • Reverse Current: IN1 = GND, IN2 = VCC/PWM
  • Off: IN1 = GND, IN2 = GND

The DRV8837 chip provides overcurrent protection, undervoltage lockout, and thermal shutdown features, ensuring safe operation.

    Getting Started with DriveCell
    Before you can start using DriveCell, you need to set it up and connect it to your project. Here’s a simple guide to get you started:

    • Connecting DriveCell: 
    First, solder the DriveCell output pins to your motor or actuator, and the input and power pins to your microcontroller. Think of these pins like connecting the pieces of a puzzle, allowing the DriveCell to pass current between the output pins.These output pins are controlled by the state of the input pin ~ so pulling IN1 high, will set OUT1 high, and pulling IN2 high, will set OUT2 high. IN1 and IN2 are usually set in opposite polarities to allow current to pass through. These technical details can be all handled by the DriveCell software library.

    • Coding DriveCell: 
    Wiring one of the input-pins to VCC will instantly turn on the DriveCell. But to make it smarter we also developed a Arduino Software Library to make it easier for you to get started. You will need to write some basic code to tell DriveCell what to do. Don’t worry, it’s quite simple! Start by downloading the "DriveCell" library from the Arduino's Library Manager. Once this is installed, we are ready to control your device. There are multiple examples that can help you get started but next we will breakdown and understand all the functions.
    Before we start make sure you connect the DriveCell to your microcontroller. We recommend using a CodeCell which is pin to pin compatible, supports all the library functions, and can add wireless control + interactive sensing. 

     


    1. Init()

    First we need a basic setup code to get you started:

    #include <DriveCell.h> // This line includes the DriveCell library
    
    DriveCell myDriveCell(IN1, IN2); // Replace IN1 and IN2 with your specific pins
    
    void setup() {
        myDriveCell.Init(); // Initializes the DriveCell
    }
    

    This code tells the DriveCell to start up and get ready to control your motor or actuator. The Init function makes sure all the necessary peripherals are configured.

    2. Pulse(bool direction, uint8_t ms_duration)

    This command sends a short burst of power in a specified polarity, to quickly energize the actuator and turn it back off. 

    myDriveCell.Pulse(true, 10); // Short burst for 10 milliseconds
    

    3. Buzz(uint16_t us_buzz) 
    This makes the actuator vibrate like a buzzer. It’s great for creating sounds for feedback.

    myDriveCell.Buzz(100); // Creates a 100us buzzing sound

    4. Tone()
    This function plays a default tone by making the actuator vibrate at different saved frequencies.

    myDriveCell.Tone(); // Plays varying tones
    

    5. Toggle(uint8_t power_percent)
    This function simply switches the direction at the full 100% power, which can be useful for reversing the spinning direction of a brushed motor or creating simple flapping movements.

    myDriveCell.Toggle(); // Switches direction

    By using the CodeCell or any other ESP32 microcontroller, you can also adjust the duty cycle 'power_percent'. For magnetic actuators the 'power_percent' controls the magnetic strength, while for brushed motors this adjusts the speed. 

    6. Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)

    By using the CodeCell or any other ESP32 microcontroller, this function lets you flip the polarity of an actuator or reverse a motor every 'flip_speed_ms' at the duty cycle 'power_percent'. Setting 'smooth' to 1, smooths out the motion, which is ideal when driving the FlatFlap or CoilPad with slow motions (less than 2Hz).

    myDriveCell.Run(true, 50, 1000); // Smooth drive at 50% power every 1000 ms

    For other Arduino devices, this command makes the motor/actuator flip its direction (forward and backward) at full speed. For example:

    myDriveCell.Run(500); // Motor changes direction every 500 milliseconds
    

    7. Drive(bool direction, uint8_t power_percent)
    By using the CodeCell or any other ESP32 microcontroller, this function lets you control the speed and direction of your motor. You can make the motor go forward or backward and adjust how fast it goes.

    myDriveCell.Drive(true, 75); // Moves forward at 75% power


    Examples:

    By using any of these functions in a loop, you can create the desired sequence for your motor, actuator, or high-power LEDs. Here's an example where we initialize two dc-motors and drive them at different speeds:

    #include <DriveCell.h>
    
    #define IN1_pin1 2
    #define IN1_pin2 3
    #define IN2_pin1 5
    #define IN2_pin2 6
    
    DriveCell Motor1(IN1_pin1, IN1_pin2);
    DriveCell Motor2(IN2_pin1, IN2_pin2);
    
    uint8_t mode = 0;
    uint8_t speed_percentage = 0;
    
    void setup() {
      Motor1.Init();
      Motor2.Init();
      speed_percentage = 80; /* Set Motor to 80% power */
    }
    
    void loop() {
      delay(3000);
      mode++;
      switch (mode) {
        case 1:
          /* Move forward */
          Motor1.Drive(1, speed_percentage);
          Motor2.Drive(1, speed_percentage);
          break;
        case 2:
          /* Move backward */
          Motor1.Drive(0, speed_percentage);
          Motor2.Drive(0, speed_percentage);
          break;
        case 3:
          /* Turn left */
          Motor1.Drive(1, speed_percentage);
          Motor2.Drive(0, speed_percentage);
          break;
        case 4:
          /* Turn right */
          Motor1.Drive(0, speed_percentage);
          Motor2.Drive(1, speed_percentage);
          break;
        case 5:
          /* Turn off both motors */
          Motor1.Drive(1, 0);
          Motor2.Drive(1, 0);
          if (speed_percentage < 95) {
            speed_percentage += 5; /* Increment speed */
          } else {
            speed_percentage = 50; /* Reset to 50% power */
          }
          mode = 0;
          break;
      }
    }
    

    In this next example we use the CodeCell's Proximity Sensor to activate the motors. This sensor will act as a gesture switch, and activate when a hand is within 5cm away. 

    #include <CodeCell.h>
    #include <DriveCell.h>
    
    #define IN1_pin1 2
    #define IN1_pin2 3
    #define IN2_pin1 5
    #define IN2_pin2 6
    
    CodeCell myCodeCell;
    DriveCell Motor1(IN1_pin1, IN1_pin2);
    DriveCell Motor2(IN2_pin1, IN2_pin2);
    
    uint8_t speed_percentage = 0;
    bool on_flag = 0;
    
    void setup() {
      Serial.begin(115200); /* Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial. */
    
      myCodeCell.Init(LIGHT); /*Initializes Light Sensing*/
      Motor1.Init();
      Motor2.Init();
      speed_percentage = 100;
    }
    
    void loop() {
      if (myCodeCell.Run()) {
        /*Runs  every 100ms - Put your code here*/
        if (myCodeCell.Light_ProximityRead() > 3000) {
          /*If Tap is detected shine the LED Yellow for 1 sec*/
          myCodeCell.LED(0XA0, 0x60, 0x00U);
          Motor1.Drive(0, 0);
          Motor2.Drive(0, 0);
          delay(1000);
          on_flag = !on_flag;
        }
        if (on_flag) {
          /*Move forward*/
          Motor1.Drive(1, speed_percentage);
          Motor2.Drive(1, speed_percentage);
        } else {
          Motor1.Drive(0, 0);
          Motor2.Drive(0, 0);
        }
      }
    }
    

    If you have any more question about the DriveCell feel free to email us and we will gladly help out!

    Read More


    Follow

    Github

    • About
    • Software
    • Education
    • Contact
    • FAQs
    • Terms
    • Refund Policy
    • Privacy Policy

    Join our Community ~ Be the first to know about new products and get exciting deals!

    © 2025 Microbots.