AI Study Lamp - Helps Reduce Distractions

by Arpan Mondal in Circuits > Microcontrollers

316 Views, 9 Favorites, 0 Comments

AI Study Lamp - Helps Reduce Distractions

YouTube Thumbnail.png
AI study lamp that improves focus
VID_20250611_1546229062-ezgif.com-optimize.gif
IMG_20250611_154951084.jpg
Screenshot_20250611_194506.png
IMG_20250611_155001520.jpg
IMG_20250611_154112712.jpg

This fun project idea came to me during a conversation with a colleague at work. He was complaining about how his kids use their smartphones while studying, and end up doomscrolling after one notification pops up. I jokingly said, “What if the study lamp could get angry when that happens and alert you somehow?”

Later that day, after getting home from work, I kept thinking about the idea and decided to build a prototype. The result is this lamp with an AI camera trained to detect smartphones. As soon as it spots a phone on the desk, the lamp shifts from a soft warm white to a harsh deep red, straining the eyes and making it harder to look at the screen (kinda). Once the phone is put away, the lamp returns to its usual warm white glow.

Sure, it might be a bit of an overkill device, but I wanted to see if the concept could actually work. And in this Instructable, I’ll show you exactly how I built it. This is going to be fun!

Supplies

Grove vision AI module V2 Purchase

Arduino / Esp32 microcontroller Purchase

WS2812B LED strip Purchase

Flexible tubing for the lamp neck

Aluminium / Iron wire

Soldering Iron

Wire strippers

Glue, Scissors, Tape

Prepare the AI Module

FCHU595M3VM0LZD.jpg
F9R2WJ6M3VM0C90.jpg

The Grove Vision AI module is a handy little device. It can be trained to detect all sorts of things. Humans, pets, gestures, toilets (yes, really!), and much more. Check out some of the pre-trained models here: Sensecraft AI.

To get started, I connected the cable to the AI module as shown in the first image.

Next, I plugged the other end of the cable into the Raspberry Pi camera, as shown in the second image.

Now we’re ready to start uploading the model.

Upload the AI Model

Screenshot_20250611_195824-1.png
Screenshot_20250611_195911.png
Screenshot_20250611_195934.png
Screenshot_20250611_195953.png
Screenshot_20250611_200019.png

I went to the Sensecraft AI models page and searched for "cell phone detection."

This website contains pre-trained models that can be uploaded to the Grove AI module. If you don’t find the model you’re looking for, you can even train your own by uploading images of specific categories. However, for this use case, I found a suitable model already available on the site.

If you’re following along, make sure to use only the models designed for the Grove Vision AI Module v2!

Next, connect the AI module to your PC using a USB-C cable, and click "Connect Device."

Your browser may prompt you to choose a device—select the correct port (there should only be one) and confirm.

Refer to the images above for the full step-by-step process I followed.


Part of this project was made in collaboration with Justway


Justway offers a comprehensive suite of solutions, including CNC machining, 3D printing, sheet metal fabrication, injection molding, and urethane casting, offering rapid prototyping and mass production solutions.

Get your project 3D printed by Justway's 3D printing service. Head over to Justway's 3D printing service and select 3D printing.

Right now, you can also take advantage of Justway's Summer Cashback Event, where you get 15% cashback on all successful orders placed between June 1 and August 31, 2025 (UTC). This offer applies to the actual paid amount and is a great way to save on your manufacturing needs, whether for prototyping or mass production

Don't miss this opportunity to get high-quality manufacturing services while enjoying significant cashback rewards.

Test the Model

Screenshot 2025-06-11 190438.png
Screenshot 2025-06-11 190629.png
Screenshot 2025-06-11 190528.png

After the model finished uploading, I could see the camera feed on the webpage. Next to it, there’s some text that shows what the AI module is detecting.

I pointed the camera at my desk, where my cell phone was lying. I tried pointing it from different angles, and each time the phone was successfully detected.

