Menu
Microbots
0
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • ProtoBot
    • Modules & Parts
    • Tools & Gears
    • Coming Soon
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Sign in
  • English
  • Your Cart is Empty
Microbots
  • Learn
    • Getting Started
    • Maker Builds
    • Education
  • Shop
    • ProtoBot
    • Modules & Parts
    • Tools & Gears
    • Coming Soon
  • About
    • Our Story
    • Reach Out
    • FAQs
  • Language

  • 0 0

CoilCell - Controlling Magnetic Polarity

In this guide, we’ll focus on controlling the CoilCell's polarity and magnetic field strength, making it ideal for applications like flip-dot mechanical pixel and other magnetic pixels.

How It Works

CoilCell operates by passing current through its coil, generating a magnetic field whose polarity depends on the current direction. Since CoilCell has an integrated H-bridge, it can directly control the coil’s polarity and strength without requiring an external driver, like DriveCell.

Instead of simply turning the coil on or off, we’ll use Pulse Width Modulation (PWM) to finely adjust the magnetic strength and flip polarity as needed.

Flipping Polarity and Adjusting Strength

Several factors affect polarity control and field strength:

  • Voltage Level – Maximum voltage is 5V, providing the highest magnetic force.
  • PWM Frequency – A frequency of 20kHz is recommended to avoid audible noise.
  • Load Conditions – The coil’s performance depends on magnet size and grade strength.

Remember CoilCell is available in two configurations:

  • 1W CoilCell: Made from a 1.3mm thin, 4-layer PCB with a 70 turns spiral coil, with a peak magnetic field of 2.3 mT. 
  • 2.5W CoilCell: Made from a 2.6mm thin, 14-layer PCB with a 200 turns spiral coil, with a peak magnetic field of 10 mT, which can be increased to 17 mT using an iron back-plate.

Using CoilCell for Polarity Control

If you're using the CoilCell library, the following example demonstrates how to flip polarity and adjust strength:

#include <CoilCell.h>

#define COIL_PIN1 2
#define COIL_PIN2 3
CoilCell myCoilCell(COIL_PIN1, COIL_PIN2);

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

void loop() {
  myCoilCell.Drive(true, 100); // Strong north pole field
  delay(3000);
  
  myCoilCell.Drive(false, 100); // Strong south pole field
  delay(3000);
  
  myCoilCell.Drive(true, 50); // Weaker north pole field
  delay(3000);
  
  myCoilCell.Drive(false, 50); // Weaker south pole field
  delay(3000);
}

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

Understanding the Functions:

  • Init() → Initializes CoilCell and sets up the control pins.
  • Drive(bool direction, uint8_t power_percent)
    • direction: true (north pole) / false (south pole)
    • power_percent: Magnetic force strength (0 to 100%)

Flipping Polarity

By alternating polarity, CoilCell can be used to flip magnetic elements, such a flipdot pixel combined with a magnet. To smooth this out, we can use Pulse Width Modulation (PWM) on both outputs. This method gradually changes the magnetic field intensity, reducing mechanical stress on the CoilCell.

This function is automatically handled within our CoilCell library:

#include <coilcell.h>

#define COIL_PIN1 2
#define COIL_PIN2 3

CoilCell myCoilCell(COIL_PIN1, COIL_PIN2);

uint16_t vibration_counter = 0;

void setup() {
  myCoilCell.Init();
  myCoilCell.Tone();
}

void loop() {
    myCoilCell.Vibrate(1, 75, 1000); // Flip at 75% power every 1sec
}

Understanding the Functions:

  • Init() → Initializes CoilCell and sets up the input pins.
  • Vibrate(smooth, power, speed_ms) → Oscillates the CoilCell in either a square wave or a smoother PWM wave.
    • smooth → 1 (PWM wave) / 0 (square wave)
    • power → Magnetic-field strength (0 to 100%)
    • speed_ms → Vibration speed in milliseconds

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

Conclusion

With these techniques, you can start controlling CoilCell's magnetic polarity. Check out the CoilCell GitHub Repository for more code examples and technical documentation!

  • Share:

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!

© 2026 Microbots.

★ Reviews

Let customers speak for us

68 reviews
Write a review
84%
(57)
6%
(4)
3%
(2)
3%
(2)
4%
(3)
63
21
C
CodeCell C3
Cloke74

Great piece of kit, had just what i needed to complete the project i had in mind. Shame shipping to the UK is so expensive, but appreciate this isn’t necessarily in the hands of MicroBots

A
CodeCell C6
Anonymous

I had an issue, got a red light, I used too much flux. Support said clean it, then the one sensor worked fine. I got the help and answer same day I provided a foto.

A
CodeCell C6 Drive
Anonymous

I think this is the best of the ESP offered, most versatile.

User picture
P
CodeCell C6
Prudhvi tej Chinimilli

Been testing the Microbots CodeCell C6 and honestly impressed with how much functionality they packed into such a tiny module. Great form factor for rapid prototyping wearable/embedded sensing applications. ESP32-C6 + IMU integration makes development much easier compared to building everything from scratch.

Still exploring battery optimization and compact LiPo options for our use case, but overall the platform is promising for low-cost real-time sensing systems. Excited to keep building with it.

F
CodeCell C6
Francisco Estivallet

Amazing hardware, my go to for compact projects.

User picture
123