MotorCell is an ultra-compact, shaftless PCB motor designed for high-speed, low-torque applications. With its innovative pancake design and planar PCB windings, MotorCell is perfect for robotics, art installations, and DIY projects. This motor simplifies integration by using sensorless control with PWM speed adjustments.
In this tutorial, we’ll cover:
What is MotorCell?
The MotorCell reimagines motor design by integrating the rotor, stator and driver, into a single, flat PCB. This unique structure:
MotorCell is ideal for applications that require small, lightweight, compact motors, such as small robotics, kinetic art, or even portable gadgets.
Setting Up Your MotorCell
To get started, follow these steps:
Pins:
Open the Arduino IDE, go to Sketch > Include Library > Manage Libraries, search for "MotorCell," and install it. Then include it in your code and setup your pins:
#include "MotorCell.h"
#define IN_PIN 2
#define OUT_PIN 3
#define FR_PIN 1
MotorCell myMotorCell(IN_PIN, OUT_PIN, FR_PIN);
void setup() {
myMotorCell.Init(); // Initialize the MotorCell
}
MotorCell Library Functions
Here are the core functions of the MotorCell library:
myMotorCell.Init();
uint16_t rpm = myMotorCell.Spin(50); // Spin at 50% speed
uint16_t rpm = myMotorCell.SpinPID(12000); // Maintain 12,000 RPM
myMotorCell.ReverseSpin();
Pulse(uint8_t p_pin, uint8_t ms_duration): Sends a short pulse to the specified pin for a given duration (in milliseconds). Useful for quick bursts of motion or momentary signals.
myMotorCell.Pulse(FR_PIN, 50); // Sends a 50ms pulse to the FR_PIN
uint16_t currentRPM = myMotorCell.RPMRead();
myMotorCell.MaxSpin();
Example Project: RPM Monitoring
Here’s a simple project to get you started:
#include "MotorCell.h"
#define IN_PIN 2
#define OUT_PIN 3
#define FR_PIN 4
MotorCell myMotorCell(IN_PIN, OUT_PIN, FR_PIN);
void setup() {
Serial.begin(115200);
myMotorCell.Init();
}
void loop() {
uint16_t rpm = myMotorCell.Spin(50); // Spin at 50% speed
}
More examples available on github, but if you have any questions about MotorCell, feel free to contact us!
If you’ve just got your hands on the CodeCell, you're in for a treat. This tiny module is designed to simplify your DIY projects with multiple features packed into a penny-sized board. In this guide, we’ll walk you through:
CodeCell is a compact and versatile module featuring the ESP32-C3, multiple power options, and integrated sensors, all within a tiny 1.85 cm wide form factor. These features make it a powerful tool for a wide range of applications.
In this first section, we'll start by getting familiar with the circuitry that forms the CodeCell. After that, we'll walk through the simple steps to set up your CodeCell.
ESP32C3 Module
At the heart of the CodeCell is the ESP32C3 module, a compact microcontroller known for being maker-friendly in the IoT space. It combines an Arduino-compatible architecture with built-in Wi-Fi and Bluetooth Low Energy (BLE) capabilities. This integration offers the most popular connectivity options while maintaining a small form factor.
The ESP32C3 module's PCB antenna is positioned on one side, away from other components, to minimize interference and improve signal transmission and reception. This placement helps reduce the impact of ground planes or other conductive surfaces that could degrade antenna performance. The components on the bottom side are kept within the recommended clearance for the antenna. From testing we found that the antenna's performance remains unaffected by the minimal interference from a USB-C cable, as these cables are typically shielded.
The ESP32-C3 provides plenty of memory, with 4 MB of Flash and 400 KB of SRAM, making it capable of running most typical applications. Its 32-bit RISC-V single-core processor, running at up to 160 MHz, efficiently handles various tasks. This combination of memory and processing power makes the ESP32-C3 suitable for a wide range of uses.
The ESP32C3 module also supports a USB Serial/JTAG Controller, allowing us to make the CodeCell reflashable through the USB-C port and to send serial data for communication and debugging.
Power Management
The CodeCell offers flexibility in power supply options. It can be powered through the LiPo battery connector, a USB-C cable, or both.
The LiPo battery connector makes it easier than ever to safely connect the battery without the need for soldering or risking accidental shorting it.
The USB-C port serves dual purposes: it is used for both powering the device and/or reprogramming it. This multi-power option is enabled through the BQ24232 battery management chip, which features dynamic power-path management (DPPM) that can power the system while simultaneously and independently charging the battery. The battery charging process is managed in three phases: conditioning precharge, constant current, and constant voltage. To protect the battery the output voltage (Vo) is regulated though the BQ24232 chip. This output supports a maximum output current of 1500mA when powered by the LiPo battery and 450mA when powered via USB.
By default, the LiPo battery charge current is set to 90mA, ensuring a balanced and a safe charge rate for the optional 170mAh LiPo battery. Further more, for those who wish to adjust the charging rate, 0402 resistor R12 have to be de-soldered and replace it with a new resistor based on the formula (R = 870/Ichrg). This is only recommended for soldering pros, who aren’t afraid of wrestling with tiny 0402 components! Check the BQ24232 datasheet for more information on the battery charging.
The CodeCell library can provides visual feedback on the battery/usb power status via the onboard addressable RGB LED:
The power regulation is further supported by multiple decoupling capacitors, including up to two bulk capacitors of 100µF each, placed next to the battery-connector. These capacitors are connected to the 3.3V and the output Vo pins to ensure stable power delivery. Additionally, the board features two TVS diodes for protection; one safeguards the USB input 5V voltage (Vin), and the other protects the output voltage (Vo). These TVS diodes provide protection against electrostatic discharges (ESD), capable of safely absorbing repetitive ESD strikes above the maximum level specified in the IEC 61000-4-2 international standard without performance degradation.
The board also includes an onboard 3.3V Low Dropout (LDO) regulator, which provides a stable power supply to its low-voltage components. This tiny NCP177 LDO chip can output up to 500mA output current with a typically low dropout voltage of 200mV at 500mA.
GPIO and Power Pins
Given the compact design, the main challenge was to maximize the use of GPIO pins. We tackled this by dividing each of the three available sides of the CodeCell into different I/O sections based on their applications. We also placed power pins along the edges of the module for easy connection to various power sources, allowing you to connect other modules, sensors, and actuators to different sides.
On the bottom side, 3 out of 5 pins are used for power: a ground pin (GD), a 3.3V logic-level power pin (3V3) and a 5V input charge pin (5V0). This 5V0 pin is connected to the USB input-voltage. This means you can use it to get 5V power when the USB is connected, or you can use it as a power input for charging instead of using the USB.. The other 2 pins are the I2C SDA & SCL pins for adding external digital sensors. If your not using any external and the light/motion sensors, these I2C pins can be set up as GPIOs.
The other two sides each have a ground pin (GD) and a voltage output pin (VO). Each side also features 3 programmable GPIO pins (IO1, IO2, IO3, IO5, IO6, IO7), which can all be configured as PWM pins (ideal for directly connecting an h-bridge for actuator/motor control). IO1, IO2, and IO3 can also be used as ADC pins.
Sensing Capabilities
The CodeCell's standout features include its onboard sensors. Each unit comes equipped with a built-in light sensor, and there's also an optional motion sensor available to elevate your project's motion detection—especially useful for robotics and wearables!
Next we'll dive into how the CodeCell library simplifies both configuring these sensors and reading their data.
What about the BOOT Pin?
Some ESP32 development boards include both a RST (Reset) button and a BOOT button to manually put the device into programming mode. However, the ESP32-C3, such as the one on the CodeCell module, can automatically enter boot mode through the serial interface when using the Arduino IDE. This means the CodeCell doesn't need dedicated RST or BOOT buttons, which allowed us to make it as small as it is.
In the rare case that your CodeCell freezes or encounters an exception (causing it to continuously reset), you can manually force it into boot mode to reflash the firmware. To do this, simply follow these steps:
Following these steps will restore your CodeCell back to life.
To make programming even easier, the CodeCell library provides a wide array of functions for initializing, reading, and managing sensors and power. In this section we're going to explain everything you need to know about setup up your device and it's library.
Unboxing Your CodeCell
Let’s start with what you’ll find inside the box. Depending on the options you selected during checkout, in the box you'll find:
Powering Up Your CodeCell for the First Time
Let's start by plugging in a USB-C cable! Once your CodeCell receives power it should:
Setting Up Your CodeCell
Next step is to connect the CodeCell to Arduino IDE and run a sketch:
With your IDE all set up, we can now go ahead an install the "CodeCell" library. To do this go to 'Sketch>Include Library>Manage Libraries' - the 'Library Manager' should open up. Just type "CodeCell" and click 'Install' to download the latest version of the CodeCell.
We are continuously updating and adding new features to this library, so make sure you're using the latest version.
To quickly get familiar with this library, go to 'File > Examples > CodeCell,' where you'll find multiple examples you can use and modify for your projects. We recommend starting with the 'GettingStarted' example, which contains just a few lines of code but explains all the sensing functionalities available with CodeCell.
Once you select an example sketch, click the 'Upload' button to flash the code onto your CodeCell. After uploading, open the Serial Monitor 'Tools > Serial Monitor' to see serial data from your CodeCell.
Here are some additional CodeCell tutorials to help you get started with various applications:
CodeCell Library Functions
To explore the code further, let's break down all the functions and explain what each one does:
Initializing CodeCell
The first step in using the CodeCell is to initialize it. This is done using the `myCodeCell.Init()` function, which allows you to specify the sensors you want to enable.
Available Sensing Macros:
You can combine multiple macros using the `+` operator to initialize multiple sensors at once.
Managing Power
The `myCodeCell.Run()` function is crucial for power management. This function should be called within the `loop()` function to handle battery status and ensure optimal power usage.
Function Behavior:
Reading Sensor Data
After initializing the sensors, you can read their data using various functions provided by the library. Here's a quick rundown of the available functions:
Light Sensor Functions:
Motion Sensor Functions:
Example Usage:
Sleep, Power-Saving, Diagnostic & LED Functions
The CodeCell includes several functions to manage sleep and power-saving modes:
You've now taken your first steps with CodeCell. Dive deeper into the library examples, explore sensor integrations, and start bringing your innovative projects to life with CodeCell!
The CoilPad is an incredibly thin and innovative actuator that brings motion to your projects in a compact form factor. To understand how it works, let's dive into its unique design and the principles behind its operation.
In this tutorial we will explain:
What is a CoilPad?
The CoilPad is an actuator made from a flexible planar coil that adheres seamlessly to any smooth surface. By adding a magnet, it transforms into a device capable of magnetic movement, buzzing, or even heating. It’s designed to convert electrical energy into mechanical movement with ease.
How Does It Work?
The CoilPad features a flat, ultra-thin coil that interacts with external magnets. When an electric current passes through the coil, it generates a magnetic field that either attracts or repels the magnet, causing movement. By alternating the direction of the current, you can control the motion of the CoilPad. Applying a square wave signal makes the CoilPad oscillate continuously, with adjustable speed and intensity. For smooth organic motions, we will explore the DriveCell PWM library.
Installing CoilPad
The CoilPad design makes it easy to install. It comes with a peelable adhesive back, ensuring that it stays firmly attached to any smooth surface.
Getting Your CoilPad Moving
You can start testing it, by pulling one of its pins to 5V and the other to ground, then switch them around. In one instance, the magnet will be repelled, and in the other, it will be attracted. You can connect it to your own transistors or H-bridge module to switch these pins automatically. However, to make it even easier, you can purchase our tiny DriveCell module. The DriveCell is a compact, pin-to-pin compatible H-bridge driver that simplifies the process of controlling actuators like the CoilPad. Its open-source Arduino software library makes actuator control easy, especially for beginners, by providing straightforward software functions and easy-to-follow examples.
For an in-depth guide on the DriveCell Software Library, check out this article. But here’s a quick recap of how you can use its functions to enhance the CoilPad actuation. Don’t worry, it’s quite simple! Start by downloading the "DriveCell" library from Arduino's Library Manager. Once installed, you’ll be ready to control your device. 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 and interactive sensing to your CoilPad.
1. Init()
First, we need a basic setup code to get you started:
#include <DriveCell.h> // This line includes the DriveCell library
DriveCell myCoilPad(IN1, IN2); // Replace IN1 and IN2 with your specific pins
void setup() {
myCoilPad.Init(); // Initializes your DriveCell connected to a CoilPad
}
This code gives the name 'myCoilPad' to your DriveCell and tells it to start up and initialize all the necessary peripherals.
2. Pulse(bool direction, uint8_t ms_duration)
This function sends a brief burst of power to the CoilPad in a specified polarity. This quick energizing and de-energizing can cause a short, sharp movement of the CoilPad, depending on the polarity.
myCoilPad.Pulse(1, 10); // Sends a short burst for 10 milliseconds in the specified direction
3. Buzz(uint16_t us_buzz)
This function makes the CoilPad vibrate like a buzzer, which is useful for creating audible feedback.
myCoilPad.Buzz(100); // Makes the CoilPad buzz with a 100 microsecond pulses
4. Tone()
The Tone
function makes the CoilPad play a tone. This can be used for audible feedback or creative applications where sound is part of the interaction.
myCoilPad.Tone(); // Plays a tone by varying the frequency
5. Toggle(uint8_t power_percent)
This function toggles the CoilPad polarity, which can be useful for creating a rapid flapping movement or reversing direction quickly in your code.
myCoilPad.Toggle(100); // Toggles direction at 100% power
6. Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)
This function allows you to continuously flip the polarity of the CoilPad and control its motion speed and smoothness. If smooth
is set to true
, the actuation will be less sharp and smoothed, which is ideal for slower, controlled movements.
myCoilPad.Run(true, 50, 1000); // Runs the CoilPad smoothly at 50% power, flipping every 1000 milliseconds
7. Drive(bool direction, uint8_t power_percent)
This function lets you control the CoilPad polarity and its magnetic field strength by adjusting the power level.
myCoilPad.Drive(true, 75); // Moves the CoilPad forward at 75% power
Here's an example where we configure two CoilPads and actuate them at two different speeds:
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell CoilPad1(IN1_pin1, IN1_pin2);
DriveCell CoilPad2(IN2_pin1, IN2_pin2);
uint16_t c_counter = 0;
void setup() {
CoilPad1.Init();
CoilPad2.Init();
CoilPad1.Tone();
CoilPad2.Tone();
}
void loop() {
delay(1);
c_counter++;
if (c_counter < 2000U) {
CoilPad1.Run(0, 100, 100);
CoilPad2.Run(0, 100, 100);
}
else if (c_counter < 8000U) {
CoilPad1.Run(1, 100, 1000);
CoilPad2.Run(1, 100, 1000);
} else {
c_counter = 0U;
}
}
Combining with CodeCell Sensors
To make it even more interactive you can combine the CoilPad and DriveCell with the tiny CodeCell Sensor Module. CodeCell is pin-to-pin compatible with DriveCell, supports all library functions, and can adds wireless control and interactive sensing to your project. This allows you to create more advanced, responsive elements with your CoilPad actuators.
With this next example the CodeCell controls two CoilPad that stops flapping when proximity is detected. Their magnetic field gets adjusted dynamically based on how close your hands gets. If no hand is detected it flips the CoilPad polarity every 400 milliseconds.
#include <CodeCell.h>
#include <DriveCell.h>
#define IN1_pin1 2
#define IN1_pin2 3
#define IN2_pin1 5
#define IN2_pin2 6
DriveCell CoilPad1(IN1_pin1, IN1_pin2);
DriveCell CoilPad2(IN2_pin1, IN2_pin2);
CodeCell myCodeCell;
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*/
CoilPad1.Init();
CoilPad2.Init();
CoilPad1.Tone();
CoilPad2.Tone();
}
void loop() {
if (myCodeCell.Run()) {
/*Runs every 100ms*/
uint16_t proximity = myCodeCell.Light_ProximityRead();
Serial.println(proximity);
if (proximity < 100) {
CoilPad1.Run(1, 100, 400);
CoilPad2.Run(1, 100, 400);
} else {
proximity = proximity - 100;
proximity = proximity / 10;
if (proximity > 100) {
proximity = 100;
}
CoilPad1.Drive(0, (proximity));
CoilPad2.Drive(0, (proximity));
}
}
}
Feel free to tweak the code with your own creative ideas, or add motion sensing for a new reaction! Get started today with our Arduino libraries! If you have any more question about the CoilPad feel free to email us and we will gladly help out!
The FlatFlap is an incredibly thin and innovative actuator that brings motion to your projects in a compact form factor. To understand how it works, let's dive into its unique design and the principles behind its operation.
In this tutorial we will explain:
What is a FlatFlap?
It's Flat and its a Flap ~ the FlatFlap is an actuator made from a flexible PCB (printed circuit board) and aluminum stiffeners, folded together to create a low-force flapping motion. It’s magnetic system converts electrical energy into mechanical movement.
How Does It Work?
The FlatFlap features a thin 10mm N52 neodymium magnet on its back, which interacts with the planar copper coil embedded within the flexible PCB. When an electric current passes through the coil, it generates a small magnetic field that either attracts or repels the magnet, causing the flap to move. By alternating the direction of the current, you can control the flapping motion of the actuator. Applying a square wave signal makes the FlatFlap flap continuously, with speeds of up to 25Hz. For smooth organic motions, we will explore the DriveCell PWM library.
Installing FlatFlap
The FlatFlap design makes it easy to install. It comes with a peelable adhesive back and optional M1.2 screws (included) for added security, ensuring that it stays firmly attached to any surface, whether smooth or textured. The adhesive is 3M467, which provides a strong bond but can be removed with tweezers if needed.
Getting Your FlatFlap Moving
If you purchased the FlatFlap as a stand-alone actuator, you can start by pulling one of its pins to 5V and the other to ground, then switch them around. In one instance, the flap will be repelled, and in the other, it will be attracted. You can connect it to your own transistors or H-bridge module to switch these pins automatically. However, to make it even easier, you can purchase the FlatFlap directly soldered to our tiny DriveCell module. The DriveCell is a compact, pin-to-pin compatible H-bridge driver that simplifies the process of controlling actuators like the FlatFlap. Its open-source Arduino software library makes actuator control easy, especially for beginners, by providing straightforward software functions and easy-to-follow examples.
For an in-depth guide on the DriveCell Software Library, check out this article. But here’s a quick recap of how you can use its functions to enhance the FlatFlap actuation. Don’t worry, it’s quite simple! Start by downloading the "DriveCell" library from Arduino's Library Manager. Once installed, you’ll be ready to control your device. 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 and interactive sensing to your FlatFlap.
1. Init()
First we need a basic setup code to get you started:
#include <DriveCell.h> // This line includes the DriveCell library
DriveCell myFlatFlap(IN1, IN2); // Replace IN1 and IN2 with your specific pins
void setup() {
myFlatFlap.Init(); // Initializes your DriveCell connected to a FlatFlap
}
This code gives the name 'myFlatFlap' to your DriveCell and tells it to start up and initialize all the necessary peripherals.
2. Pulse(bool direction, uint8_t ms_duration)
This function sends a brief burst of power to the FlatFlap in a specified polarity. This quick energizing and de-energizing can cause a short, sharp movement of the FlatFlap, depending on the polarity.
myFlatFlap.Pulse(1, 10); // Sends a short burst for 10 milliseconds in the specified direction
2. Buzz(uint16_t us_buzz)
This function makes the FlatFlap vibrate like a buzzer, which is useful for creating audible feedback.
myFlatFlap.Buzz(100); // Makes the FlatFlap buzz with a 100 microsecond pulses
3. Tone()
The Tone
function makes the FlatFlap play a tone. This can be used for audible feedback or creative applications where sound is part of the interaction.
myFlatFlap.Tone(); // Plays a tone by varying the frequency
4. Toggle(uint8_t power_percent)
This function switches the FlatFlap direction, which can be useful for creating a rapid flapping movement or reversing direction quickly in your code.
myFlatFlap.Toggle(100); // Toggles direction at 100% power
5. Run(bool smooth, uint8_t power_percent, uint16_t flip_speed_ms)
This function allows you to continuously flip the polarity of the FlatFlap and control its motion speed and smoothness. If smooth
is set to true
, the flapping will be less sharp and smoothed, which is ideal for slower, controlled movements.
myFlatFlap.Run(true, 50, 1000); // Runs the FlatFlap smoothly at 50% power, flipping every 1000 milliseconds
6. Drive(bool direction, uint8_t power_percent)
This function lets you control the FlatFlap polarity and angular position of the flap by adjusting the power level, basically adjusting how strong the magnetic pull or push is.
myFlatFlap.Drive(true, 75); // Moves the FlatFlap forward at 75% power
Here's an 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();
}
}
Combining with CodeCell Sensors
To make it even more interactive you can combine the FlatFlap and DriveCell with the tiny CodeCell Sensor Module. CodeCell is pin-to-pin compatible with DriveCell, supports all library functions, and adds wireless control and interactive sensing to your project. This allows you to create more advanced, responsive elements with your FlatFlap actuators.
With this next example the CodeCell controls two FlatFlap that stops flapping when proximity is detected. Their angle gets adjusted dynamically based on how close your hands gets.
#include <CodeCell.h>
#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);
CodeCell myCodeCell;
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*/
FlatFlap1.Init();
FlatFlap2.Init();
FlatFlap1.Tone();
FlatFlap2.Tone();
}
void loop() {
if (myCodeCell.Run()) {
/*Runs every 100ms*/
uint16_t proximity = myCodeCell.Light_ProximityRead();
Serial.println(proximity);
if (proximity < 100) {
FlatFlap1.Run(1, 100, 400);
FlatFlap2.Run(1, 100, 400);
} else {
proximity = proximity - 100;
proximity = proximity / 10;
if (proximity > 100) {
proximity = 100;
}
FlatFlap1.Drive(0, (proximity));
FlatFlap2.Drive(0, (proximity));
}
}
}
Feel free to tweak the code with your own creative ideas, or add motion sensing for a new reaction! With FlatFlap, you can bring your creative projects to life with motion in a sleek, compact package. Whether you're adding dynamic elements to art, experimenting with robotics, or developing interactive mechanical displays, the FlatFlap provides a versatile and easy-to-use solution. Get started today with our Arduino libraries! If you have any more question about the FlatFlap feel free to email us and we will gladly help out!
CoilCell is a compact planar coil designed for various DIY projects. Whether you're just starting or are an experienced maker, CoilCell offers easy integration to simplify your creations. In this tutorial we will explain:
What is CoilCell?
CoilCell is a thin, planar coil built on a multi-layered PCB, with an integrated driver that simplifies controlling magnetic polarity and strength. It is available in two configurations:
Magnetic Applications
Safety Tips
While using the 2.5W 200-Turns CoilCell, it can potentially heating up to 110°C, especially when combined with the iron back-plate. Follow these precautions:
How Does CoilCell Work?
CoilCell utilizes an on-board DRV8837 H-bridge chip to control current flow through the coil, allowing it to switch magnetic polarity:
The DRV8837 chip provides overcurrent protection, undervoltage lockout, and thermal shutdown features, ensuring safe operation.
Getting Started with CoilCell
Wiring one of the input-pins to VCC will instantly turn on the CoilCell. 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 CoilCell what to do. Don’t worry, it’s quite simple! Start by downloading the "CoilCell" 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 CoilCell to your microcontroller -- We recommend using a CodeCell which is pin to pin compatible, the same size, supports all the library functions, and can add wireless control + interactive sensing.
1. Initialize CoilCell
#include <CoilCell.h>
CoilCell myCoilCell(IN1, IN2); // Replace IN1 and IN2 with your specific pins
void setup() {
myCoilCell.Init(); // Initializes the CoilCell
}
This code configures the CoilCell, setting it up for magnetic control based on your selected pins and microcontroller.
2. Bounce(bool direction, uint8_t ms_duration)The Bounce()
function makes a magnet bounce up and down. The first parameter, sets the polarity of the CoilCell and the delay_ms
, sets the duration for which the magnet is repelled./
myCoilCell.Bounce(true, 20); //Bounce the magnet up for 20ms
3. Buzz(uint16_t us_buzz)
Create a buzzing sound by rapidly alternating the coil’s polarity. Adjust 'us_buzz' to control the frequency of the buzz.
myCoilCell.Buzz(80); // Generates a buzzing effect at 80 microseconds intervals
4. Tone()
This function plays a default tone by making the CoilCell vibrate at different saved frequencies.
myCoilCell.Tone(); // Plays varying tones
5. Drive(bool direction, uint8_t power_percent)
By using the CodeCell or any other ESP32 microcontroller, this function lets control the coil’s magnetic polarity and strength. The magnetic strength is adjusted by the 'power_percent', which controls how far the magnet is pushed from the coil.
myCoilCell.Drive(true, 75); // Drive the coil north with 75% strength
6. Toggle(uint8_t power_percent)
By using the CodeCell or any other ESP32 microcontroller, this function toggles the coil’s polarity at a set power level, useful for simple magnetic flipping actions.
myCoilCell.Toggle(60); // Toggle polarity at 60% power
For other Arduino devices, this command makes the coilcell flip its direction at full power.
myCoilCell.Toggle(); // Toggle polarity at 100% power
7. Vibrate(bool smooth, uint8_t power_percent, uint16_t vib_speed_ms)
This function flips the coil’s polarity at a specified speed and power. Setting 'smooth' to true creates smoother motions, ideal for slow frequencies below 2 Hz.
myCoilCell.Vibrate(true, 50, 1000); // Smooth vibration at 50% power every 1000 ms
For other Arduino devices, this command makes the coilcell flip its polarity at full power.
myCoilCell.Vibrate(100); // Vibrate at 100% power every 100 ms
Here's an example where we initialize a CoilCell to make a 5mm diameter ball magnet bounce. In this example, the CoilCell is initialized with pins 5 and 6. The setup()
function calls myCoilCell.Init()
to configure the CoilCell. In the loop()
, the Bounce()
function is used to make the magnet bounce upwards for 20 milliseconds, followed by a 600 milliseconds delay that attracts the magnet back down.
#include <CoilCell.h>
#define IN1_pin1 5
#define IN1_pin2 6
CoilCell myCoilCell(IN1_pin1, IN1_pin2);
void setup() {
myCoilCell.Init(); /*Initialize the CoilCell*/
}
void loop() {
myCoilCell.Bounce(0, 20); /*Bounce the magnet up for 20ms*/
delay(600); /*Attract the magnet back down for 600ms*/
}
In this next example we use the CodeCell's Motion Sensor to detect tapping. When a new tap is detected the CoilCell flips its magnetic polarity and sets a 1 second delay to flash the onboard LED to yellow.
#include <CodeCell.h>
#include <CoilCell.h>
#define IN1_pin1 5
#define IN1_pin2 6
CoilCell myCoilCell(IN1_pin1, IN1_pin2);
CodeCell myCodeCell;
void setup() {
Serial.begin(115200); /* Set Serial baud rate to 115200. Ensure Tools/USB_CDC_On_Boot is enabled if using Serial. */
myCodeCell.Init(MOTION_TAP_DETECTOR); /*Initializes Tap Detection Sensing*/
myCoilCell.Init();
myCoilCell.Tone();
}
void loop() {
if (myCodeCell.Run()) {
/*Runs every 100ms*/
if (myCodeCell.Motion_TapRead()) {
/*If Tap is detected shine the LED Yellow for 1 sec and flip the CoilCell's polarity*/
myCodeCell.LED(0XA0, 0x60, 0x00U);
myCoilCell.Toggle(100);
delay(1000);
}
}
}
With these basic functions, you can start experimenting with CoilCell in your projects. Whether you’re controlling magnets, creating interactive displays, or experimenting with magnetic forces, CoilCell provides a simple and effective solution.
If you have any more question about the CoilCell feel free to email us and we will gladly help out!
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 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:
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:
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:
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!
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.