513
edits
Line 117: | Line 117: | ||
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 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“' | |||
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 | |||
'#include "MotorControl.h“' | |||
and write the rest of your program as usual. | |||
<br> | <br> | ||
edits