Luis Estades
Published

Project #9 Motorized Pinwheel

Learn how to set up a pinwheel with a servo Motor.

BeginnerShowcase (no instructions)2 hours148
Project #9 Motorized Pinwheel

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
9V battery (generic)
9V battery (generic)
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
×1
Resistor 10k ohm
Resistor 10k ohm
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

PinWheel Code

Arduino
const int switchPin = 2;  // the number of the switch pin
const int motorPin = 9;   // the number of the motor pin

int switchState = 0;  // variable for reading the switch's status

void setup() {
  // initialize the motor pin as an output:
  pinMode(motorPin, OUTPUT);
  // initialize the switch pin as an input:
  pinMode(switchPin, INPUT);
}

void loop() {
  // read the state of the switch value:
  switchState = digitalRead(switchPin);

  // check if the switch is pressed.
  if (switchState == HIGH) {
    // turn motor on:
    digitalWrite(motorPin, HIGH);
  } else {
    // turn motor off:
    digitalWrite(motorPin, LOW);
  }
}

Credits

Luis Estades

Luis Estades

13 projects • 1 follower

Comments