In this build, we'll explore how to use the CodeCell's onboard proximity sensor to detect depth gestures and control two FlatFlaps, varying their angles based on the proximity values. This project demonstrates a unique way to create interactive robots, actuators, motors or light that respond to hand movements.
The CodeCell is equipped with a VCNL4040 proximity sensor that can measure distances up to 20 cm. By using an infrared light, the sensor detects objects within its range, measuring the reflection of emitted IR light to approximate distance. This allows you to create responsive behaviors based on how close an object is, making it ideal for interactive gestures.
Depth gestures are based on the proximity data from the CodeCell's onboard sensor. By moving your hand or other objects closer or further from the sensor, you can create dynamic inputs that drive various actions. In this project, the proximity data is used to control the angle of two FlatFlaps, which are connected to two DriveCells (H-bridge drivers).
In this example, the CodeCell continuously reads proximity data and adjusts the angle of two FlatFlaps based on how close the object is. As the object moves closer or further, the angle of the FlatFlaps changes, demonstrating a simple yet effective method for depth gesture-based control.
The two FlatFlaps, are soldered to two DriveCells (H-bridge drivers), which are pin to pin compatible with the CodeCell. These components are then connected on 3D printed mount, to create a cute little Flappy-Bot! Don't forget to add a googly-eye to give it more personality!
Below is the example code to get you started. Ensure your CodeCell is properly connected via USB-C, and the FlatFlaps are connected to the two DriveCells. Follow the comments in the code to understand each step.
#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) {
// If proximity is detected, the FlatFlaps flap
FlatFlap1.Run(1, 100, 400);
FlatFlap2.Run(1, 100, 400);
} else {
// Adjust FlatFlap angle based on proximity
proximity = proximity - 100;
proximity = proximity / 10;
if (proximity > 100) {
proximity = 100;
}
FlatFlap1.Drive(0, proximity);
FlatFlap2.Drive(0, proximity);
}
}
}
This project shows how to use the CodeCell's proximity sensor for depth gestures, driving the angles of FlatFlaps based on object distance. Experiment with the code, customize the parameters, and bring your own flappy bot to life!
In this build, we'll explore how to configure the CodeCell's onboard motion sensor to try and guess the personal activate you're doing, and display it on an OLED screen. Its meant to track different states such as walking, running, cycling, climbing stairs and driving!
The CodeCell's motion sensor is capable of categorizing various personal activities based on movement patterns. Based on these patterns the BNO085 sensor will try to guess which activity is being performed. These activities include walking, running, cycling, driving and more.
The CodeCell library makes it easy for you to directly read the activity without any complex code.
In this example, the CodeCell continuously monitors the BNO085's personal activity guess. The activity with the highest chance is then displayed on an OLED screen using the Adafruit SSD1306 library. This setup is ideal for creating wearable activity monitors or fitness trackers that provide real-time feedback on physical activities.
Note that some activities might take between 10-30 seconds to start getting recognized, as it will mainly depend on orientation of the CodeCell and where it is mounted.
Below is the example code to get you started. Make sure your CodeCell is connected via USB-C and your OLED display is wired correctly to the CodeCell’s lower side, using its ground, 3V3, and I2C pins (SDA and SCL).
Follow the comments in the code to understand each step.
#include <CodeCell.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
CodeCell myCodeCell;
/* Configure the OLED Display */
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C // Address of the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
int read_timer = 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(MOTION_ACTIVITY); // Initializes activity sensing.
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.display();
delay(2000);
}
void loop() {
if (myCodeCell.Run()) {
if (read_timer < 10) {
read_timer++;
} else {
// Update every 1 sec
read_timer = 0;
display.clearDisplay();
display.setCursor(32, 16);
display.print(F("Activity: "));
display.setCursor(32, 24);
switch (myCodeCell.Motion_ActivityRead()) {
case 1:
display.print("Driving");
break;
case 2:
display.print("Cycling");
break;
case 3:
case 6:
display.print("Walking");
break;
case 4:
display.print("Still");
break;
case 5:
display.print("Tilting");
break;
case 7:
display.print("Running");
break;
case 8:
display.print("Stairs");
break;
default:
display.print("Reading..");
break;
}
display.display();
}
}
}
This project demonstrates how to use the CodeCell’s motion sensor to monitor personal activities and display the results on an OLED screen. This basic setup provides a foundation for developing more advanced activity monitoring systems.
Experiment with the code and settings to create your own personalized wearable!
In this build, we'll explore how to use the CodeCell's onboard motion sensor to measure step counts and display these counts on an OLED display. This project demonstrates how to create a step counter, ideal for fitness trackers, pedometers, or any other DIY project that requires activity monitoring.
The CodeCell is equipped with a motion sensor that can track step counts by using its onboard sensors to detect specific movement patterns. This algorithm is performed inside the BNO085 sensor, and the CodeCell library help you easily reads these step counts.
In this example, the CodeCell continuously monitors for steps and updates the count. This count is then displayed on an OLED screen using the Adafruit SSD1306 library.
Below is the example code to get you started. Ensure your CodeCell is properly connected via USB-C and your OLED display is correctly wired to the CodeCell's lower side. There you can use its ground, 3V3 and I2C pins (SDA and SCL).
Follow the comments in the code to understand each step.
#include <CodeCell.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
CodeCell myCodeCell;
/* Configure the OLED Display */
#define SCREEN_WIDTH 64 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C // Address of the OLED display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
uint16_t step_counter = 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(MOTION_STEP_COUNTER); // Initializes step counting and activity sensing.
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println("Display Error");
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.display();
delay(2000);
}
void loop() {
if (myCodeCell.Run()) {
// Read step count from the CodeCell motion sensor.
myCodeCell.Motion_StepCounterRead(step_counter);
// Clear the display and show the step count.
display.clearDisplay();
display.setCursor(32, 16); // Start at top-left corner
display.print(F("Steps: "));
display.print(step_counter);
display.display();
}
}
This project demonstrates how to use the CodeCell’s motion sensor to count steps and display the count on an OLED screen. Experiment with the code,to create your own wearable fitness device!
In this build, we'll explore how to use the CodeCell's onboard 9-axis motion sensor to read roll, pitch, and yaw angles, and use these angles to control a servo motor. This project demonstrates how to create interactive motion-based controls, perfect for robotics, gimbals, or any project that requires responsive rotation control.
The CodeCell is equipped with a BNO085 motion sensor, which provides precise motion sensing capabilities, including roll, pitch, and yaw angles. By reading these angles, you can create interactive motion controls for various applications, such as stabilizing platforms or create a response to device orientation.
The BNO085 motion sensor read the acceleromter, gyroscope and magnetometer reading and compute the rotation vectors. These vectors are sent to the CodeCell which it then transforms into angular data to obtain the roll, pitch, and yaw based on the device's orientation in space. These angles represent the device's rotation along three axes. In this example, we'll use the pitch angle to control the position of a servo motor, allowing it to respond dynamically to changes in orientation.
In this example, the CodeCell continuously monitors the pitch angle. The pitch value is used to set the servo motor's position, allowing it to rotate based on how you tilt the device. This basic functionality can be expanded to create more complex interactions, such as controlling multiple servos, stabilizing a platform, or adding responsive movements to a robot.
Below is the example code to get you started. Make sure your CodeCell is properly connected via USB-C. Also, make sure that your servo-motor can be power via USB-C and add its angular limits to the code.
For this example you have to download the ESp32Servo libraryto control the servo-motor with your CodeCell. Follow the comments in the code to understand each step.
#include <CodeCell.h>
#include <ESP32Servo.h>
CodeCell myCodeCell;
Servo myservo;
float Roll = 0.0;
float Pitch = 0.0;
float Yaw = 0.0;
int servo_angle = 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(MOTION_ROTATION); // Initializes rotation sensing
myservo.attach(1); // Attaches the servo on pin 1 to the servo object
}
void loop() {
if (myCodeCell.Run()) {
// Read rotation angles from the BNO085 sensor
myCodeCell.Motion_RotationRead(Roll, Pitch, Yaw);
// Convert the pitch angle to a servo angle
servo_angle = abs((int)Pitch);
servo_angle = (180 - servo_angle);
// Limit the servo angle to the range 0-60 degrees
if (servo_angle > 60) {
servo_angle = 60;
} else if (servo_angle < 0) {
servo_angle = 0;
}
Serial.println(servo_angle); // Print the servo angle for debugging
myservo.write(servo_angle); // Set the servo position
}
}
servo_angle
in the code. In this example we are using a 60deg range micro-servo. Note that some servo-motors are not mechanically linear so you might also have to compensate for its angular-mechanical error.This project introduces the basics of using rotation sensing with CodeCell to control a servo, opening up numerous possibilities for motion-responsive projects. Experiment with the code, tweak the settings, and create your own dynamic builds!
In this build, we'll explore how to use the CodeCell's onboard 9-axis motion sensor to detect taps. This project demonstrates how to use tap detection for interactive controls, making it perfect for creating responsive actions with a simple tap on the device.
The CodeCell is equipped with a BNO085 motion sensor, which offers a variety of sensing capabilities, including tap detection. This feature uses accelerometer data to detect taps, making it ideal for interactive controls like toggling lights, triggering sound effects, or other actions based on a simple tap gesture.
The BNO085 motion sensor detects taps by monitoring sudden accelerations along its axes. When a tap is detected, the sensor registers the event, allowing you to trigger actions like lighting up an LED or toggling other devices. This functionality is particularly useful for creating touch-based interactions without the need for mechanical buttons.
In this example, the CodeCell continuously monitors for taps. When a tap is detected, the onboard LED lights up in yellow for one second. You can expand on this basic functionality to create more complex interactions, such as controlling multiple LEDs, motors, or other connected devices based on tap inputs.
Below is the example code to get you started. Make sure your CodeCell is properly connected via USB-C, and follow the comments in the code to understand each step.
#include <CodeCell.h>
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
}
void loop() {
if (myCodeCell.Run()) {
// Runs every 100ms to check for taps
if (myCodeCell.Motion_TapRead()) {
// If a tap is detected, shine the LED yellow for 1 second
myCodeCell.LED(0xA0, 0x60, 0x00); // Set LED to yellow
delay(1000); // Keep the LED on for 1 second
}
}
}
In this next example, we use a CoilCell to flip its polarity, and actuate a flip-dot. This expands the interactivity by using tap detection to control external devices, creating a more dynamic response.
#include <CoilCell.h>
#include <CodeCell.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(); // Initializes the CoilCell.
myCoilCell.Tone(); // Plays a tone to confirm initialization.
}
void loop() {
if (myCodeCell.Run()) {
// Runs every 100ms to check for taps.
if (myCodeCell.Motion_TapRead()) {
// If a tap is detected, shine the LED yellow and flip the CoilCell's polarity.
myCodeCell.LED(0xA0, 0x60, 0x00); // Set LED to yellow.
myCoilCell.Toggle(100); // Toggle the CoilCell's polarity.
delay(1000); // Delay to keep the LED on and polarity flipped for 1 second.
}
}
}
This project introduces the basics of using tap detection with CodeCell. Experiment with the code, customize the responses, and explore the potential of tap detection in your next project!
In this build, we'll explore how to use the CodeCell's onboard proximity sensor to detect objects.
The CodeCell is equipped with a VCNL4040 sensor that can measure proximity up to 20 cm. This sensor uses I2C communication and is automatically initialized through the CodeCell library, allowing for seamless integration into your projects. Whether you're looking to add simple gesture depth control or detect nearby objects, the VCNL4040 makes it easy to add proximity sensing into your builds.
The VCNL4040 proximity sensor uses infrared light to detect objects within its range. It measures the reflection of emitted IR light to approximate how close an object is, allowing you to create responsive behaviors based on proximity. This feature is particularly useful for creating interactive lighting, robotics, touchless switches, or other proximity-based actions.
In this example, the CodeCell continuously monitors proximity data and turns on a red LED when an object is detected. You can expand on this basic functionality to create more complex interactions, such as varying the LED color or brightness based on distance, or triggering different actions based on proximity.
Below is the example code to get you started. Ensure your CodeCell is properly connected via USB-C, and follow the comments in the code to understand each step.
#include <CodeCell.h>
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, including proximity
}
void loop() {
if (myCodeCell.Run()) {
// Runs every 100ms to check proximity
uint16_t proximity = myCodeCell.Light_ProximityRead();
// Check if an object is within range
if (proximity > 100) {
myCodeCell.LED(0xFF, 0, 0); // Set LED to Red when proximity is detected
delay(1000); // Keep the LED on for 1 second
} else {
// No action if the object is out of range
}
}
}
100
in the example) to adjust the sensitivity of proximity detection based on your application.myCodeCell.LED()
function to create multi-colored responses to proximity.This project introduces the basics of using proximity sensing with CodeCell, opening up a range of interactive possibilities. Experiment with the code, tweak the settings, and make it your own!
Click here for the next example, where we will experiment with using this proximity sensor for depth gestures.
In this build, we'll explore how to use the CodeCell to sense white light and automatically adjust the brightness of LEDs. This project demonstrates the CodeCell's onboard light sensor, helping you create responsive lighting effects that adapt to changing light conditions.
The CodeCell features a built-in VCNL4040 sensor that can measure both light levels and proximity up to 20 cm. This sensor uses I2C communication, and talks to the ESP32 in the CodeCell library, where the sensor is automatically initialized to optimize its sensing resolution. This makes the setup straightforward, so you can focus on building your project.
The VCNL4040 sensor on the CodeCell is capable of both ambient light sensing and white light sensing, each serving distinct purposes:
In this project, we're using the white light sensing feature to directly influence LED brightness based on the detected white light levels, creating a more targeted response compared to general ambient light sensing.
In this example, the CodeCell continuously measures ambient white light and adjusts the brightness of an onboard LED based on the detected light level. As the room gets darker, the LED will dim, providing a smooth transition that you can tweak and customize for your own lighting projects.
Below is the example code to get you started. Make sure your CodeCell is connected properly, and follow the comments in the code to understand each step.
#include <CodeCell.h>
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.
}
void loop() {
delay(100); // Small delay - You can adjust it accordingly
// Read white light from the sensor and adjust brightness for 8-bit
uint16_t brightness = (myCodeCell.Light_WhiteRead()) >> 3;
Serial.println(brightness); // Print the brightness value to the serial monitor for debugging.
// Limit the sensor values to the LED's brightness range (1 to 254)
if (brightness == 0U) {
brightness = 1U; // Set a minimum brightness to avoid turning off the LED completely
} else if (brightness > 254U) {
brightness = 254U; // Cap the brightness to the LED's maximum level
}
brightness = 255U - brightness; // Invert the brightness so the LED dims as it gets brighter
myCodeCell.LED(0, 0, brightness); // Shine the onboard blue RGB LED with the new adjusted brightness
}
myCodeCell.LED()
function allows you to specify RGB values. Try experimenting with different colors based on light levels.This project is just the starting point for utilizing the CodeCell's light-sensing capabilities. Dive into the code, make it your own, and light up your next project!
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!
Welcome to the exciting world of miniaturized robotics and IoT projects! 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 its robust features packed into a penny-sized board. In this guide, we’ll walk you through the unboxing, setting up, and first steps with your CodeCell.
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
Your CodeCell comes with pre-loaded software to get you familiar with its functionality. Here’s what it does:
Setting Up Your CodeCell
Here are the steps you need to take to connect and run a sketch on your new the CodeCell:
Trying Out CodeCell Examples
To try out the CodeCell Examples, we have to install the library.This can be done by going to the Arduino Library Maganer and search for 'CodeCell' in the library manager and click 'Install'. Make sure you have the latest version of the library installed.
Once the library is installed, go to 'File > Examples > CodeCell'. Here you’ll find various examples demonstrating how to use the light sensor, motion sensor and other features of the CodeCell.
Upload and Test
Open an example sketch, connect your CodeCell to your PC if not already connected, and click the 'Upload' button. After uploading, open the Serial Monitor 'Tools > Serial Monitor' to see serial data from your CodeCell.
Final Thoughts
Congratulations, you’ve taken the first steps with your CodeCell! Next step is to dive into the examples, experiment with the sensors, and have fun building your next innovative creation!
Happy coding!
Despite its small footprint, just 1.85 cm wide, CodeCell incorporates a range of features that make it a powerful tool for various applications.
Let's break down its hardware and explore the technical specifics that your next project can benefit from.
The 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.
The bottom side has 3 pins out of 5 used for power: a ground pin (GD), a 3.3V logic-level power pin (3V3) and an optional 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.. This side also contains 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!
The CodeCell is a versatile, penny-sized module that is perfect for DIY robotics, wearables, and IoT projects. It features an ESP32-C3 Wi-Fi & BLE module, and a USB-C port for both programming and battery charging. Designed for all makers, the CodeCell comes with a built-in light sensor and an optional 9-axis IMU motion sensor. To make programming even easier, the CodeCell library provides a wide array of functions for initializing, reading, and managing sensors and power.
Let's explore the CodeCell library and its functionalities to understand how to get the most out of this tiny but powerful board!
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 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:
The Next Step
Download the CodeCell Arduino Library from the Library Manager to get started with multiple examples that showcase how these functions are used. Explore the full capabilities of CodeCell and start building your next innovative project today!
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 the unique design and the principles behind its operation.
The Structure
The FlatFlap is designed from a flexible PCB (printed circuit board) and aluminum stiffeners. These components are carefully folded together to form the actuator.
The flexible PCB serves as the foundation of the actuator. Unlike rigid PCBs, the flexible version can bend and twist without breaking, which is essential for creating the flapping motion. The flexibility of the PCB allows the FlatFlap to move freely while still maintaining its structural integrity.
The Aluminum Stiffeners provide the necessary rigidity to hold the magnet that directs the flapping motion, ensuring that the movement is both precise and consistent.
The Magnetic System
The FlatFlap is powered by a clever magnetic system that converts electrical energy into mechanical motion. This system consists of a magnet on the back of the actuator and a planar copper coil embedded within the flexible PCB.
The FlatFlap features a 10mm N52 neodymium magnet attached to its back. This magnet plays a crucial role in the actuator's operation, interacting with the magnetic field generated by the copper coil. This coil is inside the flexible PCB, and is responsible for creating the magnetic field when an electric current is passed through it. Flapping motion is achieved by pulsing the current through the copper coil in different directions.
Depending on the direction of the current, this magnetic field interacts with the magnet on the back of the FlatFlap. By alternating the direction of the current, the magnetic field can either attract or repel the magnet, causing the flap to move. The voltage can also be varied via PWM, to control the distance of the coil from the magnet.
By rapidly pulsing the current in different directions, creating a square wave, the FlatFlap can produce a continuous flapping motion. The speed and frequency of this motion can be controlled by adjusting the rate at which the current is pulsed. In its optimal configuration. The FlatFlap can achieve a speed of up to 25Hz, creating a fast and responsive movement.
Easy Attachment and Secure Installation
Installing the FlatFlap is a breeze, thanks to its peelable adhesive back and optional screws. The adhesive provides a strong bond that keeps the actuator securely in place, while the screws offer an additional layer of security if needed. This dual installation method ensures flawless adhesion, whether you're attaching the FlatFlap to a smooth surface or something more textured.
Ultra-Thin and Compact Design
One of the standout features of the FlatFlap is its incredibly slim profile. With a flap that’s only 0.3mm thin and an actuator measuring just 2.6mm, this sleek design can integrate seamlessly into any flat surface. Its low profile ensures that it doesn't interfere with the aesthetics of your project, making it ideal for applications where space is at a limited.
The FlatFlap is perfect for a wide range of applications. It’s particularly well-suited for creating kinetic sculptures and experimenting with robotics. Its ability to add eye-catching motion to lightweight objects, such as thin 3D-printed plastic or paper origami, opens up a world of creative possibilities.
A PCB motor is an innovative solution that integrates the motor's mechanics into the electronic components, using the PCB itself as the structure of the motor.
What is a PCB Motor?
A PCB motor is a unique type of motor that uses the copper traces on a printed circuit board (PCB) to create a magnetic field that drives the motor. This concept is inspired by how radio systems use PCB traces as antennas. The same principle is applied to generate a magnetic field strong enough to turn a rotor. This type of motor is known as an axial flux brushless motor, where the PCB stator and the rotor are aligned in parallel.
The Design and Construction of a PCB Motor
The first step in creating a PCB motor is designing the PCB stator coils. In traditional motors, these coils are often made from wire wound into dense, three-dimensional shapes. In a PCB motor, the coils are instead manufactured as flat spiral traces printed onto the layers of a PCB.
One of the challenging aspects of these planar motors is fitting enough turns in the small space available to generate sufficient magnetic flux. These coils have to be connected in a star or delta configuration to create a 3-phase system. In our 6-slotted star-configured MotorCell design, we were able to stack the coils on four layers, utilizing two additional layers for the controller, to produce the required magnetic field to spin the rotor.
Over the years, we have also learned that the design of the rotor is crucial for improving the motor's efficiency. It is important to use high-quality ceramic ball bearings and to align the bearings precisely to achieve the optimal mechanical solution. This typically requires specialized tools, so we also offer the MotorCell 's rotor individually, allowing you to easily integrate it with your custom PCB.
Achieving Synchronization in the PCB Motor
One of the most critical aspects of driving a brushless motor is ensuring that the rotor stays in sync with the stator's electromagnetic field. In traditional motors with brushes, synchronization is mechanically managed by the brushes themselves. However, in a three-phase brushless motor like a PCB motor, sensory feedback is necessary to keep the motor running smoothly.
Back EMF is typically used as feedback to control the motor's speed. Back EMF is the voltage generated by the spinning motor itself, which can be measured to determine the rotor’s speed. This information is then fed into the motor’s control electronics, ensuring that the stator coils are driven in sync with the rotor's motion. For the MotorCell, all of this is handled directly by the onboard chip, simplifying the process.
Be the first to know about new projects and get exciting deals!
© 2024 Microbots.