Night Reading Tracking Light | Recommended Works by DF Community

Night Reading Tracking Light | Recommended Works by DF Community

Night Reading Tracking Light | Recommended Works by DF Community

Scan the QR code to watch the demo video

What can the HuskyLens visual sensor do? It can recognize faces, colors, tags, and paths, and can track objects visually. With Husky, it becomes very easy for you to let Arduino see or recognize something.

This application is a device for reading at night. It uses the color recognition function of Husky to recognize books, informs Arduino of the recognition information, and then Arduino drives the servo to achieve lighting that follows the book, making it convenient to read at night.

Night Reading Tracking Light | Recommended Works by DF Community

In today’s world, establishing the concept of lifelong learning is very necessary. I enjoy leaning against the bed at night to read and supplement my knowledge, but sometimes while I am reading, my roommate has already gone to sleep. To avoid disturbing others, I can’t turn on the big light and can only use a small range of lighting. However, ordinary small-range lighting is fixed, which is the problem I want to solve. I want to create a light that can track the movement of the book, which is also a type of work that makers can do and are good at.This kind of customized solution that meets personal special needs is where we, as makers, can shine and heat up.

I considered using a cold light panel clipped behind the book page to provide backlight for reading, but after testing it, I found the effect to be awkward, as the text on the back and the front overlapped and became unreadable.I forgot to take a photo of the actual effect, but I simulated it using the LED on my phone, and the effect was similar, as shown in Figure 1.

Night Reading Tracking Light | Recommended Works by DF Community

Figure 1: Light projected from behind the book page, causing the text on the back and front to overlap

Production Idea

In the color recognition mode of Husky, first learn the color of the book page. After that, switch to color recognition mode. Husky will check if the color of the book appears in the current image. If the book’s color appears, Husky will output the recognized position information, which is essentially a bounding box. The information that can be directly used here includes the center coordinates of this box and its length and width. We can only use the center coordinates of the box to complete this production, using the distance of these coordinates from the center point of the image (160, 120) to drive the servo to rotate, ensuring that the light always shines on the book page.

Details

(1) I tried to use serial communication between Husky and Arduino Uno, but the servo would shake back and forth for unknown reasons, so here I used I2C communication.(2) There may be many similar colors in the image, and generally, small color blocks are recognized as the book, so I used an if statement to filter out the interference from these small color blocks and only process results with larger recognition areas.(3) I did not use other lights, directly using the LED on the back of Husky to simulate the light source (see Figure 2).(4) I only used one dimension of tracking, meaning I only used one servo to control Husky’s left and right rotation. In practice, it may be necessary to consider using two servos to achieve simultaneous tracking left-right and up-down for better results.

Night Reading Tracking Light | Recommended Works by DF Community

Figure 2: Using the LED on Husky to simulate the light source

Installation

(1) First, take out Husky. Inside the box, there is a metal bracket, which should be fixed with the provided screws.

Night Reading Tracking Light | Recommended Works by DF Community

(2) Install a servo horn on the servo, then stick it to the metal bracket of Husky.

Night Reading Tracking Light | Recommended Works by DF Community

(3) Finally, stick the servo onto a phone holder.

Night Reading Tracking Light | Recommended Works by DF Community

(4) Let Husky learn the color of the book.

Night Reading Tracking Light | Recommended Works by DF Community

(5) The hardware connection is very simple. Husky connects to the I2C interface of the Arduino Uno expansion board, and the servo connects to the D5 pin of the Arduino Uno expansion board.

Night Reading Tracking Light | Recommended Works by DF Community

Code Section

Night Reading Tracking Light | Recommended Works by DF Community

Figure 3: Part of the program to drive the servo

As shown in Figure 3, there is a judgment at the beginning: (result.width+result.height) >=80. This statement filters out other small blocks of similar colors in the image. Next, it checks if the book is not in the centered position of the image. If the center of the recognized book’s bounding box is more than 20 pixels away from the center of the image, the servo will rotate 3°. Since the servo I used is a 180° servo, I set a limit on its rotation. Once it reaches the limit, it will stop rotating. After uploading the code to the Arduino Uno, the program’s effect is: if the book moves to the right, the servo controls Husky to turn to the right; if the book moves to the left, the servo controls Husky to turn to the left (see Figure 4).

Night Reading Tracking Light | Recommended Works by DF Community

Night Reading Tracking Light | Recommended Works by DF Community

Figure 4: Servo controls Husky to follow the book’s rotation

Night Reading Tracking Light | Recommended Works by DF Community

Science Popularization · Innovation · Practice · Sharing

Long press to scan the QR code and follow “Wireless Radio” magazine

Leave a Comment

×