I have a weird problem. again. This time it's the PWM. I have used PWM before and I used to work the way I am doing it now. But now it just wont work. The Fading
sketch from example works. When I compile a code with the similar code it doesn't work. Everything with respect to compilation is same.
The code that works:
int ledPin = 3; // LED connected to digital pin 9
void setup() {
// nothing happens in setup
}
void loop() {
for (int fadeValue = 0 ; fadeValue <= 255; fadeValue += 5) {
analogWrite(ledPin, fadeValue);
delay(30);
}
for (int fadeValue = 255 ; fadeValue >= 0; fadeValue -= 5) {
analogWrite(ledPin, fadeValue);
delay(30);
}
}
The code that doesn't work.
#define FAN1 3
#define FAN2 5
void setup() {
//EMPTY
}
void loop() {
int speed1 = 25;
int speed2 = 127;
analogWrite(5, speed1);
analogWrite(3, speed2);
delay(10000);
}
Why doesn't the second code work?
EDIT 1:
By not working I meant No output on Second Code and Expected Output on First one. Currently I'm using ISIS
for simulation and Oscilloscope
to view the output along with a L239D
with motors attached.
In the first code the motor starts and stops as expected, with the expected PWM Waveform.
In second code, nothing. No waveform, no motor movement.