AI Study Lamp - Helps Reduce Distractions
by Arpan Mondal in Circuits > Microcontrollers
316 Views, 9 Favorites, 0 Comments
AI Study Lamp - Helps Reduce Distractions







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
Prepare the AI Module


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





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



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



This code requires the Seed SSCMA library. To install the Seeed SSCMA Arduino library, follow these steps:
- 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.
- Add the Library to Arduino IDE
- 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.
Downloads
Solder a Wire for the LED Strip



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:
- Connect SCL on the Vision AI module to SCL on the Arduino.
- Connect SDA on the Vision AI module to SDA on the Arduino.
- Connect VCC on the Vision AI module to the Arduino's 3.3V power pin.
- Connect GND on the Vision AI module to the Arduino's GND pin.
Making the Lamp




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




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



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
- LED_PIN: The GPIO pin used to communicate with the LED strip.
- LED_COUNT: Total number of LEDs in the strip.
- Color definitions: RGB values for "warm white" and "deep red".
- DETECT_DELAY: How long (in milliseconds = 10 seconds) the phone must be continuously detected before changing the light to red.
Initialization
- strip: Initializes the LED strip object.
- Infer: Handles communication with the AI module.
- phoneSeenAt: Stores the timestamp when a phone was first detected.
- isInRedState: Tracks whether the current light color is red.
setup()
- Initializes the AI module and LED strip.
- If the AI module fails to start, the program halts.
- LEDs are set to warm white initially.
loop() – Core Logic
Inference and Phone Detection
- Infer.invoke() performs a frame-by-frame analysis.
- Infer.boxes().size() returns the number of detected objects.
- A phone is considered detected if at least one bounding box exists.
Transition to Red After Delay
- If a phone is seen, the timestamp is recorded.
- If the phone remains detected for 10+ seconds (millis() - phoneSeenAt >= DETECT_DELAY), the LEDs fade to red.
- The flag isInRedState prevents redundant transitions.
Revert to Warm White
- If the phone disappears, phoneSeenAt is reset.
- If the LEDs are red, they smoothly fade back to warm white.
Color Control Helpers
Instant Color Fill
- Sets all LEDs to a specific color instantly.
Smooth Color Transition
- Gradually fades from one color to another over 2 seconds (100 steps × 20 ms).
Conclusion



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: