Introduction: Twister With Servo Motor (4 Colors)

The classic game of twister with an upgrade in electronics. Two lights will light with each spin, the light that says which hand/foot and the color. This will work automatically so there will no longer need to be a person sitting on the side just to spin the spinner. The setup is simple and it only requires a couple of supplies to build your very own twister spinner.

Step 1: Gathering Supplies

Picture of Gathering Supplies

First you need to gather your supplies in order to build your spinner. You will need...

  • 2 servo motors
  • a breadboard
  • an Arduino Uno
  • a USB cable
  • 8 LEDs (2 of each color)
  • 15 male wires

Step 2: Assembling the Twister

Picture of Assembling the Twister

You want to have more room for ground and VN, so you should connect the ground to a blue minus space on your breadboard, and the VN to a red plus space next to it. (To make it more convenient have the blue minus be on the inside). Each LED should have the short leg in ground (or next to a wire connected to ground) and the long leg anywhere on the breadboard. A wire will be directly in front of the long leg and this will be connected to any number between 1-13 on the Arduino Uno. With each Servo motor the yellow wire should be connected to a male wire which will be connected to a different number between 1-13 on your Arduino. The middle wire will be connected to VN and the brown will go to ground. It should end up looking like the diagram above. In terms of the code in the next step, one servo is pin 9 and the other is pin 6, and the LEDs are pin 4, 5, 12, 13 and 7, 8, 10, and 11. (The diagram above is accurate except for the wires leading to the pins. Follow the pin numbers listed above. Also only half of the LEDs are set up, you'll see. Those are only for reference on how to set up an LED and don't actually lead to the right place. Well the ground part is right but the numbers are not. See later steps for exact LED set up.)(Remember when setting up an LED that the long leg should lead to the number while the shorter leg goes to ground.)

Step 3: The Code

Picture of The Code

This is the code for the twister spinner. I made it on Arduino IDE:

#include

Servo myservo;

Servo myservo2;

void setup() {

myservo.attach(9); //This will sync the servo to pin 9//

myservo2.attach(6); //This will sync the second servo to pin 6//

//The pinmodes will activate all of the LEDs//

pinMode(4, OUTPUT);

pinMode(12, OUTPUT);

pinMode(5, OUTPUT);

pinMode(13, OUTPUT);

pinMode(7, OUTPUT);

pinMode(8, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

}

void loop() {

int val = random(180); //This will cause servo 1 to turn in a random direction//

int val2 = random(180); //This will cause servo 2 to turn in a random direction//

myservo.write(val);

myservo2.write(val);

delay(2000); //Gives us time in between turns. In this case, 2000 milliseconds or 2 seconds//

/*The if statements after this will cause certain lights to light up when each servo is in a certian direction*/

if (val <= 45) {

digitalWrite(10, HIGH);

digitalWrite(8,LOW);

digitalWrite(11, LOW);

digitalWrite(7, LOW);

}

if (val>45 and val<= 90) {

digitalWrite(10, LOW);

digitalWrite(8,HIGH);

digitalWrite(11, LOW);

digitalWrite(7, LOW);

}

if (val>90 and val<=135) {

digitalWrite(10, LOW);

digitalWrite(8,LOW);

digitalWrite(11, HIGH);

digitalWrite(7, LOW);

}

if (val>135 and val<=180) {

digitalWrite(10, LOW);

digitalWrite (8, LOW);

digitalWrite(11, LOW);

digitalWrite(7, HIGH);

} if (val2 <= 45) {
digitalWrite (13, HIGH);

digitalWrite(12,LOW);

digitalWrite(5, LOW);

digitalWrite(4, LOW);

}

if (val2>45 and val2<= 90) {

digitalWrite(13, LOW);

digitalWrite(12,HIGH);

digitalWrite(5, LOW);

digitalWrite(4, LOW);

}

if (val2>90 and val2<=135) {

digitalWrite(13, LOW);

digitalWrite(12,LOW);

digitalWrite(5, HIGH);

digitalWrite(4, LOW);

}

if (val2>135 and val2<=180) {

digitalWrite(13, LOW);

digitalWrite(12,LOW);

digitalWrite(5, LOW);

digitalWrite(4, HIGH);

}

}

Step 4: Any Trouble?

Picture of Any Trouble?

First of all if you have any questions I'm pretty sure you can comment below, but if you run into any of these problems here's how to fix them.

The LEDs don't light up correctly

They might not be attached to the right pins. Above I showed a picture of the LEDs and (starting from the yellow moving to the right) they should be attached to: Pin 5, Pin 4, Pin 12, Pin 13, Pin 8, Pin 7, Pin 10, Pin 11.

The servos won't work

Check to see if your power cable is properly secured to the Arduino and is fully plugged in. Without the extra power your lights will work fine (due to the power from the computer) but they'll be dimmer and the servos won't work at all.

The code won't work

Check the code to see that every digitalWrite is orange. If not then delete and rewrite it. This was a problem that I ran into while posting the code on this instructable. Otherwise the code should work fine (if you're not used to using a coding site like Arduino IDE then remember to connect the Arduino by going to Tools, Port, and then clicking on your Arduino)

Comments

tomatoskins (author)2017-12-07

This is so cool! Thanks for sharing your cool project!

About This Instructable

224views

5favorites

License:

More by kamermelstein:Twister With Servo Motor (4 Colors)
Add instructable to: