oolvoonoo
Published © GPL3+

Motor-Go-Round

This project is to create a little merry-go-round!

IntermediateFull instructions provided405
Motor-Go-Round

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×2
MOSFET Transistor, Switching
MOSFET Transistor, Switching
I just used the transistor in the starter kit
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Capacitor 100 µF
Capacitor 100 µF
×1
Temperature Sensor
Temperature Sensor
×1
Fast / Ultrafast Diode, 1 kV
Fast / Ultrafast Diode, 1 kV
Just used the diode in the starter kit
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
DC Motor, 12 V
DC Motor, 12 V
×1
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Motor Go Round Schematic

Motor Go Round Schematic

Code

Music, Spin, and Temperature

Arduino
This is for the first Arduino UNO. It will control the music and speed of the DC motor (which is regulated by the temperature).
const int tempPin = A1;

const int transistorPin = 9;

int mintemp = 1023;

int maxtemp = 0;

int cur_temp;


const int piezo = 11;

int transistorValue;

void setup() {
  // put your setup code here, to run once:

  
  Serial.begin(9600);
  pinMode(transistorPin, OUTPUT);

  while (millis()<5000){
    cur_temp = analogRead(tempPin);

    if (cur_temp > maxtemp){
      maxtemp = cur_temp;
    }
    if (cur_temp < mintemp){
      mintemp = cur_temp;
    }
    
  }
  
  // this helps us determine the range of temperatures
  
  Serial.print("MIN TEMP: ");
  Serial.println(mintemp);
  Serial.print("MAX TEMP: ");
  Serial.println(maxtemp);


}

void loop() {
  // put your main code here, to run repeatedly:

  cur_temp = analogRead(tempPin);
  
  Serial.print("CUR TEMP");
  Serial.println(cur_temp);

  transistorValue = map(cur_temp, mintemp, maxtemp, 100, 250);
  // converts temp value to number between 0-255 to PWM the motor. 
  //we want a higher temperature to equal faster spin
  
  Serial.println(transistorValue);

  
  analogWrite(transistorPin, transistorValue);
  // starts spinning the motor at the speed according to the temperature

  tone(11, 261, 500);
  delay(500);
  tone(11, 294, 130);
  delay(130);
  tone(11, 329, 260);
  delay(260);
  tone(11, 329, 260);
  delay(260);
  tone(11, 294, 130);
  delay(130);
  tone(11, 261, 130);
  delay(130);
  tone(11, 294, 130);
  delay(130);
  tone(11, 329, 130);
  delay(130);
  tone(11, 261, 260);
  delay(260);
  tone(11, 196, 350);
  delay(350);
  // it can only change the speed of the carousel at the end of each melody
}

Servo Motor Code

Arduino
This is for the second Arduino UNO. This is to control the servo motor, which will raise the little toy up and down as the merry go round spins.
#include <Servo.h>


Servo myServo;

 
void setup() {
  // put your setup code here, to run once:
  myServo.attach(3);
  


}

void loop() {
  // put your main code here, to run repeatedly:
  myServo.write(90);
  delay(600);
  myServo.write(0);
  delay(500);
  // the delay is large so that the servo can have enough time to spin
}

Credits

oolvoonoo
1 project • 0 followers

Comments