Distance Sensing Light Up Tangled Lantern Painting
205 Views, 3 Favorites, 0 Comments
Distance Sensing Light Up Tangled Lantern Painting

Hi, my name is Mary and I have created a distance-sensing light-up canvas that depicts a scene from one of my favorite Disney movies- Tangled! Lanterns play a large role in the movie and I wanted to incorporate that in my painting by bringing them to life with neopixels. As you walk by the painting, the distance sensor picks up your movement and lights up the strand in 5 random colors. Additionally, if you click the button on the lantern right above the boat, the chorus line of the song from this scene in the movie plays.
Supplies



You will need the following supplies to complete this project:
Painting Supplies
- Gesso https://www.michaels.com/golden-gesso-white/D045554S.html?r=g&srsltid=AR5OiO34tBoILMLqtWw2MqjYFTbwniaJ1oKzEUMKC8foGPb4pFdKi7P99D8
- Pencil/White charcoal
- Stretched canvas (I used a 12x16" canvas) https://www.michaels.com/6pk-12x16-super-value-canvas-by-artists-loft-necessities/10276631.html
- Acrylic paint
- Brushes
- Tape
- Clear Gorilla Glue gel https://www.amazon.com/Gorilla-Super-Glue-gram-Clear/dp/B082XGL21J/ref=asc_df_B082XGL21J/?tag=hyprod-20&linkCode=df0&hvadid=416671023321&hvpos=&hvnetw=g&hvrand=8103563515670650850&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9002065&hvtargid=pla-870614969959&psc=1&tag=&ref=&adgrpid=90730998621&hvpone=&hvptwo=&hvadid=416671023321&hvpos=&hvnetw=g&hvrand=8103563515670650850&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9002065&hvtargid=pla-870614969959
Laser cutter materials
- Adobe Illustrator
- 1/8" clear acrylic
Coding Materials
- Circuit Playground Bluefruit (with CircuitPython installed) https://www.adafruit.com/product/4333
- Mu Editor https://codewith.mu/en/download
- NeoPixel strand, 20 LEDs https://www.adafruit.com/product/3631?gclid=CjwKCAjwh4ObBhAzEiwAHzZYU1oI25s7xR90g8xLoKGFaylLVsG0NuYQj3ziC7UynVCYLGcK-fn7ExoCeX0QAvD_BwE
- 3 nuts and bolts (to attach strand to CPB)
- Time of flight distance sensor w/ STEMMA-QT cable https://www.adafruit.com/product/3967#:~:text=The%20Adafruit%20VL53L1X%20Time%20of,source%20and%20a%20matching%20sensor.
- 4 alligator clips https://www.adafruit.com/product/4100?gclid=CjwKCAjwh4ObBhAzEiwAHzZYU5qiFS6ALnO2a4C9ha_MdKBcRLzKAdBWfSsdPLc737UQOAyj475K-xoCwA0QAvD_BwE
- Battery pack with 3 AAA batteries https://www.adafruit.com/product/727?gclid=CjwKCAjwh4ObBhAzEiwAHzZYU0ANdg3pK4NeHItoLZKZSiE43rQ-y16nqCVavSlVI0UWE9PRWjD5zxoC__8QAvD_BwE
Paint Your Canvas!



The first step is to prime your canvas with some gesso- this will help make your colors vibrant and creates a great base to work with. Then find your reference photo so you have a starting point for your painting. Since I was creating the scene from Tangled, I used a screenshot from the movie as my reference. I went right into painting the blue and purple background for the sky, mixing in some water on the lighter colors to give it that washed effect that makes it appear more cartoony or dream-like. If you would like, now you can sketch your image lightly using either a normal pencil or a white charcoal pencil (which is what I normally prefer.) I went back in with the gesso to prime the focal points of the painting and then went in with my colors. Make sure to leave time in between as you layer colors on top.
Laser Cut & Glue
.jpg)



