Wrote some code for a project I am working on, the motor just does not want to work with me
#include <Servo.h>
int MotorPin = 9;
Servo Motor;
void setup() {
pinMode(MotorPin, OUTPUT);
Motor.attach(MotorPin);
}
void loop() {
MotorControl(100); // Move the motor to a position based on input
delay(1000); // Wait for 1 second
MotorControl(-100); // Move the motor in the opposite direction
delay(1000); // Wait for 1 second
}
void MotorControl(int value) {
// Map the value (-100 to 100) to servo position range (1000 to 2000)
Motor.writeMicroseconds(map(value, -100, 100, 1000, 2000));
}
Using an Arduino uno, a vex 393 motor and a vex 29 motor controller
3.3V power and ground going out of frame to something.
A 5V level output pin going out of frame to something.
Red and black wires coming in frame from something going to something.
I'm afraid I can't even begin to venture a guess as to what might be going wrong based on that. I can see that you have an R3 with wires attached to it but that's about it.
A picture that showed where all those wires were going would be a better start. A schematic showing the same would be great.
A 9vdc battery can power an Arduino, but should not be connected while the computer USB is connected.
An Arduino can send commands to a motor controller, but an Arduino can not source the power necessary to run a motor controller and a motor. The motor controller must have an external power supply enough to move the motor.
Read the datasheets for the motor controller and motor for the specific data you need.
How much current does your controller and motor require? At what voltage? Is it 5V, as your wiring diagram claims, or 3.3V, as your photo shows? Have you accounted for the fact that a PP3 9V battery barely provides enough current to run the R3, with little to nothing left over for a current hungry motor? Or that even with a beefier power supply, that the R3 can only supply a relatively modest amount of current from its 5V pin, and even less from its 3.3V pin?
My bad, I meant to wire it to the 5v slot. As for the current for the controller, the max is 4 amps and the motor would be around 1 amp? I want to say when it is moving
And after overloading it like that, you'd do well to measure if you're getting anything at all out of the 3.3V pin. As well as checking your controller after powering it with 3.3V and giving it a 5V level signal. You're probably safe since your 9V battery's voltage probably dropped like a stone after being called on to supply current orders of magnitude above what it's designed to do, but better safe than sorry.
The 5V regulator on the R3 is rated for 1A max. And since it doesn't have a heat sink, derate that to a couple of hundred mA. And the R3 itself will take 45mA of that.