Arduino Project

Here is an image of the wiring for an Arduino that controls the speed of an electric motor and angle of a servo motor.

Here is the code you will need to upload to get your Arduino working.

#include <Servo.h>
const int MOTOR=3;
const int MPOT = A3;
const int SPOT = A0;   
const int SERVO = 6;
Servo myServo;
void setup()
{
	pinMode(MOTOR,OUTPUT);
	pinMode(MPOT,INPUT);
  pinMode(SPOT, INPUT);
  myServo.attach(SERVO);
	Serial.begin(9600);
}
void loop()
{
	int mrval = analogRead(MPOT);
  int mwval = 0;
	mwval = map(mrval, 0, 1023, 0, 255);
	analogWrite(MOTOR, mwval);
  Serial.println(mwval);
  int srval = analogRead(SPOT);       
  int swval = map(srval, 0, 1023, 0, 180);
  myServo.write(swval);
}