Here is the video of the Rube Goldberg egg-breaking device Molmol and I made for Dustyn Roberts’ Mechanisms and Things that Move class. It was great fun working with Molmol, who was responsible for figuring out how we would actually crack the egg. The project also gave me a chance to empty out my toy closet.
void setup() //run once, when the sketch starts
{
pinMode(ledPin, OUTPUT); //sets the digital pin as output
}
void loop() //run over and over again
{
digitalWrite(ledPin, HIGH); //sets the LED on
delay(1000); //waits for a second
digitalWrite(ledPin, LOW); //sets the LED off
delay(3000); //waits for 3 seconds
}
//declare variables:
int switchPin = 2; // digital input pin for a switch
int yellowLedPin = 3; // diagital output pin for a LED
int redLedPin = 4; // diagital output pin for a LED
int switchState = 0; // the state of the switch
void setup() {
pinMode(switchPin, INPUT); // set the switch pin to be an input
pinMode(yellowLedPin, OUTPUT); // set the yellow pin to be an output
pinMode(redLedPin, OUTPUT); // set the red pin to be an output
}
if (switchState == 1) {
// if the switch is closed:
digitalWrite (yellowLedPin, HIGH); // turn on the yellow LED
digitalWrite (redLedPin, LOW); // turn off the red LED
}
else {
// if the switch is open:
digitalWrite (yellowLedPin, LOW); // turn off the yellow LED
digitalWrite (redLedPin, HIGH); // turn on the red LED
}
}
And working with Emily Ryan, we turned a simple squeak toy into a blazing-eyed Valentine Rat!
While working on the rat, I regaled those in the lab with us with the story of my experience in rat dissection in my freshman year biology lab class at Penn:
//declare variables:
int switchPin = 2; // digital input pin for a switch
int redlLedPin = 3; // diagital output pin for a LED
int redrLedPin = 4; // diagital output pin for a LED
int switchState = 0; // the state of the switch
void setup() {
pinMode(switchPin, INPUT); // set the switch pin to be an input
pinMode(redlLedPin, OUTPUT); // set the yellow pin to be an output
pinMode(redrLedPin, OUTPUT); // set the red pin to be an output
}
if (switchState == 0) {
// if the switch is open:
digitalWrite (redlLedPin, LOW); // turn on the left eye LED
digitalWrite (redrLedPin, LOW); // turn off the right eye LED
}
else {
// if the switch is closed:
digitalWrite (redlLedPin, HIGH); // turn on the left eye LED
delay (55); // wait for a little bit
digitalWrite (redrLedPin, HIGH); // turn on the right eye LED
delay (50); // wait for a little bit
digitalWrite (redlLedPin, LOW); // turn off the left eye LED
delay (50); // wait for a little bit
digitalWrite (redrLedPin, LOW); // turn off the right eye LED
delay (50); // wait for a little bit
}
}
It was a blast working with Emily, who is always fun to work with because of her energy, ideas, and great (often self-deprecating) sense of humor.