As you can see in the images, the camera feed draws a red box around the phone as soon as it’s detected. Later, we’ll write code to check for the presence of this red box to confirm that the module has detected a phone.

The number displayed on top of the red box indicates how confident the model is about its recognition.

Program the Microcontroller

F4QCZJ9M3VM0WCB.jpg
Screenshot 2025-06-11 192825.png
Screenshot 2025-06-11 192901.png

This code requires the Seed SSCMA library. To install the Seeed SSCMA Arduino library, follow these steps:

  1. Go to the official Seeed GitHub repository for the SSCMA library: Seeed_Arduino_SSCMA and download the latest version as a ZIP file by clicking on Code > Download ZIP.
  2. Add the Library to Arduino IDE
  3. Open your Arduino IDE, then go to Sketch > Include Library > Add .ZIP Library... and select the ZIP file you just downloaded.

This code checks if a cell phone is detected and remains visible for at least 10 seconds, it triggers a smooth colour transition on a WS2812 LED strip from warm white to deep red, indicating the detection of a cell phone. If the cell phone is no longer detected, the LEDs transition back to warm white. The system continuously monitors the camera feed and updates the LED colour accordingly. I have done a detailed code walkthrough in the end of this instructable.

My code is attached below.

Solder a Wire for the LED Strip

FD2JMA1M3VM0RX9.jpg
FX47VU6M3VM0CB2.jpg
FGQG6X0M3VM0CBN.jpg

I Pushed the Xiao into the female headers in the AI module, Making sure the USB-C port in the Xiao is facing the same direction as the one on the AI module.

Then I soldered one wire from D2 of the Xiao. I did it on the AI module itself, as it was easier. This will be the data pin to the LED strip.

In case you're using a different microcontroller like an arduino, you can instead wire it up to the grove module.

Connect the Grove Vision AI V2 module to the Arduino board's default I2C interface using the provided 4-pin Grove cable as follows:

  1. Connect SCL on the Vision AI module to SCL on the Arduino.
  2. Connect SDA on the Vision AI module to SDA on the Arduino.
  3. Connect VCC on the Vision AI module to the Arduino's 3.3V power pin.
  4. Connect GND on the Vision AI module to the Arduino's GND pin.


Making the Lamp

IMG_20250611_141830515.jpg
IMG_20250611_142550996.jpg
IMG_20250611_141848538.jpg
IMG_20250611_150439560.jpg

You can find plenty of 3D models on Thingiverse if you want to 3D print the lamp. However, I built mine using some materials I had lying around the house.

For the neck, I used white tubing and inserted an aluminum wire inside to make it adjustable. For the base, I used a plastic lid, made a hole in it, inserted the tubing, and glued it in place.

I later added some weight to the base to make it more stable.

The Lamp Head

IMG_20250611_144213476.jpg
IMG_20250611_144332261.jpg
IMG_20250611_145356054.jpg
IMG_20250611_145634521.jpg

For the head of the lamp, I glued some matte sticker paper onto a tissue paper roll.

Then, I used a strip of 10 WS2812 LEDs, which can be color-adjusted. I glued the LED strip inside the lamp head.

To connect it to the AI module, I repurposed a white USB cable and chopped the ends off. It contains four wires, which is perfect for wiring up the WS2812 LEDs.

Assembly

IMG_20250611_150244140.jpg
IMG_20250611_150508960.jpg
IMG_20250611_152659521.jpg

Finally, I glued the neck to the lamp head and routed the wire through the back of the head.

While a 3D-printed lamp could be designed to house the AI module inside, this is just a prototype. So I chose to keep the AI camera system external to keep the build simpler.

I mounted the AI module on a shelf above the study table, positioning it, so the camera looks directly down at the tabletop. Then, I connected the wire from the lamp to the AI module.

Code Walkthrough

This code checks if a cell phone is detected and remains visible for at least 10 seconds, it triggers a smooth colour transition on a WS2812 LED strip from warm white to deep red, indicating the detection of a cell phone. If the cell phone is no longer detected, the LEDs transition back to warm white. The system continuously monitors the camera feed and updates the LED colour accordingly.


