The motivational spinner is a cute, fun toy to have in your room. The apparatus is self-contained, with a cardboard bottom and top. Shafts of sturdier cardboard hold the ceiling up and leave enough room for the motor and wheel. The motor itself is taped to a box platform and elevated so that the wheel will fit inside the structure. The servo is attached to a blade, which is taped to the wheel so that when the servo spins, the entire wheel will spin as well.

The number of spins is randomly generated each time the code is run. This will allow the user to obtain different motivational quotes each time. The quotes are “Stay healthy”, “Be happy”, “Sleep more”, “Enjoy Life”, and “Exercise”. As my sophomore year workload has ramped up significantly, this spinner is a good way to keep myself both entertained and motivated to deal with the upcoming workload.

#include <Servo.h>

int count = 0;
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(0)); //makes rng start from a random value
  int limit = random(0, 30);
  Serial.print(limit);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  while (count<limit) {
    for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees if (pos%30==0) count++; //Serial.print(count); myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position if (count>=limit) return;
    }
    for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
      if (pos%30==0) count++;
      //Serial.print(count);
      myservo.write(pos);              // tell servo to go to position in variable 'pos'
      delay(15);                       // waits 15ms for the servo to reach the position
      if (count>=limit) return;
    }
  }
}

void loop() {
}