First Attempt at making the motor work

I have been playing around with servo motors and trying to get them to turn with the Arduino using the Servo Knob code example. I also made the Ping sensor work using the Ping code example, so all I need to do is combine the two codes – taking the important elements I need from each code and put them together.

  • const int pingPin = 7;
  • #include <Servo.h>;
  • myservo.attach(9);

These are some of the main aspects of code which I need to include for the Ping sensor and the servo motor to be recognised and included in the sketch.

The video above shows the motor turning depending on how close or far away my hand was. The Ping sensor flashes and the faster the flash the closer it is to an object.

The servo motor only has a 180 degree turning cycle, so when it completes its half rotation clockwise it turns back anti clockwise. For my final outcome I am wanting the motor to be a full rotation motor, so I am going to have to invest in a stepper motor which is a full 360 degree rotation. I will also have be using the SpeedControl example rather than Knob as I am wanting the motor to turn faster or slower depending on the input from the Ping sensor. This is what my next task is going to be.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s