Configuration and Constants

#define LED_PIN D2
#define LED_COUNT 10
#define WARM_WHITE_R 255
#define WARM_WHITE_G 244
#define WARM_WHITE_B 229
#define DEEP_RED_R 128
#define DEEP_RED_G 0
#define DEEP_RED_B 0
#define DETECT_DELAY 10000UL
  1. LED_PIN: The GPIO pin used to communicate with the LED strip.
  2. LED_COUNT: Total number of LEDs in the strip.
  3. Color definitions: RGB values for "warm white" and "deep red".
  4. DETECT_DELAY: How long (in milliseconds = 10 seconds) the phone must be continuously detected before changing the light to red.


Initialization

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
SSCMA Infer;

unsigned long phoneSeenAt = 0;
bool isInRedState = false;
  1. strip: Initializes the LED strip object.
  2. Infer: Handles communication with the AI module.
  3. phoneSeenAt: Stores the timestamp when a phone was first detected.
  4. isInRedState: Tracks whether the current light color is red.


setup()

if (!Infer.begin()) { ... }
strip.begin();
fillColor(WARM_WHITE_R, WARM_WHITE_G, WARM_WHITE_B);
  1. Initializes the AI module and LED strip.
  2. If the AI module fails to start, the program halts.
  3. LEDs are set to warm white initially.


loop() – Core Logic


Inference and Phone Detection

if (!Infer.invoke()) {
size_t n = Infer.boxes().size();
bool phoneDetected = (n > 0);
  1. Infer.invoke() performs a frame-by-frame analysis.
  2. Infer.boxes().size() returns the number of detected objects.
  3. A phone is considered detected if at least one bounding box exists.


Transition to Red After Delay

if (phoneDetected) {
if (phoneSeenAt == 0) {
phoneSeenAt = millis();
} else if (!isInRedState && millis() - phoneSeenAt >= DETECT_DELAY) {
smoothTransition(...); // warm white → red
isInRedState = true;
Serial.println("→ RED");
}
}
  1. If a phone is seen, the timestamp is recorded.
  2. If the phone remains detected for 10+ seconds (millis() - phoneSeenAt >= DETECT_DELAY), the LEDs fade to red.
  3. The flag isInRedState prevents redundant transitions.


Revert to Warm White

} else {
phoneSeenAt = 0;
if (isInRedState) {
smoothTransition(...); // red → warm white
isInRedState = false;
Serial.println("→ WARM WHITE");
}
}
  1. If the phone disappears, phoneSeenAt is reset.
  2. If the LEDs are red, they smoothly fade back to warm white.


Color Control Helpers


Instant Color Fill

void fillColor(uint8_t r, uint8_t g, uint8_t b)
  1. Sets all LEDs to a specific color instantly.


Smooth Color Transition

void smoothTransition(uint8_t r0, uint8_t g0, uint8_t b0,
uint8_t r1, uint8_t g1, uint8_t b1)
  1. Gradually fades from one color to another over 2 seconds (100 steps × 20 ms).


Conclusion

F8NVKF6MBP3WBM4.gif
FQUCMU0MBP3UUZE.jpg
FHGVKZ7MBP3UUXV.jpg

So that's all! My little “angry lamp” prototype that’s not afraid to call out your phone habits!

It might be a bit over the top, but hey, if a harsh red light can make you think twice before doomscrolling, it’s already doing its job. It was a fun project to try out, even if it’ll never be a real product. I enjoyed building it, and that’s what matters most.

As an engineer, you build a lot of useful things. But if you let the child in you create something crazy once in a while, who knows, maybe one day that crazy device will be revolutionary!

If you had fun reading how I built this crazy lamp, here are a few other crazy stuff I experimented with:

Toothbrush Alarm Clock

Fake Guard Dog

AI Scarecrow

Floor Mat Alarm Clock

My Own Board Game!