Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Tiny delay in digitalWrite causing some timing issues
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Tiny delay in digitalWrite causing some timing issues

by magician13134 on Thu Sep 15, 2011 8:35 pm

Hello everyone, I'm tweaking some code on a small project that I'm working to try to get it better than it is now. It's very simple, just an ATTiny85 using 5 IO pins to control LEDs. I wrote, compiled and uploaded the code in the Arduino environment so I'm simply using DigitalWrite to control them. However, when I want to flash them all at once, I just do five DigitalWrite commands in a row to turn them all off or all on, but you can actually see the LEDs turning off one by one, it's not quite instantaneous and it irks me. I was just wondering if there was a way to tell all of the pins to turn on or off in one command?

Also, speeding up the clock is not an option, it is a very power-conscious project. Thank you for any help.
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

Re: Tiny delay in digitalWrite causing some timing issues

by westfw on Fri Sep 16, 2011 1:02 am

If you use direct port writes, you can turn a whole port worth of bits at one time (and on a tiny85, all the pins there are are on a single port...) It would look something like:
PORTB = 0x3F; // set all outputs HIGH.

westfw
 
Posts: 1736
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Please be positive and constructive with your questions and comments.