(An Attempt at a Musical See Saw)

The premise of the demo was to create a See Saw that teeters to and fro that can play music when on one end and be silent on the other. This project attempts to explore why and how my example came to be.

This is a photo of the assembly. The rocking lasercut piece would overhang the table so that it may rotate.

The project had its many ups and downs. The code initially did not work for the Servo, so I had to reorganize for that. The major issue however, is not one of coding or electrical, I lacked a heavy enough ball to press in the switch to allow the rest of the code to work in harmony.

#include <Servo.h&gt;

Servo rocker;
const int SWITCH_PIN  = 9;
const int SPEAKER_PIN = 5;

void setup()
{
    Serial.begin(115200);
    Serial.println("Hello!");
    rocker.attach(7);
}

const float note_table[] = { 329.63, 392.00, 293.66, 261.63, 293.66, 329.63, 392.00, 293.66, 329.63, 392.00, 587.33, 523.25, 392.00, 349.23, 329.63, 293.63, -1 };
const float freq_table[] = { 1000, 500, 1000, 250, 250, 1000, 500, 1000, 1000, 500, 1000, 500, 1000, 250, 250, 1000};

int nextnote = 0;

void loop()
{
  while(digitalRead(SWITCH_PIN) == 0) { // busywait for the switch to be pressed

  float freq = note_table[nextnote];
  Serial.print("Note: ");
  Serial.println(freq);
  tone(SPEAKER_PIN, freq);
  delay(freq_table[nextnote]);
  nextnote = nextnote + 1;
  if (note_table[nextnote] < 0) nextnote = 0;
    rocker.write(45);
  }
  
  while(digitalRead(SWITCH_PIN) != 0)  {// busywait for the switch to be released
  noTone(SPEAKER_PIN);
    rocker.write(0);

 
  }


}

This is the code that I used in order to create the flicking aspect of the See Saw and the creation of the song to play while the switch is pressed in.

This is the example of the project using my current heaviest ball, the bouncy ball. Unfortunately, the ball is only heavy enough to press in the switch but not keep it long enough to proc the flicking motion from the Servo.
Here is the second attempt with the flicking motion actually happening. However, it took three of the rods to press the button completely in. In the next steps, I would have found a way to keep all three rods in the mechanism to allow it to oscillate more seamlessly.