Why Won't Project 10 of Starter Kit Work?

I got the arduino uno starter kit, and the tenth project isn't working. I tried it with everything exactly copied from the book but that didn't work, so then I tried tweaking it a bit. That didn't work either. I also changed the location of two wires, because the potentiometer was too big to fit as it did in the photo in the book. I'll link my code and a photo of my breadboard:

const int controlPin = 2;
const int controlPin2 = 3;
const int enablePin = 9;
const int directionSwitchPin = 4;
const int onOffSwitchStateSwitchPin = 5;
const int potPin = A0;
int onOffSwitchState = 0;
int previousOnOffSwitchState = 0;
int directionSwitchState = 0;
int previousDirectionSwitchState = 0;
int motorEnabled = 0;
int motorSpeed = 0;
int motorDirection = 1;
void setup() {
  pinMode(directionSwitchPin, INPUT);
  pinMode(onOffSwitchState, INPUT);
  pinMode(controlPin, OUTPUT);
  pinMode(controlPin2, OUTPUT);
  pinMode(enablePin, OUTPUT);
    digitalWrite(enablePin, LOW);

void loop() {
  onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
  directionSwitchState = digitalRead(directionSwitchPin);
  motorSpeed = analogRead(potPin)/4;
  if(onOffSwitchState != previousOnOffSwitchState){
      motorEnabled != motorEnabled;
  if(directionSwitchState != previousDirectionSwitchState){
      motorDirection != motorDirection;
  if(motorDirection ==1){
    digitalWrite(controlPin, HIGH);
    digitalWrite(controlPin2, LOW);
    digitalWrite(controlPin, LOW);
    digitalWrite(controlPin2, HIGH);
  if(motorEnabled == 1){
    analogWrite(enablePin, motorSpeed);
    analogWrite(enablePin, 0);
  previousDirectionSwitchState = directionSwitchState;
  previousOnOffSwitchState = onOffSwitchState;



Have you tried adding Serial.print() statements so you can work out what's happening with
the code?

Have you tried monitoring the output pins for the motor driver using a multimeter/voltmeter
to see what they are doing?

Are those switches ant the pot connected to 9V?

Here's the breadboard layout and schematic from the project book. It looks like you've gone a bit off script @imnotverygood.

The first thing you should do is disconnect the battery and the connection to your computer.

After that, spend some time to study the project book and your circuit, taking careful notes of the differences.

After that, correct your circuit to match the project book and see if it starts working. Unfortunately, you might have destroyed your Uno. If so, it's important to understand that this is an inevitable part of the journey of learning electronics. I'm sure everyone on this forum with more than a couple months of experience has burned out some part or other. The important thing is to make sure you gain knowledge from the experience. This is why I recommended you to study your current circuit. If you can understand what went wrong, then you might avoid doing the same thing with your next Uno.

I did do it the way it showed, but it wasn't working. My potentiometer is larger than the illustration in the book, and couldn't fit well, so I thought maybe it couldn't fully connect. That was why I tried changing up the circuit.

Are those switches ant the pot connected to 9V?

No, they're connected to the 5V power source from the arduino.

The problem I see is that you have the potentiometer connected to the 9 V rail on the breadboard. It's supposed to be connected to the 5 V rail. This means that you can expose pin A0 on the Uno to more than the maximum 5 V.

But I did a quick look at your sketch and noticed that you made some transcription errors. I'll let you in on a secret: all the project code is available from the Arduino IDE's File > Examples > 10.StarterKit_BasicKit menu. This allows you to skip the tedious process of typing out code from a book and then troubleshooting the typos that are introduced during that process and instead invest that time into studying the code, researching to learn the meaning of any parts you don't understand, and then experimenting with changes to the code and circuit then checking the behavior matches your expectations to verify you understand it correctly.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.