I am building a project using an Arduino Nano. In it, I am using pin 3 as PWM output. However, If I supply values lower than 255 to it, the pin does not output any voltage at all.
According to this diagram, pin 3 is PWM:
I have tested it on two boards, it doesn't function on either one. It's not my sketch, either (I tested it with a simple analogWrite();
).
This is the code:
void setup() {
// put your setup code here, to run once:
#define E1 3 // Enable Pin for motor 1
#define E2 10 // Enable Pin for motor 2
#define I1 4 // Control pin 1 for motor 1
#define I2 2 // Control pin 2 for motor 1
#define I3 A1 // Control pin 1 for motor 2
#define I4 A0 // Control pin 2 for motor 2
}
void loop() {
// put your main code here, to run repeatedly:
// I use differential steering, speed is important
analogWrite(E1, 100); // Run in full speed
analogWrite(E2, 100); // Run in full speed
// always go forward
digitalWrite(I1, LOW);
digitalWrite(I2, HIGH);
digitalWrite(I3, LOW);
digitalWrite(I4, HIGH);
}
What could be the reason of this?