I am using Tinkercad (online circuit simulator) to test curcuits. Here’s my scheme
Here’s my code for this:
#include <Servo.h>
Servo motor;
void setup(){
pinMode(6, OUTPUT);
motor.attach(6);
}
void loop(){
int potValue = analogRead(5);
int speed = map(potValue, 0, 1023, 0, 180);
if (speed == 90){
motor.write(LOW);
} else {
motor.write(speed);
}
}
Experimentally, I found out that 0-180 is a range of this motor. 90 supposed to be a “stop value”. Unfortunatelly, at 90 value it continues to rotate the motor at a little speed. How can I stop the motor completely?
Hello.
Just to clarify, it appears from your diagram that you are using our Simple Motor Controller (SMC) 18v7, and not one of our newer High Power SMC G2 boards. Is that correct? (Assuming that is correct, I will be linking to the user’s guide for the older controllers.)
Using an Ardunio to read your potentiometer then output an RC servo signal to control your SMC seems like an unnecessarily complicated approach. Since the SMC has an interface for reading analog signals, you could just connect your potentiometer directly to your SMC following the instructions in the “Connecting a Potentiometer or Analog Joystick” section of the user’s guide.
However, if you do want to continue using your SMC through its RC interface using a Ardunio, the quickest way to get your current setup working would probably be to remove the if
and else
conditions and replace them with just the motor.write(speed);
line. You should also calibrate the RC Channel input settings using the Input Settings tab of the Simple Motor Control Center, in particular using the Channel Setup Wizard which you start by pressing the “Learn…” button, to ensure that the SMC is making use of the full range of signals you are sending it.
By the way, 9V batteries are not appropriate for high-current applications like controlling motors, so you should probably switch to a more appropriate power supply, like a bench-top supply or a battery pack that can handle high discharge currents.
- Patrick