Creating a simple program

After creating a new empty PlatformIO project you're ready for the next step.


Preparation

The PlatformIO project structure consists of the following:
  • platformio.ini (Project Configuration File)
  • src directory where you should place source code (*.h, *.c, *.cpp, *.S, *.ino, etc.)
  • lib directory can be used for the project-specific (private) libraries
Now you need to download the necessary libraries and configuration files from our GitHub repository and place them in your project directory.


Writing a simple program

We're now going to write a simple program. Here's a quick example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <Arduino.h>
#include <CircuitOS.h>
#include <Spencer.h>
 
void setup() {
	Spencer.begin();
	Spencer.loadSettings();
 
	LEDmatrix.startAnimation(new  Animation( new SerialFlashFileAdapter("GIF-heart.gif")), true);
}
void loop() {
	LoopManager::loop();
}

Next steps

Turn on your Spencer and plug it into your computer with a USB cable.

Click the Upload button on the bottom left part of the screen (arrow pointing to the right).

Click on the arrow pointing to the right

You have now uploaded your code on the Spencer!