Go Down

Topic: analogWrite low for ground (Read 478 times) previous topic - next topic

suicidalacorn

sorry if this is in the wrong place, this seemed to fit it best.
if i use analogWrite function to write a pin (non pwm) to low, that makes it a ground. i know it works because i have tried it. but...will this do any type of damage to the arduino?

PeterH

It'll be fine, as long as you don't ask it to sink more than about 20mA.
I only provide help via the forum - please do not contact me for private consultancy.

suicidalacorn


It'll be fine, as long as you don't ask it to sink more than about 20mA.

ok. thank you!

GoForSmoke


if i use analogWrite function to write a pin (non pwm) to low,


Why use analogWrite to a non-pwm pin at all?
Write the pin LOW and set it to OUTPUT.

And here's the fun part. You can switch modes and states in no time flat on the same pin. It's not set in stone, it's made to be versatile and fast.

Some of the neatest code does that. There's a sketch that uses 2 pins, 1 led and 1 resistor to read the ambient light level with the led then change to pulse the led to make light at controlled brightness so it's not too bright or too dim.. many times a second. Just to read light with a led uses mode and state switching.

Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up