How to adapt your Arduino sketches (I)

In this first example we going to see how to adapt an Arduino code from github to biicode in a simple way. Let’s go!

Arduino sketches work like a charm with biicode

Create a biicode project and copy your code inside

First, create a new biicode project and a block.

The following layout has been created:

Make your code grow with all the power of C++

Ino files to cpp files through biicode

Change your .ino executables to .cpp and add #include “Arduino.h” at the top. To know which are executables or not, just see if the file has the loop() function inside it.

Now, check your unresolved dependencies. There are 3 unresolved dependencies of the file PID_v1.h, it is because the #include paths are relative.

To solve it, just include the PID_v1.h path relative to your block,  /PID_v1, in your biicode.conf. You can change the file’s #include from #include “PID_v1.h” to #include “david/Arduino-PID-Library/PID_v1/PID_v1.h”, but this change broke the compatibility with the Arduino IDE so we prefer  touch the code as little as posible.

Check your deps again and see that the unresolved dependendencies to PID_v1/PID_v1.h have desapiered.

 Build and Upload your Code with biicode

Configure your project

Connect your Arduino and configure the project settings with the info of your Arduino SDK and your board name. If you need help with the name of your board write /o when biicode ask you for the board.

It’s important that you connect your Arduino first.

Plugged Arduino Uno board ready to work with biicode

Now. configure your project.

 Build your code

Now, build your code as usual with biicode. Just execute bii build.

 Upload your Arduino sketches

To upload your code in the Arduino just need to execute bii arduino:upload.

We hope you liked this first example of many to come, feel free to comment below.
As you know, we’re available at our forum or Stackoverflow tag. You can also write us and request features at our roadmap.

Related Posts