Beginner help with Motor and Encoder library

Two problems:
1 - you are executing a DigitalWrite and a AnalogWrite on the same port (E1, i.e. port 4)
2 - you never define the mode (INPUT or OUTPUT) of this port.

You should:
1 define if you need a Digital or a Analog port
2 verify if port 4 (pointed from E1 variable) is the correct type and, if necessary, move to a new one
3 define the port usage (INPUT o OUTPUT) ad write the correct value on it.

pls note:
default for every port is INPUT. For code readiness, it's always better to define a port as Input also if it is not strickly due.
On an analog port, probably you could use digitalWrite (HIGH or LOW) instead analogWrite (255 or 0), but it is not much elegant.
If you need a digital port, use a digital port instead an analog.
Analogic output is realized via PWM modulation, non via a linear actuator. Pls google "PWM" to understand this tecnology.
Avoid as possibile to mix analogic and digital.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.