513
edits
Line 115: | Line 115: | ||
==Organizing classes in separate files== | ==Organizing classes in separate files== | ||
We can improve our program structure by putting classes in separate files | We can improve our program structure by putting classes in separate files: | ||
:1. | |||
:Click on the arrow in the right corner in order to add a new file. | |||
:Select „new Tab“. | |||
:[[File:NewTabARDU.jpg]] | |||
:2. | |||
Enter the | :Enter a filename at the bottom of the window. | ||
:It must end with .h – In our case it could be 'motorControl.h'. | |||
:3. | |||
:The first line of your code should be: | |||
' | :'#include „Arduino.h“' | ||
#include „Arduino.h“ | |||
:This line 'links' the file to the Arduino–specific features. | |||
:Now we can include the code of our class. | |||
:4. | |||
:Go back to your main file. | |||
:Now you have to 'link' the new file to your main file in order to use the features of our class. | |||
:Include the following line in the top of your main file | |||
Go back to your main file. | |||
Now you have to | |||
Include the following line in the top of your main file | |||
:'#include "MotorControl.h“' | |||
:and write the rest of your program as usual. | |||
==More details on the concept== | ==More details on the concept== |
edits