-
Notifications
You must be signed in to change notification settings - Fork 0
PORT_Arduino
DragonCoder01 edited this page Apr 27, 2020
·
2 revisions
PORT: The Arduino Program
Here I've got the Arduino
version of a blinking LED.
As you can see, it is much more readable than the C
version.
But this readability comes at a cost.
#include <Arduino.h>
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);
}
If you want to know more about the code, look at the repository. I've documented most of the lines for you there! 😃
Flash | RAM |
---|---|
1286 / 32256 Bytes (4.0%) | 9 / 2048 Bytes (0.4%) |
To be fair, this is the result with non standard Arduino
compile options. Here, I am compiling with optimization level -O1
instead of -Os
.
If you compile it with the Arduino
standard options, you'll get something more like this:
Flash | RAM |
---|---|
930 / 32256 Bytes (2.9%) | 9 / 2048 Bytes (0.4%) |
Still, compared to the C
version this Arduino version is on the heavy side.
Some might say that that's the price you have to pay for the gained abstraction. As we will see soon,
we can do better than that. We will gain:
- More functionality
- The same amount of abstraction
- Better Performance (No overhead compared to the C version)
- And all of that using evil C++! With classes!