Blog Home

This desk lamp automatically adjusts its brightness using AI on an Arduino UNO

Arduino TeamJune 7th, 2024

When you hear about all of the amazing things being accomplished with artificial intelligence today, you probably assume that they require a massive amount of processing power. And while that is often true, there are machine learning models that can run on the edge — including on low-power hardware like microcontrollers. To prove that, Shovan Mondal built this AI-enhanced desk lamp.

Mondal’s goal with this project was to demonstrate that AI (specifically machine learning) can be easy to implement on affordable and efficient hardware, such as an Arduino UNO Rev3 board. Here, the ML model adjusts the brightness of the lamp’s LED proportionally to the ambient light in the area as detected by an LDR (light-dependent resistor). The lamp body is heavy cardstock paper. 

It would be possible to program this behavior explicitly with set thresholds or a manually created formula. But a trained ML model can do the same job without explicit instructions. The training process is simply subjecting the lamp to different lighting conditions and manually adjusting the brightness to suit them. That produces a series of data pairs consisting of the LDR and LED brightness values. 

In CSV format, that data can be used to train a linear regression model provided with scikit-learn. That then produces a formula and values that will reproduce the data seen in the training set. The output can then set the LED brightness. 

In this case, that formula is very simple, because it only has to account for two variables with a direct relationship. But much more complex relationships are possible, as are ML models that perform tasks more challenging than linear regression.

Boards:Uno
Categories:Arduino