LessLight: the Automatic Light Switch by Adi Duggal and Brett Woffington
by woffibre25 in Workshop > Home Improvement
117 Views, 1 Favorites, 0 Comments
LessLight: the Automatic Light Switch by Adi Duggal and Brett Woffington
Have you ever wanted to save the world? To be a part of something bigger than yourself? A part of positive change?
That’s exactly what we wanted, but it was too hard so we made a light switch instead.
A “useless machine” is a mechanism that turns itself off, providing absolutely no use to the world outside of caveman-level humor. LessLight takes the revolutionary idea of a useless machine and applies it to the wall-mounted light switch, turning off the light after any attempt to turn it on.
Supplies
- PC/laptop - to modify and upload code
- Arduino software - to code
- Protoboard - for the circuit
- Soldering iron and jumpers - to create the circuit
- Battery pack - to power the circuit
- Arduino Nano or any equivalent computer - to “think” for the mechanism
- Servo motor with pieces for the end - to flip the switch itself
- Flex sensor - to detect when the switch switches
- Light panel with 2 switches - this is where the machine is installed
- 3D printer - to print the custom switch plate cover
Measurements
Unscrew the standard switch plate cover and measure the length, width, curvature, hole sizes, etc.
Additionally, measure the dimensions of the servo motor.
Switch Plate Cover
Create the 3D model of the switch plate cover. It needs to function like the traditional one while providing space and support for the motor. There also needs to be space for wires to run out of the bottom of the plate in the form of a track. Attached is the STL file for the switch plate cover along with pictures of some different sizes/attempts of the print. Make adjustments as needed to fit your supplies.
Downloads
Other 3D Pieces
Create any other 3D pieces as needed. We had 2 extra pieces: an extension below the plate cover with the same dimensions including the wire track, and an open box below the extension to hold the computer and electronics. Attached are the STL files for these 2 pieces to fit ours and pictures of the prints.
Wiring and Soldering
Attach the Nano to the protoboard and solder it into place. Next, make any necessary connections in order to correctly power the motor using the flex sensor. Use the schematic as a template.
Base Code
Copy the base code into the Arduino software. This takes the input from the flex sensor (default is A3) and outputs to the servo/motor (default is 9). When the flex sensor is bent enough, the Nano tells the servo to rotate, which flips the switch.
// Include the servo library to add servo-control functions:
#include <Servo.h>
Servo servo1; //Create a servo "object", called servo1.
//Each servo object controls one servo (you
//can have a maximum of 12).
const int flexPin = A3; //Define analog input pin to measure
//flex sensor position.
void setup() {
Serial.begin(9600); //Set serial baud rate to 9600 bps
servo1.attach(9); // Enable control of a servo on pin 9
}
void loop() {
int flexPosition; // Input value from the analog pin.
int servoPosition; // Output value to the servo.
// int oldloop;
// Read the position of the flex sensor (0 to 1023):
flexPosition = analogRead(flexPin);
// Now we'll command the servo to move to that position:
if (flexPosition > 700) {
delay(2000);
servo1.write(180);
// The following code sends a message to the console in the Arduino software
Serial.print("sensor: ");
Serial.print(flexPosition);
Serial.print(" servo: ");
Serial.println(servoPosition);
delay(100);
} else {
servo1.write(0);
}
delay(20); // wait 20ms between servo updates
}
Attach Motor
Squeeze the motor into place on the switch plate cover. You can break off pieces of your 3D printed cover to fit the motor in and melt them back later on. Once the motor is in place, attach the wires to the appropriate connecting wires on the Nano.
Attach Flex Sensor
Run the flex sensor wires up into the plate so that the flex sensor is mostly flat against the back of the plate with the very end visible through the light switch hole. This end will be the part that rests on top of the switch. Once the flex sensor is in place, tape it down so it stays consistent.
Mount Plate Cover
Unscrew the original plate cover and screw in the 3D printed one (with flex sensor and motor installed) leaving one screw out to provide space for the flex sensor. Mind that the wires need to run out through the trough at the bottom. As you screw in the plate, make sure that the flex sensor rests on top of the switch and doesn’t fall to either side.
Test/modify/debug Code
Before testing your code, make sure to switch the flex sensor input and servo/motor output values to whatever your wiring is actually connected to. Once the switch plate is in place, you should upload your code to your Nano to make sure it works. If it doesn’t seem to be working as intended, revisit your code and change what you need to change. Debugging can take some time, so make sure to be patient.
The sensitivity of the flex sensor will most likely not match your preferences, so play around with it. In the base code, the value “700” in the line
if (flexPosition > 700)
is what determines how bent the sensor needs to be to trigger a response from the motor. Find upper and lower bounds on this value, then hone in until you find a value that works.
Add Extra Pieces
Using any type of adhesive, attach any extra 3D printed pieces to the wall/other pieces so that the wires run through the continued trough and the electronics are stable and accessible in the compartment. If you don’t have a battery pack, power the computer through a USB wire as shown.
Epilogue
Ultimately, we couldn’t get LessLight to function entirely independently. Here is a list of the things that didn’t work out and how we would solve them given unlimited time/resources:
- The main one: the flex sensor isn’t consistent enough to detect a switch flipping — solve by decreasing the gap between the sensor and the plate and/or adhering the sensor to the switch itself
- While we’re solving problems, the plate occasionally tries to pop off the wall — solve by shrinking the screw hole size to ensure that the screws can’t slip through the hole