Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
laurenkoi
Published

Arduino Project 9: Motorized Pinwheel

Motorized Pinwheel goes brrrr.

BeginnerShowcase (no instructions)1 hour82
Arduino Project 9: Motorized Pinwheel

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
9V battery (generic)
9V battery (generic)
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
×1
Snap-on Connector, For 1 9-V Battery
Snap-on Connector, For 1 9-V Battery
×1

Story

Read more

Schematics

Pinwheel Video

Fritzing

Schematics

Code

Motorized Pinwheel Code

Arduino
Pinwheel go brrrrr.
const int switchPin=2;
const int motorPin=9;
int switchState=0;

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

void loop() {
  //Reading if the switch has been pushed
  switchState=digitalRead(switchPin);
  if(switchState==HIGH){
    //If the switch has been pushed make the motor spin
    digitalWrite(motorPin,HIGH);
  }
  else{
    //If the switch hasn't been pushed don't make the motor spin
    digitalWrite(motorPin,LOW);    
  }
}

Credits

laurenkoi

laurenkoi

13 projects • 1 follower

Comments