I'm a total noob with Arduino, but after reading for some hours I thought I understood how to control a motor by sending a PWM signal from the Arduino Nano to the ESC.
The ESC is this one:
The issue is that the motor is pulsing. I made a simple script with analogWrite (3, 127) to test if it would turn half speed, but "no cigar".
I tried using the "servo.h" library, also. No luck.
The ESC works fine with the potentiometer that came with it. It's a 100KOhm and the board supplies it with 10V. In case it is relevant.
The PIN9 of the Nano is connected to the ESC by the yellow wire (signal) plus the GND from the ESC paired with the signal. Can't be simpler but I'm doing something wrong.
Blockquote
Setting the pinMode() of the output pin to OUTPUT would be a good place to start
On the guides it's stated that for using PWM isn't necessary to set the pin as an output. Of course now that you say this to me I'll do it that way.
Blockquote
What makes you think that the yellow wire is a signal wire and not simply connected to the wiper of the pot to provide a variable voltage output ?
My "noobness". Red for positive, black for GND and yellow, signal. I measured between the red and black wires and it gave me 10V so I supposed the yellow wire was the signal.
Blockquote
Can you please provide a link to somewhere that says that ? Are you perhaps confusing not needing to set the pinMode() of an analogue input ?
Blockquote
You do not need to call pinMode() to set the pin as an output before calling analogWrite() .
Maybe I misunderstood?
Blockquote
As to the signal wire, measure the voltage between the the black wire and the yellow wire. Does it vary when you rotate the knob on the control ?
With the motor stopped, yellow-black is 4.4V. With the motor at full speed yellow-black is 0V.
Thanks for the link, you did not misunderstand, it was me, hence my question
Pins normally default to INPUT but personally I always use use pinMode() as it makes sense to me to explicitly set the mode of pins to match their function so I set PWM pins to OUTPUT in any case
Your results when reading the voltage of the yellow wire seem to me to indicate that rotary control is a potentiometer between 0V and the supply voltage and that the yellow wire simply provides a varying voltage by being connected to the wiper of the pot
If that is true, then in order to control the speed of the motor you need to supply a variable voltage or a PWM signal between black and yellow wires. Using an Arduino PWM pin directly for that may damage the Arduino because it cannot provide much current
Depending on the electronics of the controller then a PWM signal may not work because it only provides a fixed on/off voltage of 5V which the controller electronics may not interpret as a varying voltage
I can see no indication that your motor controller (which not a conventional ESC) can be controlled by an external PWM input. The PWM in the description refers to the output to the motor NOT to any control input.
If the link you posted is really your ESC, then the images below represent it.
Note that it uses a 555 IC to do PWM.
The external potentiometer adjusts the voltage on pin 7 of the IC.
This potentiometer is part of the timebase for the 555.
I believe that with a PWM signal it will not work correctly.