Playing with Lights: Lighting Controller

I partnered with KC on this assignment.

 

Our task this week:

  • A control to turn the light on and off. When it turns on, it should retain the relative red, green, and blue brightness levels from when it was last turned on.
  • The ability to fade each color channel (red, green, and blue) from off to full brightness
    • Fade level should be maintained when you release the fade controller
    • Fade should be interrruptable by other controllers, e.g. on/off or another fade controller
  • The ability to fade the overall brightness of the light

 


I started too ambitious out in the project yet again as started to focus on the form rather than the function. Once I dialed it back, I began to work with KC to solve the coding issues we were having.

 

Layout and Wiring

 

After wiring everything correctly as shown by both the Fritzing model and the images below, we began to debug the code and see what was wrong in terms of mapping the values from the potentiometers.

 

 

We ran into a few problems, some that we were able to solve and others which we could not solve in the time this assignment allowed for.

 

Problem 1: LED was not turning FULL Red/Green/Blue – Solved!

For some reason, mapping only worked from 0 to 673, which we then mapped to 0-255, which worked! We originally had it mapped to 672, and after seeing the additional value in the Serial Monitor, we changed the mapping and got the lighting working for a while.

 

Problem 2: 255 and 0 were reversed – Unsolved

For some reason, the ‘0’ and the ‘255’ were reversed. We changed the wiring and reversed the range in the code, but could not figure out why these were revised when we view the data in the Serial Monitor.

 

Problem 3: After soldering and assembling, the entire thing stopped working.

After spending the time to solder and make sure all connections had current running through them, we were surprised to realize that our LED began blinking random colors. We could not test the rib values as they kept changing everything the light changed automatically to a different color. We tried a different Arduino, a different breadboard and even combed through the code, and couldn’t find what could be wrong with this.

 

Considerations for Next Time

I would have incorporated the switch at an earlier process during the build/test phase instead of towards the end, which complicated things temporarily. Once I find out what was wrong with the soldering problems, I will incorporate that feedback here.

Game Controller for Lunar Landing

What a journey this project was. I immediately dived into the junk shelf and began digging through thenpiles until I found some things I could use.

I found a joystick from a drone, some wood, and buttons from the Shop. I was set…or so I thought…

My focus was on ergonomics as having a tiny box didn’t seem the best way to play. I played around with the idea of large controls, i.e. pedals and a thrust lever, but I was straying too far from the original ask. I found some pieces of wood that resembled extra large video game controllers, so I took the cue from there and began shaping and designing them as a game controller.

 

 

 

I cut off the end clip and soldered leads on each of the wires. I thought I would come back to this controller once I figured out the buttons…

It took me some time to figure out the code and the wiring.
#include

const int upButton = 13;
const int downButton = 12;
const int leftButton = 11;
const int rightButton =10;
const int reloadButton = 9;
const int enterButton = 6;
const int ledPin = 5;

int potMove;
int up;
int down;
int left;
int right;
int reload;
int enter;
int led;

void setup() {
Serial.begin (9600); //set up serial baud rate
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(leftButton, INPUT_PULLUP);
pinMode(rightButton, INPUT_PULLUP);
pinMode(reloadButton, INPUT_PULLUP);
pinMode(enterButton, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
Keyboard.begin();
}
//
void loop() {
int up = digitalRead(upButton);
int down = digitalRead(downButton);
int left = digitalRead(leftButton);
int right = digitalRead(rightButton);
int reload = digitalRead(reloadButton);
int enter = digitalRead(enterButton);
// int potMove = analogRead(A2);
// led = digitalRead(ledPin);

//use buttons and pot to control keyboard
// Serial.println(potMove);

if (up == HIGH) {
Keyboard.press(‘w’);
delay(10);
Serial.println(“UP_”);
Keyboard.release(‘w’);
//Serial.println(potMove);
}

if (down == HIGH) {
Keyboard.press(‘s’);
delay(10);
Serial.println(“DOWN_”);
Keyboard.release(‘s’);
//Serial.println(potMove);
}

if (right == HIGH) {
Keyboard.press(‘d’);
delay(10);
Serial.println(“RIGHT_”);
Keyboard.release(‘d’);
//Serial.println(potMove);
}

if (left == HIGH) {
Keyboard.press(‘a’);
delay(10);
Serial.println(“LEFT_”);
Keyboard.release(‘a’);
//Serial.println(potMove);
}

if (reload == HIGH) {
Keyboard.press(135);
Keyboard.press(‘r’);
delay(50);
Keyboard.releaseAll();
digitalWrite(ledPin, HIGH);
delay(1000);
Serial.println(“RELOAD”);
digitalWrite(ledPin, LOW);
}

if (enter == HIGH) {
Keyboard.write(176);
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
Serial.println(“ENTER”);
}

 

I then focused on the actual controller bit of the assignment.


 

I drew out where the controls were go, and walked around the Floor, asking random classmates hold the device, and adjusting the orientation and placements of the buttons to ensure that both large handed and small handed people would be able to grasp the large controller without any significant issue.

 

I wanted to figure out a way for the button to sit flush in the wood, but it was way too thick and after various attempts to make it work, I went back to laser cutting acrylic.


 

I hot glued the buttons to the bottom so they would stay in place as the user pressed on the buttons from the top.

 

This is when I ran into issues. I didn’t think through how I wanted to close the controller…

I wanted it to be accessible, but I ran out of time in figuring this portion of the controller out.

 

Functionally it works! It doesn’t look so good though…