Francesco Guerri
Published © GPL3+

Electronic Wind DIY Pinwheel

A DIY pinwheel controlled by Arduino using a DC motor recycled from a portable CD player.

BeginnerFull instructions provided3 hours8,317
Electronic Wind DIY Pinwheel

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DC motor (generic)
I took this engine from an old portable CD player
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Hand tools and fabrication machines

Carboard
Scissors
Scotch tape

Story

Read more

Schematics

Project schematics

Code

Arduino Sketch

Arduino
// It starts the engine when the button is pressed, keeping it on when you release.
// We press a second time to turn off the engine

#define MOTOR 5               // motor to pin 5
#define BUTTON 7              // input pin where the button is connected
int val = 0;                  // it is used to store the state of the input pin
int old_val = 0;              // it is used to maintain state in the previous step of the input pin
int state = 0;                // stores the motor status: 0 for off, 1 for on
  
void setup() {  
  pinMode(MOTOR, OUTPUT);       //sets the pin output 
  pinMode(BUTTON, INPUT);     // sets the pin input 
}  
  
void loop() {  
  val = digitalRead(BUTTON);  // reads the input value and saves into val
  
  // checks if something happened 
  if ((val == HIGH) && (old_val == LOW)){  
    state = 1 - state;  
  }   
  
  old_val = val;            // ricordiamo il valore precedente di val  
  
  if (state == 1) {  
    analogWrite(MOTOR, 255);   // starts the motor. 225 is the speed value. You can modify it from 155 to 255
  }  
  else {  
    analogWrite(MOTOR, 0);    //turn off the motor 
  }  
}  

Credits

Francesco Guerri

Francesco Guerri

4 projects • 16 followers
Computer engineering at University of Siena. Android developer and graphic designer.

Comments