🎉 Black Friday is Here! Enjoy Up to 35% Off ~ Offer Ends November 30th!
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!
Be the first to know about new projects and get exciting deals!
© 2024 Microbots.