void loop(){...

So I'm very new to the arduino scene and i've just been perusing all of the software's predone example sketches and have even done just a few very basic little projects (fading an led with a force resistor.)

I have a question concerning the two function nature of the sketches. Is there no way to implement a modular feel to this? I'm very used to creating functions and then calling them whenever i please. would i be able to do this within this environment? or would i have to write my own libraries (i don't even know if i can this is outside my experience). At this point in my career i have only a couple semesters of programming and mostly a whole lot of electrical engineering courses under my belt.

The setup() and loop() functions are the two you have to provide. You're at liberty to define and call additional functions in your sketch, without writing a library.

So then it is really just like C in that i can define them outside of the loop or setup function and then call them as i please! thank you for the good news thinking about it i'm not sure why i thought that i might not be able to.

Arduino sketches are in reality C++ programs. The main differences between writing Arduino sketches and writing regular C/C++ programs are:

  • The Arduino environment generates the .h file for you, which means you don't need to forward-declare functions;
  • The entry points are setup() and loop() instead of main;
  • Some features of C++ are not supported (e.g. exceptions and the STL) because of the limited memory space.

dc42:
Arduino sketches are in reality C++ programs. The main differences between writing Arduino sketches and writing regular C/C++ programs are:

  • The Arduino environment generates the .h file for you, which means you don't need to forward-declare functions;
  • The entry points are setup() and loop() instead of main;
  • Some features of C++ are not supported (e.g. exceptions and the STL) because of the limited memory space.

Nominated for a Sticky Topic!

i can define [additional functions] outside of the loop or setup function and then call them as i please! thank you for the good news

I knew, somehow, that that just had to be, but I didn't know how at first, either. It'd be tough getting anything done otherwise. PaulS got me dialed in on that. "Blink" should be followed immediately by "Blink with Functions". :slight_smile: