This guide explains how the CoilCell can generate vibrations, how frequency and polarity affect its movement, and how to create its drive signals.
To make CoilCell vibrate, an electric current is applied to its coil, generating a magnetic field. By reversing the polarity at a set frequency, we create a repetitive push-pull motion that causes vibrations.
The vibration frequency can be controlled within the range of 1 Hz to 25 Hz, which means CoilCell can oscillate between 1 to 25 times per second depending on the input signal. It can go to higher frequencies, but usually the magnet won't have enough time to react.
If you attach it to something, you can adjust it to match its new resonant frequency and make the whole thing shake.
A square wave signal is required to make the CoilCell vibrate. Unlike CoilPad, CoilCell has an integrated H-Bridge driver, so no external driver like DriveCell is needed. The input signals of the square wave can be generated using simple digitalWrite()
commands in Arduino:
#define VIB_PIN1 2
#define VIB_PIN2 3
void setup() {
pinMode(VIB_PIN1, OUTPUT);
pinMode(VIB_PIN2, OUTPUT);
}
void loop() {
digitalWrite(VIB_PIN1, HIGH);
digitalWrite(VIB_PIN2, LOW);
delay(100); // Adjust delay for desired vibration speed
digitalWrite(VIB_PIN1, LOW);
digitalWrite(VIB_PIN2, HIGH);
delay(100); // Adjust delay for desired vibration speed
}
This simple code creates a square wave oscillation, making the CoilCell vibrate continuously. You can adjust the delay time to change the vibration frequency.
The code example above generates a basic square wave, which drives the coil in an abrupt on-off manner. At low frequencies, this might not be desirable. 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() {
delay(1);
vibration_counter++;
if (vibration_counter < 2000U) {
myCoilCell.Vibrate(0, 100, 100); // Square Wave mode
}
else if (vibration_counter < 8000U) {
myCoilCell.Vibrate(1, 100, 1000); // Smooth PWM Wave mode
} else {
vibration_counter = 0U;
}
}
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 Run()
function uses a high-speed PWM timer, making it compatible only with CodeCell and ESP32-based devices.
With these techniques, you can start using CoilCell to vibrate. Check out the CoilCell GitHub Repository for more code examples and technical documentation!
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.