Motor won't work

Hi, so I’m making a circuit that involves both a motor and a servo. So far I have been able to get the servo to work, but I haven’t been able to get the motor up and running. I’m stumped as to what the problem is and would greatly appreciate some help.

Here is my code:

#include <Servo.h> //Servo library
Servo myServo;
int const potPin = A0; //Potention meter connected to this pin
int potVal;
int angle;
const int switchPin = 2;
const int motorPin = 8;
 int switchState = 0;
void setup() {
  myServo.attach(9); //Servo connects to Arduino here
  Serial.begin(9600);
}
void loop() {
  pinMode(motorPin, OUTPUT);
  pinMode(switchPin, INPUT);
  potVal = analogRead(potPin); 
  Serial.print("potVal: ");
  Serial.print(potVal);
  angle = map(potVal, 0, 1023, 0, 179);
  Serial.print (", angle , ");
  Serial.println(angle); //Lower case L, not an I or a 1.
  myServo.write(angle);
  delay(15);
    switchState = digitalRead(switchPin);
  if (switchState == HIGH) {
    digitalWrite(motorPin, HIGH);
  }
  else  digitalWrite(motorPin, LOW);
  }

And I’m also attaching an image of the circuit.

Thank you!

TEJ.JPG

If the 9V PP3 battery is powering the motor there will not be enough current from to do so.

Draw us a schematic.

.

Better image needed.

2016-06-02_20-24-17.png
.

It is not clear from that picture how/if you have wired a switch to pin2. Or how you have connected the motor/transistor.

int const potPin = A0; // ?

pinMode in void loop() // ? Leo..

Hi;

LarryD: If the 9V PP3 battery is powering the motor there will not be enough current from to do so.

Draw us a schematic.

.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png? Not a fritz picture... Thanks. Tom.. :)

TomGeorge:
Hi;Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Not a fritz picture…
Thanks. Tom… :slight_smile:

If I may ask, why do people seem to not like fritz diagrams on this forum?

Because they end up looking like pictures of 'black boxes' with wires connecting them. Even a simple thing like a transistor - which pin is the Gate, Drain, Source, or Base, Collector, Emitter?

While a Schematic will show the functions of the pins of each box without having to look up each part to see what its connections are.

hawleycj: If I may ask, why do people seem to not like fritz diagrams on this forum?

See: https://forum.arduino.cc/index.php?topic=382458.0

.

First of, thanks to everyone who replied.

Second off, sorry about the picture quality. When I originally pasted the photo in a google doc it turned out fine. I should have checked the quality before posting.

Here is a new circuit made with 123d.