Matching colours has always been part of design, crafts, and everyday life. A phone camera can guess a colour well, but its results shift with lighting, distance, and automatic adjustments. That’s why I built the AS7341-based Colour Picker Panel Light. Unlike a camera, the AS7341 measures light across multiple spectral bands, giving Lumi Tile a more consistent way to identify colours. Just hold it over an object, and it can display a colour reading you can use to find a close match for paint, yarn, fabric, or other materials.
With a single touch, it picks the colour of a nearby object and lights it up in the same colour. Since the AS7341-based Colour Picker Panel Light comes with an AS7341 spectral sensor that uses its own light and a fixed distance, the results stay far more consistent from one moment to the next. It also doubles as a desk gadget: a colour palette tool that can glow as a soft light. Whether you’re matching a favourite shade or simply exploring colours, Lumi Tile turns colour picking into a quick, hands-on experience.
AS7341-based Colour Picker Panel Light is also designed to make experimenting with colour feel effortless. Its compact form fits neatly on a desk, ready whenever inspiration strikes, while its gentle glow makes it as pleasant to display as it is to use.
Take a look at some of the key components used in this AS7341-based colour picker panel light, based on the AS7341 spectral sensor:-
- AS7341 Spectral Colour Sensor integrates the 11-channel ams-OSRAM AS7341 IC that can measure light intensity throughout 11 wavelength bands, including violet, indigo, blue, green, yellow, orange, red, white light, and near-infrared (NIR), as well as detect light flicker. It captures minute variations in colour, material, or illumination by recording the spectral signature of the surface or light source it is exposed to, making it ideal for spectral analysis and colour matching. This module comes with 6 (16-bit) ADC channels that use a built-in SMUX to transform the sensor’s raw analogue data into digital values that can be accessed via an I2C signal. In addition, it contains two built-in LEDs that serve as a flashlight in low-light conditions. You can use this sensor on the go without soldering the header pins because it is compatible with the STEMMA QT connectors.
- CJMCU 8×8 RGB LED Driver Development Board, also known as the 8×8 NeoPixel RGB LED Matrix, is a programmable 64 WS2812 RGB LEDs arranged in an 8×8 grid, where a single pixel is made up of a combination of red, green, and blue LEDs and a WS2812 driver chip. Each pixel in the matrix can be individually addressed without disturbing the others to create a full spectrum of colours and animations. Programming the 64 WS2812 RGB LEDs using any microcontroller is quite convenient, as it supports single-data-line communication to control all the pixels at once via a PWM signal.
- The TTP223B Capacitive Touch Switch is a decent touch-based sensor that makes use of the physical human touch response to drive a microcontroller. It can be used to trigger different colours, patterns, or animation modes on the LED matrix with a simple touch.
- Arduino Nano Every is a small, breadboard-friendly microcontroller ideal for embedded applications and prototyping. The ATmega4809 processor provides more capacity and versatility than the traditional Arduino Nano. It also supports I²C and SPI, making it suitable for connecting with sensors, displays, and other peripherals.
While making the wiring connection, you might need to consider the power utilisation, as the AS7341-based Colour Picker Panel Light uses two supply voltages. The CJMCU 8×8 RGB LED Driver Development Board runs on 5 V because its 64 WS2812B LEDs need that voltage, and it is connected to a separate 5 V supply rather than the Arduino Nano Every’s 5 V pin, which keeps the Arduino Nano Every’s regulator from being overloaded. The AS7341 Spectral Colour Sensor runs on 3.3 V, so they share the Arduino Nano Every’s 3.3 V pin and GND. Since both are low-power parts, one shared pin is enough, though the sensor’s built-in LEDs draw more current than the chip, so the 3.3 V rail’s headroom should be checked. To protect the 64 WS2812 RGB LEDs, a 330 Ω resistor is placed on the data line between the Arduino Nano Every and the CJMCU 8×8 RGB LED Driver Development Board. Also, a 1000 µF capacitor is placed across the CJMCU 8×8 RGB LED Driver Development Board power pins to smooth out current spikes. Finally, the 64 WS2812 RGB LEDs’ brightness is kept low via programming, which reduces power draw and heat, and makes the AS7341-based ColourPicker Panel Light comfortable as a desk lamp.
How the AS7341-Based Colour Picker Panel Light Works
When the AS7341-based Colour Picker Panel Light is powered on, the 64 WS2812 RGB LED matrix shows a slow blue breathing light, which tells the user the panel light is ready. The AS7341 Spectral Colour Sensor’s own LEDs stay off at this stage to save power. The panel waits quietly until the user touches the pad.
When the user touches the TTP223B Capacitive Touch Switch’s touch pad marked as “⏻,” it wakes up the Arduino Nano Every and signals the AS7341 Spectral Colour Sensor to start a scan by its built-in LEDs to light up the object in front of it.
The AS7341 Spectral Colour Sensor has an array of light-sensitive photodiodes that use an optical filter to record the amount of light entering from the exposed object or light source placed 1-2 cm in front, across 8 bands (F1 to F8). These measurements are sent to the Arduino Nano Every via I2C communication, as shown in the image below:
The Arduino Nano Every is programmed to turn those eight band readings into a single solid colour and send it to the 64 WS2812 RGB LEDs matrix via a PWM signal. The chosen colour is locked on the tile and stored in the Arduino Nano Every’s built-in EEPROM so that it will reappear if the power is switched off and back on.
To release the colour, the user taps the touchpad marked as “◎”. The colour picker tile unlocks and returns to the blue breathing light, ready for a new colour. To prevent accidental taps from unlocking the AS7341 Based Colour Picker Panel Light, the Arduino Nano Every ignores taps for 2 seconds after each lock.
For accurate results, the tile needs a one-time calibration. After powering on, place a white sheet of paper in front of the sensor and tap the touchpad marked as “⏻” three times. The tile measures the white paper, works out correction factors for each colour channel, and saves them to EEPROM. From then on, it treats that paper as true white.
Here are the instructions that can come in handy when you work with your AS7341-Based Colour Picker Panel Light:
User Input | Actions |
Power ON | The matrix breathes blue, ready to scan |
Single tap | Scan the object; the matrix blinks the yellow light, and it locks its colour. If the scan fails, the matrix displays a red light. |
Tap again | Unlock (wait 2 seconds after a lock first) |
Triple tap | Calibrate white on plain paper, saved to memory |
Power OFF and ON | The locked colour and calibration are kept |
E-Components
These are all the electronic components that are required for this DIY E-Project, and their purchase links are:-
MODEL | E-COMPONENT | PURCHASE LINK |
Arduino Nano Every | ||
AS7341 Spectral Color Sensor | ||
CJMCU 8x8 RGB LED Driver Development Board | ||
TTP223B Capacitive Touch Switch | ||
USB Female to Micro USB/USB Type C Connector | ||
USB data cable | ||
Power Bank |
For creating the outer case, here are the products required along with their purchase links:
PRODUCT | PURCHASE LINK |
Stencil Sheet | |
Black Foam Sheet | |
Small Plastic Container |
Circuit Diagram
Schematic Diagram
Procedure
These are some of the step-by-step guidelines to be followed for this DIY E-Project:
1. Install the latest Arduino IDE.
- From the Board Manager, install “Arduino MegaAVR Boards.”
- Install all the latest versions of these dependencies in the Arduino IDE. (Note: Make sure to click on the “Install All” button instead of “Install without dependencies” when prompted to avoid encountering any errors while debugging.)
1.Adafruit_AS7341
2.Adafruit_NeoPixel
4. Make hardware connections as per the above circuit and schematic diagrams. (Note: The CJMCU 8×8 RGB LED Driver Development Board needs to be soldered to leads/jumperwires before use. Simply get it soldered from your local electronics repair shop in case you have no prior soldering experience.
- Connect the Arduino Nano Every to one of your laptops/PCs via a USB data cable. In Arduino IDE, go to Tools→Board→Arduino MegaAVR Boards and select the board as Arduino Nano Every and the COM port accordingly.
6. Upload the sketch “colour picker tile” from the programming section to the selected Arduino Nano on every board.
7. After completing the program upload, you can unplug the USB data cable connected to the Arduino Nano Every. Every time, connect the laptop/PC and reconnect it to the Arduino Nano Every to the power bank.
8. Follow these steps to get your colour picker tile up and running:
1. Your AS7341-based ColourPicker Panel Light has two sides. On the front side, which is closed, you will find the CJMCU 8×8 RGB LED Driver Development Board, where the picked colour will be displayed. On the bottom side, which is exposed, there is a cutout for the AS7341 Spectral Colour Sensor that detects the colour, as well as a touch area marked as “⏻” that activates your colour picker tile.
2. As soon as you power on your AS7341-based ColourPicker Panel Light, you will see a blue breathing light on the CJMCU 8×8 RGB LED Driver Development Board. This indicates that the panel is on and ready to scan for object colours.
3. Prerequisite: Place a white sheet of paper 1-2 cm in front of the sensor. Then, tap the touchpad marked with “⏻” three times. This measurement will be saved as “true white” in EEPROM. This is a one-time step that is required to calibrate the readings from each channel in order to get accurate results.
4. Place an object or light source 1-2 cm away from the AS7341 Spectral Colour Sensor. Then, single-tap on the area marked “⏻.” The sensor will use its two built-in LEDs to illuminate the object, scan its colour, and lock it in. The colour will then be displayed on the panel light. To clear the colour, double-tap on the area marked “⏻.”
(Note: The AS7341 is a spectral sensor, not a phone camera, so it estimates colours well but rarely matches them exactly. Results depend on the distance from the object, ambient light and shadows, sensor gain and integration settings, and whether the surface is shiny, textured, or very dark. For the best results, hold the tile at a consistent distance of 1-2 cm, calibrate under the same lighting you plan to use, and expect close estimates rather than perfect matches.
5. Finally, it’s time to power on your AS7341-based ColourPicker Panel Light and expose it to different colored objects, materials, and clothes that you can find lying around at your home, and have fun with colour matching!
If you want to get creative and build your outer case without the hassle of 3D printing, follow these steps to create the outer covering for your colour picker tile:
1. Measure and cut the stencil sheet to cover the inside of the plastic container where the CJMCU 8×8 RGB LED Driver Development Board will be placed.
2. Insert the stencil layers inside the plastic container in the front as well as in the bottom. Add as many stencil layers as needed to achieve the desired diffused light effect.
3. Make an opening in the bottom of the container to expose the AS7341 spectral sensor. Wrap a strip of black paper around the perimeter of the AS7341 so that it can effectively scan the object’s colour.
4. Mark the area where the touch sensor will be secured with a tap under the plastic container with the symbol “⏻.”
5. Create an opening at the bottom of the box for the data cable.
6. Place all the electronic components inside and secure them in position using strong tape.
Program
/*
* AS7341 Based Colour Picker Panel Light
* Made by www.wiztaqnia.com
* Modified date: 23/11/2026
* Typical pin layout used:
* --------------------------------------------------------------------------------------------
* Signal CJMCU 8x8 AS7341 TTP223B Arduino
* RGB LED Driver Spectral Capacitive Touch Nano
* Development Board Color Sensor Switch Every
* --------------------------------------------------------------------------------------------
* 3.3V -- VCC VCC 3V3
* 5V 5V -- -- +5V
* GND(Ground) GND GND GND GND
* DIN (Data Input) DIN -- -- D6
* SIG (Signal Out) -- -- -- D2
* SCL (Serial Clock) -- SCL SCL A4
* SDA (Serial Data) -- SDA SDA A5
*/
#include <Wire.h>
#include <EEPROM.h>
#include <Adafruit_AS7341.h> // AS7341 Spectral Color Sensor driver
#include <Adafruit_NeoPixel.h> // 64 WS2812B LEDs driver
// ---------- Pin and hardware settings ----------
#define SIG 2 // TTP223B Capacitive Touch Switch's SIG pin
#define DIN 6 // CJMCU 8x8 RGB LED Driver Development Board's data pin
#define NUM_LEDS 64 // Number of LEDS in the WS2812B number of LEDs in the matrix
#define BOARD_LED_MA 70 // Brightness of AS7341 Spectral Color Sensor's Built in LEDs(mA)
// ---------- Timing settings (in milliseconds) ----------
#define DEBOUNCE_MS 50 // Ignore touch signal changes shorter than this as noise
#define TAP_WINDOW_MS 400 // Taps closer together than this count as one group
#define LOCK_GUARD_MS 2000 // After locking, ignore taps for 2 seconds
// ---------- Color settings ----------
#define MIN_TOTAL_LIGHT 100.0 // Total light below this means, its too dark to read
#define SAT_LEVEL 60000.0 // A band reading above this is saturated (too bright)
#define DARK_OFFSET 5.0 // Baseline noise removed from every band
// ---------- EEPROM settings ----------
#define CAL_MAGIC 0x7A14 // Valid calibartion saved address
#define CAL_ADDRESS 0 // Pre-Calibration address
#define LOCK_MAGIC 0x7A15 // Valid lock saved address
#define LOCK_ADDRESS 32 // Locked data address post calibration
struct CalData {
uint16_t magic; // Must equal CAL_MAGIC to be trusted
float calR, calG, calB; // White-balance factors for red, green, blue
};
struct LockData {
uint16_t magic; // Must equal LOCK_MAGIC
uint8_t r, g, b; // The locked color
uint8_t isLocked; // 1 = the color was locked when power went off
};
Adafruit_AS7341 color_picker;
Adafruit_NeoPixel matrix(NUM_LEDS, DIN, NEO_GRB + NEO_KHZ800); //Adafruit_NeoPixel(pixel_count,PWM_pin,pixels are wired for GRB bitstream+800 KHz bitstream)
const as7341_gain_t gain_settings[] = {AS7341_GAIN_64X, AS7341_GAIN_16X, AS7341_GAIN_4X};// gain_settings[]={64x gain: Highest sensitivity, suitable for dark objects,
//16x gain: Balanced sensitivity for general measurements, 4x gain : Lowest sensitivity, suitable for bright objects}
int gainIndex = 1;
// ---------- Lock state ----------
bool locked = false; // True when a color is held on the matrix
uint8_t lockedR = 0, lockedG = 0, lockedB = 0; // The held color
unsigned long lockedAt = 0; // When the color was locked (for the guard time)
// ---------- Touch state ----------
bool lastRaw = LOW; // Last raw reading from the touch pin
bool stableState = LOW; // Debounced (trusted) touch state
unsigned long lastChangeTime = 0; // When the raw reading last changed
int tapCount = 0; // Taps in the current group
unsigned long lastTapTime = 0; // Time of the most recent tap
float calR = 1.0, calG = 1.0, calB = 1.0; // 1.0 means no correction. Calibration changes these so white looks neutral.
// Set all LEDs to one color
void solidColor(uint8_t r, uint8_t g, uint8_t b) {
for (int i = 0; i < NUM_LEDS; i++) {
matrix.setPixelColor(i, matrix.Color(r, g, b));
}
matrix.show();
}
// Flash the whole matrix a number of times for feedback
void blinkAll(uint8_t r, uint8_t g, uint8_t b, int times, int onMs, int offMs) {
for (int t = 0; t < times; t++) {
solidColor(r, g, b);
delay(onMs);
solidColor(0, 0, 0);
delay(offMs);
}
}
// Soft blue breathing light for the idle state.
// It runs without blocking, so the touch pad is still checked on time.
void bluePulse() {
static unsigned long lastStep = 0;
static int level = 5;
static int dir = 1;
if (millis() - lastStep < 30) return;
lastStep = millis();
level += dir;
if (level >= 40) dir = -1;
if (level <= 5) dir = 1;
for (int i = 0; i < NUM_LEDS; i++) {
matrix.setPixelColor(i, matrix.Color(0, 0, level * 5)); // Turn all 64 LEDS of WS2812B 8x8 matrix 'blue'= power on
}
matrix.show();
}
void startReading() {
gainIndex = 1;
color_picker.setGain(gain_settings[gainIndex]);
color_picker.enableLED(true); //Turn ON AS7341 Spectral Color Sensor's Built in LEDs
delay(50);
}
void stopReading() {
color_picker.enableLED(false); //Turn OFF AS7341 Spectral Color Sensor's Built in LEDs
}
bool readRGB(float &r, float &g, float &b) {
for (int attempt = 0; attempt < 4; attempt++) {
if (!color_picker.readAllChannels()) return false;
// Read the visible channels
float f1 = color_picker.getChannel(AS7341_CHANNEL_415nm_F1); // violet
float f2 = color_picker.getChannel(AS7341_CHANNEL_445nm_F2); // blue
float f3 = color_picker.getChannel(AS7341_CHANNEL_480nm_F3); // cyan-blue
float f4 = color_picker.getChannel(AS7341_CHANNEL_515nm_F4); // green
float f5 = color_picker.getChannel(AS7341_CHANNEL_555nm_F5); // yellow-green
float f6 = color_picker.getChannel(AS7341_CHANNEL_590nm_F6); // orange
float f7 = color_picker.getChannel(AS7341_CHANNEL_630nm_F7); // red
float f8 = color_picker.getChannel(AS7341_CHANNEL_680nm_F8); // deep red
// Find the brightest band to check for saturation
float peak = max(max(max(f1, f2), max(f3, f4)), max(max(f5, f6), max(f7, f8)));
if (peak > SAT_LEVEL) {
if (gainIndex < 2) {
gainIndex++;
color_picker.setGain(gain_settings[gainIndex]); // Lower gain, then retry
continue;
}
return false;
}
// Group the bands into red, green, and blue as per weighted averages
b = (0.45 * f1) + (0.35 * f2) + (0.20 * f3);
g = (0.40 * f4) + (0.60 * f5);
r = (0.55 * f7) + (0.45 * f8);
// Remove the sensor's baseline noise so dark colors don't look tinted
b = max(0.0f, b - DARK_OFFSET);
g = max(0.0f, g - DARK_OFFSET);
r = max(0.0f, r - DARK_OFFSET);
// Apply the white-balance correction from calibration
r *= calR;
g *= calG;
b *= calB;
return true;
}
return false;
}
// Turn one reading into a displayable RGB color (0 to 255 per channel)
bool scanColor(uint8_t &outR, uint8_t &outG, uint8_t &outB) {
float r, g, b;
if (!readRGB(r, g, b)) return false; // Return false if no usable reading
float total = r + g + b;
if (total < MIN_TOTAL_LIGHT) return false; // Return false if too dark to trust
// Divide by the total so only the color balance remains, not the brightness
r /= total;
g /= total;
b /= total;
// Boost saturation: push each channel away from the average.
// This undoes the washed-out look from the broad sensor filters.
float mean = (r + g + b) / 3.0;
r = mean + (r - mean) * 1.35;
g = mean + (g - mean) * 1.35;
b = mean + (b - mean) * 1.35;
// Keep the values in range 0 to 1
r = constrain(r, 0.0, 1.0);
g = constrain(g, 0.0, 1.0);
b = constrain(b, 0.0, 1.0);
// Scale so the strongest channel is exactly 1.0 (the color looks vivid)
float m = max(r, max(g, b));
if (m > 0.0) {
r /= m;
g /= m;
b /= m;
}
// Gamma correction: makes the LED brightness look right to the eye
float gamma = 1.0 / 2.2;
outR = (uint8_t)(pow(r, gamma) * 255.0 + 0.5);
outG = (uint8_t)(pow(g, gamma) * 255.0 + 0.5);
outB = (uint8_t)(pow(b, gamma) * 255.0 + 0.5);
return true;
}
// Save the white-balance factors so they survive power-off
void saveCalibration() {
CalData d;
d.magic = CAL_MAGIC;
d.calR = calR;
d.calG = calG;
d.calB = calB;
EEPROM.put(CAL_ADDRESS, d);
}
// Load the saved factors at startup. If nothing valid is saved, keep 1.0.
void loadCalibration() {
CalData d;
EEPROM.get(CAL_ADDRESS, d);
if (d.magic != CAL_MAGIC) return;
if (d.calR <= 0 || d.calG <= 0 || d.calB <= 0) return;
calR = d.calR;
calG = d.calG;
calB = d.calB;
}
// Save the lock so the AS7341 Based Color Picker Panel Light comes back on the same color after power-off
void saveLock() {
LockData d;
d.magic = LOCK_MAGIC;
d.r = lockedR;
d.g = lockedG;
d.b = lockedB;
d.isLocked = locked ? 1 : 0;
EEPROM.put(LOCK_ADDRESS, d);
}
// At power-up, restore the last locked color if there was one
void loadLock() {
LockData d;
EEPROM.get(LOCK_ADDRESS, d);
if (d.magic != LOCK_MAGIC || d.isLocked != 1) return;
lockedR = d.r;
lockedG = d.g;
lockedB = d.b;
locked = true;
lockedAt = millis() - LOCK_GUARD_MS; // Guard time is already over, so a tap unlocks at once
}
// Single tap: scan the object and hold its color until the next tap
void scanAndLock() {
startReading(); // Initialise the scan
blinkAll(255, 200, 0, 3, 100, 100); // Blink all 64 LEDS of WS2812B 8x8 matrix 'yellow'= scanning state
uint8_t r, g, b;
bool ok = scanColor(r, g, b);
stopReading(); // Turn ON AS7341 Spectral Color Sensor's Built in LEDs
if (ok) {
lockedR = r;
lockedG = g;
lockedB = b;
locked = true;
lockedAt = millis();
saveLock();
solidColor(lockedR, lockedG, lockedB);
} else {
blinkAll(255, 0, 0, 3, 120, 100); // Blink all 64 LEDS of WS2812B 8x8 matrix 'red' = failed to read
locked = false;
}
}
// Tap after the guard time while locked and release the color
void unlock() {
locked = false;
saveLock();
solidColor(0, 0, 0);
}
// Triple tap: measure a white card and store the correction
void calibrateWhite() {
float r, g, b;
if (!readRGB(r, g, b)) {
blinkAll(255, 0, 0, 3, 120, 100); // Blink all 64 LEDS of WS2812B 8x8 matrix 'red' = failed to read
return;
}
float avg = (r + g + b) / 3.0;
if (avg < 1.0) { // Blink all 64 LEDS of WS2812B 8x8 matrix 'red' = failed to read
blinkAll(255, 0, 0, 3, 120, 100);
return;
}
// Each factor scales its channel so all three match the average.
// A white card then reads as neutral white.
calR = avg / r;
calG = avg / g;
calB = avg / b;
saveCalibration();
blinkAll(255, 255, 255, 3, 150, 100); // Blink thrice all 64 LEDS of WS2812B 8x8 matrix 'White' = save calibration
locked = false;
}
// Decide what to do after the tap window closes
void handleTaps(int count) {
if (count >= 3) {
startReading(); // Turn ON AS7341 Spectral Color Sensor's Built in LEDs
calibrateWhite();
stopReading();
saveLock(); // Calibration may clear the lock, so save that
if (locked) solidColor(lockedR, lockedG, lockedB); // Calibration failed: show the held color again
} else if (locked) {
// Ignore taps during the guard time so an accidental touch doesn't unlock
if (millis() - lockedAt >= LOCK_GUARD_MS) {
unlock(); // Tap after the guard time means unlock
}
} else {
scanAndLock(); // Single tap means scan and lock
}
}
void setup() {
pinMode(SIG, INPUT); // TTP223B Capacitive Touch Switch's SIG pin, HIGH while Touch pad is touched
Wire.begin(); // Initialise I2C communication
matrix.begin(); // Initiate the CJMCU 8x8 RGB LED Driver Development Board
matrix.setBrightness(30); // Set the brightness of the pixels. The range of brightness for each WS2812B pixel is 0 to 255.
solidColor(0, 0, 0); // Turn OFF all 64 LEDS of WS2812B 8x8 matrix
if (!color_picker.begin()) { // Initialte I2C coomunication with AS7341 Spectral Color Sensor (Slave address of AS7341 Spectral Color Sensor is 0x39 )
while (1) {
blinkAll(255, 0, 0, 1, 150, 150); // Blink all 64 LEDS of WS2812B 8x8 matrix 'red' = failed to read
}
}
color_picker.setLEDCurrent(BOARD_LED_MA); // Set the Brightness of AS7341 Spectral Color Sensor's Built in LEDs(mA). The opernting current range for both leds combined is 20mA to 70mA.
color_picker.enableLED(false); // Turn OFF AS7341 Spectral Color Sensor's Built in LEDs
color_picker.setATIME(20); // Integration time as to how long to look
color_picker.setASTEP(599); // Step size to fine-tune the integration time
color_picker.setGain(gain_settings[gainIndex]); // Initialise the gain. Higher gain reads dark objects better; lower gain avoids saturation.
loadCalibration(); // Restore saved white balance, if any
loadLock(); // Restore the last locked color, if any
if (locked) solidColor(lockedR, lockedG, lockedB);
}
void loop() {
// --- Step 1: debounce the touch pad ---
bool raw = digitalRead(SIG);
if (raw != lastRaw) {
lastChangeTime = millis();
lastRaw = raw;
}
// Accept the change only if it stayed steady for DEBOUNCE_MS
if ((millis() - lastChangeTime) > DEBOUNCE_MS && raw != stableState) {
stableState = raw;
if (stableState == HIGH) {
tapCount++;
lastTapTime = millis();
}
}
// --- Step 2: when the tap window has closed, act on the count ---
if (tapCount > 0 && (millis() - lastTapTime) > TAP_WINDOW_MS) {
int count = tapCount;
tapCount = 0;
handleTaps(count);
}
// --- Step 3: display breathe blue while idle (not locked, no taps pending) ---
if (!locked && tapCount == 0) {
bluePulse();
}
}
Output
This post was inspired by https://techtalkies.in/2024/02/20/esp8266-color-picker-for-pc/
References:-
- https://www.adafruit.com/product/4698?srsltid=AU7gw4VfGB5oPQr9Y5nmFWobaFw1bY8UAcWmNqTpE0whISQ5Euy-K0Bx
- https://www.waveshare.com/wiki/AS7341_Spectral_Color_Sensor
- https://techatronic.com/what-is-ttp223-touch-sensor-touch-sensor-ttp223-working/
- https://zbotic.in/as7341-spectral-sensor-measure-light-colors-with-arduino/?srsltid=AYCX9vLwj5xsgIM7QFKeww48ol4B2pEBrDf16BjodN4pBkydwuBX_NCB
- https://www.sparkfun.com/qwiic?srsltid=AYCX9vJbmDXKdi9bEltKx39LpNPg7Yg8UiJYxd6BN2TRVtp3bzb7TOMz
- https://cdn-learn.adafruit.com/downloads/pdf/introducing-adafruit-stemma-qt.pdf
Noor Fatimah Iqbal Husain is the visionary behind Wiztaqnia. As a hardware engineer passionate about hands-on learning, she simplifies complex electronics and technology through engaging content. When not writing or working with circuits, she explores emerging technologies and their real-world benefits. Connect with her to deepen your understanding of technology and electronics.