For the midterm project, I was interested in creating a series of interconnected reactions, and thought there’s nothing better than a Rube Goldberg machine that embodies that concept. At first, I was throwing around wild concepts, that involve the use of multiple sensors and intricate code. But, in the end I settled on less intricate structure, that was equally challenging.
The main parts this project is comprised of are:
- A wooden ramp
- 2 servos
- Distance sensor
- Force Sensitive Resistor
- LCD Screen
- Rubber ball
- Marble
Although the project fulfills its purpose and main function, I would still have prefered to have some aspects of he code to be enhanced a bit – such as the movement of the servos in relation to the reaction, as well as the display on the LCD screen.
And here’s the video:
The code:
// include the library code: #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(13, 12, 11, 10, 9, 8); //defining lcd pins int sensorValue = 0; // variable to store the value coming from the sensor int sensorPin = A0; // select the input pin for LDR int sensorMin = 1023; int sensorMax = 0; int fsrReading; void setup(void) { Serial.begin(9600); pinMode(3, INPUT); lcd.begin(16, 2); } void loop() { sensorValue = analogRead(sensorPin); // read the value from the sensor Serial.println(sensorValue); //prints the values coming from the sensor on the screen //display text on lcd if (sensorValue > 100) { lcd.display(); lcd.clear(); lcd.setCursor(0, 0); lcd.print("Who let the"); lcd.setCursor(0, 1); lcd.print("ball out!"); } else { lcd.clear(); } lcd.display(); delay(100); }