diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2008-10-13 15:03:20 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2008-10-13 15:03:20 +0000 |
commit | 5444b25e11bce6139a58c8a641dccd266f90a0f1 (patch) | |
tree | 8da36e16ca20fbb31fdcd4314dd108452bda3253 /cores/arduino/wiring_analog.c | |
parent | b7ec38e61a4f92ade80e38744d00311538671179 (diff) |
Little fixes:
- changing random(max) to use stdlib.h random()
- not generating .eep files to avoid warning when EEMEM isn't used
- removing cast macros (since they are automatically defined in C++)
- writing a digital LOW for PWM value of 0 on pins 5 or 6
Diffstat (limited to 'cores/arduino/wiring_analog.c')
-rwxr-xr-x | cores/arduino/wiring_analog.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 30c5642..de0372e 100755 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -89,15 +89,23 @@ void analogWrite(uint8_t pin, int val) OCR1B = val; #if defined(__AVR_ATmega168__) } else if (digitalPinToTimer(pin) == TIMER0A) { - // connect pwm to pin on timer 0, channel A - sbi(TCCR0A, COM0A1); - // set pwm duty - OCR0A = val; + if (val == 0) { + digitalWrite(pin, LOW); + } else { + // connect pwm to pin on timer 0, channel A + sbi(TCCR0A, COM0A1); + // set pwm duty + OCR0A = val; + } } else if (digitalPinToTimer(pin) == TIMER0B) { - // connect pwm to pin on timer 0, channel B - sbi(TCCR0A, COM0B1); - // set pwm duty - OCR0B = val; + if (val == 0) { + digitalWrite(pin, LOW); + } else { + // connect pwm to pin on timer 0, channel B + sbi(TCCR0A, COM0B1); + // set pwm duty + OCR0B = val; + } } else if (digitalPinToTimer(pin) == TIMER2A) { // connect pwm to pin on timer 2, channel A sbi(TCCR2A, COM2A1); |