Demo:
Idea:
When I came across some bad robot images online, I think it could be fun to make a broken robot with “laser” eyes, which can be used as a flashlight.


What should I use to make these laser eyes? The first image that pops up in my mind is this Magic Light Cup Module that I did some research on last semester in my pcomp class. KY-027 Magic Light Cup Module is a set of two boards, each one has a led and a mercury tilt switch. A pair of the modules create a light hourglass effect, light being “magically” transferred from one module to the other when tilting them, which is quite playful. I think this could be my broken robot’s “laser” eyes.

Material:
For the electronic part, I used Arduino Nano IoT33 as the microcontroller, a pair of KY-027 magic Light Cup Module, a 9v Li-On battery as the external power source, a 1.8″ x 1.4″ x 0.4″ breadboard and multiple wires.


For the fabrication part, I used cereal package — cardboard, duck tape and double-sided tape.

Digital Design:
I used a small breadboard with dimension1.8″ x 1.4″ x 0.4″ holding all electronics in order to make it portable.



To have a hourglass effect, I put some delay after each transfer. Also for the fading off effect, I extend time period of decreasing brightness.
Codes:
int ledPinA = 12;
int switchPinA = 11;
int switchStateA = 0;
int ledPinB = 3;
int switchPinB = 2;
int switchStateB = 0;
int brightness = 0;
// fade off effect
void setup() {
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(switchPinA, INPUT);
pinMode(switchPinB, INPUT);
Serial.begin(9600);
}
void loop() {
switchStateA = digitalRead(switchPinA);
if (switchStateA == HIGH && brightness != 150) {
brightness ++;
}
switchStateB = digitalRead(switchPinB);
if (switchStateB == HIGH && brightness != 0) {
brightness --;
}
analogWrite(ledPinA, brightness); // LED A slowly fade out
Serial.print("LED A: ");
Serial.println(brightness);
analogWrite(ledPinB, 150 - brightness); // LED B slowly bright up
Serial.print("LED B: ");
Serial.println(150 - brightness);
delay(20);
}
Fabrication Design:
The main idea is to only show LED lights and hide everything else. For my own convenience to insert in and take out the breadboard for debugging issues, I also need a nice and easy flip. Beyond that, to make it a portable product, I want it to look integral. With all these concerns, I decided to make a cuboid to hide all the electronics.




I drilled two tiny holes to only show the LED lights out.




Experiments:
I tested the electronic part to make sure that LED lights fade off with an external power source — a 9V battery. Here I had some difficulties finding the right external power source. Since Arduino nano accepts either 3.3 volts or 5 volts as power input, but I only got a 9 volts battery aside. After reading the datasheet of Arduino nano IoT 33 again, I found that Vin pin can also work as a power input pin that can hold voltage from 5 to 21 volts. Problem solved!
After that, I started to put everything inside the box. The easy-flip is quite helpful here to allow me to plug in and out my battery easily without pulling out the entire breadboard.




Here is a draft demo of my flashlight.
Recap:
After I showed this to my roommate, he mentioned that the light transition speed is too slow for him to wait to see the fade off effect. I adjusted the fade off period from 255 to 150 to allow the light transition process goes faster.