If you're finding the Arduino Reference a bit dry you need this page.
On this Arduino reference page you can find links to common Arduino
functions so you can find out how they work, and how you should use
them. Some functions are obvious while others have obscure and subtle
problems of which you should be aware e.g. abs, strtok, map and more.
This is a more complicated question than just "what
compiler the Arduino system" uses; it is more about the complete Arduino environment.
Click to open Arduino Hello World page.
Find out exactly what 'Arduino Serial begin' does,
and what it's for; Why you shouldn't use the number 9600...what does it
mean anyway? Find out here.
Serial begin initialises the serial hardware module in the Arduino so you can communication from PC to Arduino or vice versa.
The number 9600 is not the optimum number to use; Find out why in the link below:
Click to open Arduino Serial Begin page.
Or is Serial data Ready Yet? Normally your program will work the way you expect
but sometimes it won't. What are the interactions that could make your
program Fail? Find out Here.
Serial available can cause problems when your Arduino is busy doing
lots of other work. Find out what the effects are and what to do about
it.
Click to open Arduino Serial Available page.
Arduino
Serial Read: Or how to
control your Arduino from a PC! Find out how the Serial read
function works to receive multiple bytes using interrupts and buffers. Understand
its Internal Operation so you Don't Fall into a Trap...
Arduino Serial read looks like a simple function and in
normal use it behaves exactly as you would expect making reading data
from the serial port a trivial and easy matter. However it is useful to
understand its internal operation as you can sometimes fall into a trap
where you lose data. Find out more in the link below...
Click to open Arduino Serial Read page.
The Arduino absolute value function is a fairly simple function but
there is a trip-up in the way it is implemented on the Arduino system.
This is likely different to other C implementations.
Click to open Arduino absolute value page.
Click to open Arduino analogRead value page.
Find out the capabilities of the internal PWM generators in the Arduino:
You can find code and the algorithm used to perform this useful task.
Another useful algorithm on the page is a radix conversion variation of
atoi that allows you to convert from hexadecimal or binary strings.
Click to open Arduino String to int page.
The Arduino delay function takes an argument representing the number
of milliseconds to delay. Although it is used a lot, it is a blocking
function. When you get more complex projects you can not afford for the
processor to do nothing (as occurs with the delay function). The alternative is
the millis Arduino function.
Click to open Arduino delay page.
Here you can find out exactly how the function works with source code explanation and how to use macros to get faster operation.
Click to open Arduino digitalWrite page.
There is one function that allows you to convert a float into a string easily but it can cause problems.
Click to open Arduino float to string page.
The for-loop is the main construct used to step through a series of values. It allows you to :
So you can set the start and exit conditions while updating a
variable up or down. In addition you can repeat a block of code while
the variable is updated.
Click to open Arduino for-loop page.
The Arduino conditional construct allows your code to make decisions
based on input variables. It gives you the standard if, then, else
decision making code that is common to all programming languages.
Find out how it is used in C/C++ in the link below.
Click to open Arduino if-else page.
Arduino int to string: How to convert an integer to a string. Find
out the standard form and Learn how to code it yourself. Also find the
one subtle error you missed.
Here you will find out how to convert an integer into a string, using
the standard function itoa but if you want to know how it really does its
magic this page will also show you fundamental code for conversion of
Arduino int to strings.
Click to open Arduino int to string page.
The Arduino map function should be an obviously simple implementation
of mapping one range of values to another range of values but there is a
subtle problem that will not evenly distribute the ranges. Find out how to fix it in
the link.
Click to open Arduino map page.
The Arduino millis function, returns only the number of elapsed
milliseconds since reset of the board. Unlike delay, millis is a
non-blocking function. You can use it to time events while also allowing
the processor to do other tasks. You can also uses it in an equivalent,
but non-blocking way, to the delay function by calculating timing
delays.
There is a subtle 'feature' in the millis code that forces it to occasionally skip values - find out more in the link.
Click to open Arduino millis page.
Click to open Arduino pinMode page.
The functions are:
Click to open Arduino pulseIn page.
The function shiftIn is a serial to parallel converter that you can
use to get data from chips that send out data when driven by a clock
signal.
This is a software implementation of part of the SPI protocol and is consequently slower but can operate on any pin.
Click to open Arduino shiftIn page.
The function shiftOut is a parallel to serial converter that you can use
to send data to chips that accept data when driven by a clock signal.
This is a software implementaion of part of the SPI protocol and is consequently slower but can operate on any pin.
Click to open Arduino shiftOut page.
The switch-case construct allows you to minify your decision making
code if you use it in the right way. there is one pitfall that you
should avoid: described in the link below.
Click to open Arduino switch-case page.
Find out the difference between C strings and C++. You can observe
the differences with an example that shows how to decode a serial
command stream in both C and C++ string versions.
Also find out if there are any problems in either C strings or C++ strings [to do with memory usage - hint C++ uses the heap].
Click to open Arduino string page.
The Arduino strtok function is a function that steps through a string
rejecting some characters (the delimiters) while keeping other
characters (the tokens). At each call the function returns a pointer to
each set of tokens in turn.
Click to open Arduino strtok page.
The Arduino while-loop is another construct that lets you repeat
code. However in this case it is simpler that the for-loop. Since it
only has a condition for exit it allows you to write clearer code if it
can be used instead of a for-loop.
Unlike the for-loop you have to implemnent the variable increment
or decrement within the while loop block. Sometimes you need this for
the problem you are trying to solve.
The other form of the while-loop is the do-while-loop that always
executes some code before testing the exit condition. This can also be
useful in many use-cases.
Click to open Arduino while-loop page.
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.