I have read about Arduino, and how it uses a language that is similar but not equal to C. I am very familiar with C++, and I was wondering how one would do basic tasks with the Arduino, such as communicating with the I/O pins. I figure that one would need the memory address to the pins, and then do something like this for a "flashing led":
int main() {
while (1) {
bool * out_pin = /* Whatever that memory address was for that pin */;
*out_pin = 1;
// Some sort of sleep function? (I only know of "windows.h"'s "Sleep" function)
*out_pin = 0;
}
return 0; // Kind of unneeded, I suppose, but probably compiler errors otherwise.
}
I'm probably really wrong: that's why I'm asking this question.
pin_name = pin_value;(likePORTD = 7;) and the compiler does the magic.pin_name" Is it abool *or something else? And can you later do what I did modifying the value (and such)?PORTD = 7;is compiles it to the necessary assembly code to load a 7 into the PORTD register. When it seesi = PORTD;is loads the value from the PORTD register and stored it in the variablei. The compiler just makes it work.