Scan Your Hand Meet Your LEGO Minifigure
by rirmak in Circuits > Arduino
53 Views, 0 Favorites, 0 Comments
Scan Your Hand Meet Your LEGO Minifigure


Have you ever visited a LEGO store and used their fun hand scanner that "reads your palm" and shows you a random LEGO minifigure? In this project, I recreated that magical experience using Arduino!
This interactive scanner detects a hand placed above the sensor and randomly displays a LEGO minifigure suggestion—just like the ones found in official LEGO shops. It’s a great combination of technology and play, perfect for exhibitions, classrooms, or your own DIY LEGO display.
With a few basic components (an Arduino, IR or ultrasonic sensor, and a display), you can build your own Minifig Fortune Teller and add a playful surprise to any space.
Supplies
Arduino Uno – The main controller of the project
ST7735 1.8" TFT LCD (160x128) – Color display used to show LEGO minifigure images
ST7735 1.8" TFT LCD Wiring


ST7735 1.8" TFT LCD Wiring
The ST7735 1.8" TFT LCD module is connected to the Arduino Uno using SPI communication.
The VCC (or +) pin of the display is connected to 5V on the Arduino to provide power, and the GND pin is connected to GND.
The CS (Chip Select) pin is connected to digital pin 10,
the RESET (RST) pin to digital pin 9,
and the DC (Data/Command) pin to digital pin 8.
For SPI communication, the MOSI (SDA) pin is connected to digital pin 11,
and the SCK pin to digital pin 13.
The LED pin, which controls the backlight, can be connected directly to 5V or 3.3V, optionally through a current-limiting resistor. This setup allows the Arduino to control the display and render images from the SD card.
SD Card Module Wiring
The SD card module communicates with the Arduino Uno using the SPI protocol.
The VCC pin of the module is connected to the 5V pin on the Arduino to provide power, and the GND pin is connected to GND.
For SPI communication, the MOSI pin is connected to digital pin 11,
the MISO pin to digital pin 12,
and the SCK pin to digital pin 13.
The CS (Chip Select) pin, which allows the Arduino to select and communicate with the SD card, is connected to digital pin 4.
This configuration enables the Arduino to read BMP image files stored on the SD card and display them on the TFT screen.
Required Libraries
TFT.h lets us control the TFT display.
SPI.h is required because both the TFT screen and SD card use SPI communication.
SD.h allows us to access image files stored on an SD card.
Defining Pin Connections
These #define statements assign the Arduino pins that connect to the TFT and SD card:
TFT_CS: Chip Select pin for the display
TFT_RST: Reset pin for the display
TFT_DC: Data/Command select for display communication
SD_CS: Chip Select pin for the SD card
Setup Functions
What happens here:
The serial monitor is started for debugging purposes.
The TFT screen is initialized and rotated for correct orientation.
The SD card is initialized. If it fails, the program stops.
The screen is cleared with a black background
Loop Function: Display BMP Images
A for loop runs from 1 to 5 (adjustable).
It creates filenames like "001.bmp", "002.bmp", etc.
This matches your image filenames stored on the SD card.
Calls the loadBitmap() function to draw the image.
Shows each image for 3 seconds.
Clears the screen between images.
LoadBitmap() – Custom Function to Read and Display BMP Files
Tries to open the BMP file from the SD card.
Checks if the file is a valid BMP format (must start with 'B' and 'M').
Reads total file size (not critical for drawing, but helpful for verification).
Gets the width and height of the image from the BMP header.
Gets the size of the pixel data
Calculates how to center the image on the screen.
Reading Pixels and Drawing to the Screen
Starts reading pixel data from the BMP file.
Reads BGR color bytes for each pixel (standard for BMP).
Converts them to 16-bit color using .Color565().
Draws each pixel to the screen, centered.
Final Cleanup
Closes the file and returns success.
How to Improve This Project
You can improve this project by adding an LED push button that mimics the function of a hand scanner, enhancing the interactivity and making the experience more engaging for users