Project 9 Motorized Pinwheel doesn't work untethered

I did project 9 the motorized pinwheel, including the pot addition. Everything works perfectly. When connected to the computer via the USB port.

I tried disconnecting the board from the USB and plugged in a switching PS who output is 5V, 4A to the power connector. I expected this to work but it does not. Has anyone else tried this with success?

Here is the sketch and a photo.

const int switchPin = 2;
const int motorPin = 9;
int switchState = 0;
const int potPin = A0;
int potVal;
int motorSpeed;

void setup() {
  pinMode(motorPin, OUTPUT);
  pinMode(switchPin, INPUT);

void loop() {
  switchState = digitalRead(switchPin);
  potVal = analogRead(potPin);
  motorSpeed = map(potVal, 0, 1023, 0, 254);
  Serial.print("potVal: ");
  Serial.print(" motorSpeed: ");

  if (switchState == HIGH) {
      analogWrite(motorPin, motorSpeed);
  } else {
      analogWrite(motorPin, 0);

Which board are you using?

Sorry, genuine Arduino UNO. See photo I just attached.

agundrum’s picture:

From the “Documentation” tab of the Uno product page:


The Arduino Uno board can be powered via the USB connection or with an external power supply. The power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be connected by plugging a 2.1mm center-positive plug into the board’s power jack. Leads from a battery can be inserted in the GND and Vin pin headers of the POWER connector.

The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable. If using more than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7 to 12 volts.

Connecting a 5 V power supply to the Uno’s power jack or Vin pin won’t work because it’s too low a voltage. If you want to power the Uno with 5 V, you should connect the power supply to the 5V pin. But make sure that you don’t supply more than 5 V to that pin because there is no voltage regulator.

It took me a bit, but I finally found an acceptable PS that is DC 12V, 2A and it worked fine.

Thank you!

You're welcome. I'm glad to hear it's working now. Enjoy!