Starting Arduino code for the sensor board


#1

Originally published at: https://contextualelectronics.com/topic/starting-arduino-code-for-the-sensor-board/

The resulting code can be found in this repository: https://github.com/ContextualElectronics/CE-Header/tree/master/TeensyConverter/CEheader_translation


#2

Maybe I’m jumping ahead, but I’m wondering if the #defines from this video belong in a .h file? Or an Arduino library (I don’t recall how Arduino handles those)?


#3

@jgalak,

They can be moved. I am not aware of anything that says you need to have them in .h files. Of course if your project has several other files that need to use them, then, that makes sense for including. Maybe as the rest of the code gets fleshed out these will move to a .h file.

If you try something like:

#define jgalak 12
int myvar = jgalak;

right in your sketch file, it will compile fine.

Libraries are just separate groups of files together that provide some functionality. From when I created and published one (DS7505), you typically include one .h and one .cpp files that are named to match your library name. But I don’t know that there is any limit to the number of those you can have to provide supporting functionality.


#4

I think I’m just used to sticking any definitions that I may want to reuse (which presumably I would, using the ce header) into a .h

May just be a style thing.


#5

Come to think of it, what is probably the best idea would be to have ce_header.h that goes something like

#if defined TEENSY
#define CE_spi_cs_gpio3 10
.
.
.
#elif defined ARDUINO
#define CE_spi_cs_gpio3 X
.
.
.