513
edits
Line 114: | Line 114: | ||
==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. <br> | |||
Click on the arrow in the right corner in order to add a new file.<br> | |||
Select „new Tab“. | |||
[[File:NewTabARDU.jpg]] | [[File:NewTabARDU.jpg]] | ||
<br> | |||
2.<br> | |||
Enter a filename at the bottom of the window. <br> | |||
It must end with '.h' – In our case it could be 'motorControl.h'. | |||
3.<br> | |||
3. | |||
The first line of your code should be: | The first line of your code should be: | ||
'#include „Arduino.h“' | '#include „Arduino.h“' | ||
This line 'links' the file to the Arduino–specific features. | This line 'links' the file to the Arduino–specific features.<br> | ||
Now we can include the code of our class. | Now we can include the code of our class. | ||
4. | 4.<br> | ||
Go back to your main file. | Go back to your main file.<br> | ||
Now you have to 'link' the new file to your main file in order to use the features of our class. | Now you have to 'link' the new file to your main file in order to use the features of our class.<br> | ||
Include the following line in the top of your main file | Include the following line in the top of your main file | ||
edits