3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Arduino is Slow - and how to fix it!

Step 2A and B watch out, C is here

A and B watch out, C is here
Now it is time for the “true c” style statements! The thing is, there are quite a few of them and they all do the same thing. It gets confusing, but basically it boils down to changing a port register in some way.
 
There are many right ways to do it, but here is the way that I found to be the simplest. To turn a port high, use this command:
PORT{letter} |= _BV(P{letter}{number});
 
To turn a port low, use this command:
PORT{letter} &= ~_BV(P{letter}{number});
 
Replace {letter} and {number} with the corresponding pin letter and number. For example, for pin B5 with the LED, turning it high and then low would be:
PORTB |= _BV(PB5);
PORTB &= ~_BV(PB5);
 
Note that | can be found to the left of the backspace key, on the same key of the backslash.

So, basically, you can replace the entire digitalWrite() command with the above to get a faster response!
 
But how much faster is it, really? It is time for an experiment!
« Previous StepDownload PDFView All StepsNext Step »
1 comment
Nov 20, 2009. 10:06 AMghaon says:
 So do you then use the AVR Studio 4? 
Or how do you program an Arduino in this way?
Can you use the Arudino's usb ftdi connection?

Please elaborate. Thanks!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
21
Followers
9
Author:RazorConcepts
Check out razorconcepts.net for some projects.