To make everything work we used the following code that was written by Nick.
//THE USELESS MACHINE
#include <Servo.h> //Including the servor library in the code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
int LED = 8;
// this constant won't change:
const int onoffswitch = 10 ; // the pin that the pushbutton is attached to
// Variables will change:
int switchCounter = 0; // counter for the number of button presses
int switchState = 0; // current state of the button
int lastSwitchState = 0; // previous state of the button
//Set servo as myservo
Servo myservo;
void setup () { //Starting off the code
// initialize the button pin as a input:
pinMode(onoffswitch, INPUT);
//myservo is set to pin 12
myservo.attach(6);
//and is placed at 180 degree
myservo.write(180);
// initialize serial communication:
Serial.begin(9600);
//Start LCD Scrren by clearing and writing "Points ="
lcd.begin(16, 2);
lcd.clear();
lcd.print("THE USELESS GAME");
lcd.setCursor(0,1);
lcd.print("Points =");
int switchCounter = 0;
}
void loop () //Start loop
{
// read the switch input pin:
switchState = digitalRead(onoffswitch);
// compare the switchState to its previous state
if (switchState != lastSwitchState)
{
// if the state has changed, increment the counter
digitalWrite(LED,HIGH);
delay(500);
if (switchState == HIGH) {
// if the current state is HIGH then the button
// went from off to on:
myservo.write (180); //so place servo at 180 degree so that
//the finger will push the switch back to off
switchCounter++;
lcd.setCursor(9,1);
lcd.print(switchCounter); //write out button presses
} //close IF statement
else{
myservo.write (25); //move servo to position 25 degree
digitalWrite(LED,LOW);
delay (100); //then pause for 10th of a second
} //close ELSE statement
} //close IF statement
// save the current state as the last state,
//for next time through the loop
lastSwitchState = switchState;
} //close LOOP
The project summary was written my Matt and reviewed by the other members of team "ThinkStation" before being submitted.
To assemble the "Useless Machine" we gorilla glued all of the acrylic walls together with the exception of the lid that has the hinge on it. The LCD screen was placed on the lid opposite of the hinged lid using 4 nuts and bolts. Along with the LCD screen there is also an LED light and a switch that are mounted on the same lid using bulkhead fittings that Matt supplied. On one of the walls of the box the servo motor is mounted using double sided sticky tape, because the wall with the holes to bolt the motor on that we originally submitted for fabrication was never delivered.
Upon testing of the final project we discovered that everything worked as we originally planned. One issue that arose while troubleshooting was the lack of power from using the LCD screen, servo motor, and LED light all at the same time. Even though everything worked properly we did however encounter a few issues when it came to assembling the project due to inaccuracies of tolerances while dimensioning.
The best way to improve on the overall quality of the project is to learn more about geometric dimensioning and tolerance (GD&T). This will help eliminate the overlapping of parts and make the assembly process a lot smoother. As for redesigning parts that would be resolved by learning more about GD&T.