Now we are going to laser cut the sun used to house the distance sensor and the diamonds that will embellish the painting. These clear acrylic pieces will add further dimension to the project and are also another way to diffuse the light from the neopixel strand. I found an image online of an outline of the Tangled sun and brought that into Adobe Illustrator. I also created diamonds in illustrator using the shape tool. My AI file contains a few different suns as I wasn't sure what size would work best. Depending on what size canvas you use, you may need to play around with your embellishments and how large you make them.
Once you have completed your laser cutting, it's time to add them to your painting! I tried several different types of glue but was struggling to find something sturdy enough to hold the acrylic to the painted canvas. Eventually, I found that clear Gorilla glue worked very well. I applied a small amount of glue to the back of the shape, then placed it immediately onto the canvas. Be sure to wipe up any excess glue with a paper towel before it dries. Repeat this step for all of the embellishments you may have. I finished by attaching the sun to the back of the canvas, then painted the back of it yellow to add some more color.
Code
import board, time, neopixel, random, digitalio,adafruit_vl53l1x,math
from rainbowio import colorwheel
from audiopwmio import PWMAudioOut as AudioOut
from audiocore import WaveFile
path="sounds/"
#set up speaker
speaker=digitalio.DigitalInOut(board.SPEAKER_ENABLE)
speaker.direction= digitalio.Direction.OUTPUT
speaker.value= True
audio= AudioOut (board.SPEAKER)
#make list of lantern colors
YELLOW = (255, 253, 15)
BLACK = (0, 0, 0)
WHITE=(255,255,255)
AMBER=(255, 100, 0)
GOLD=(255, 222, 30)
ORANGE=(255,127,0)
colors=[YELLOW,WHITE,AMBER,GOLD,ORANGE,BLACK]
#set up sensor
i2c = board.I2C()
distance_sensor = adafruit_vl53l1x.VL53L1X(i2c)
distance_sensor.distance_mode = 1
distance_sensor.timing_budget = 100
distance_sensor.start_ranging()
#set up strip
strip_pin=board.A1
strip_num_of_lights= 20
strip= neopixel.NeoPixel(strip_pin, strip_num_of_lights, brightness=1,auto_write=True)
WHITE=(255,255,255)
BLACK=(0,0,0)
#set up button
button_A=digitalio.DigitalInOut(board.BUTTON_A)
button_A.switch_to_input(pull=digitalio.Pull.DOWN)
#values needed for while true loop
last_random=-1
MAX_DISTANCE = 100
MIN_DISTANCE = 10
cm_per_light = (MAX_DISTANCE-MIN_DISTANCE)/strip_num_of_lights
#define function to randomly animate lights
def animate_lights():
global random_number
global random_color
global last_random
global COLOR
random_number= random.randint(0,9)
random_number_strip=random.randint(0,19)
random_color=random.randint(0,5)
COLOR= colors[random_color]
while last_random == random_number:
random_number= random.randint(0,9)
strip[random_number_strip]=COLOR
time.sleep(0.25)
strip[random_number_strip]= BLACK
last_random= random_number
#define function to play wav files
def play_sound(filename):
with open(path+filename,"rb") as wave_file:
wave= WaveFile(wave_file)
audio.play(wave)
while audio.playing:
animate_lights()
#start with lights off and animation off
animating=False
strip.fill(BLACK)
while True:
if distance_sensor.data_ready:
distance = distance_sensor.distance
if distance == None:
distance = 0
if distance == 0:
continue
distance = min(distance, MAX_DISTANCE)
distance = max(distance, MIN_DISTANCE)
leds_off = math.ceil((distance-MIN_DISTANCE)/cm_per_light)
leds_on = strip_num_of_lights-leds_off
for i in range(strip_num_of_lights):
if i < leds_on:
animating= True
animate_lights()
if button_A.value:
play_sound("I_see_the_light.wav")
if i > leds_on:
strip[i]=BLACK
else:
strip[i] = BLACK
strip.write()
distance_sensor.clear_interrupt()
time.sleep(0.05)
Assemble Project

.jpg)
Now that we have the code and painting aspect of this project all done, let's bring them together! In the step above, you will see that this code works by first defining two functions, one to animate the lights and one to play the sound. These functions are used in the while loop, which runs through the animation if there is something near the distance sensor, also allowing for button A to be pressed to play the song. In order for this code to execute, we will need to hook the Neopixel strand to GND, VOUT, and A1 for signal. Then, using the stemma QT cable, we will connect the ToF sensor to our board using SCL, SDA, GND, and 3.3V. Lastly, attach your battery pack to your CPB. I then taped the Neopizel strand to the back of the canvas, also attaching the CPB with button A facing out so the viewer can press it. Attach the distance sensor to the sun on top of the canvas, and now you're ready to enjoy your awesome interactive painting!