Close

Arduino Code : Board management

A project log for Gesture/Pattern Recognition Without Camera : TOF !

Grumpy Hedgehog is a connected device that allows you to read and interact with movements. Its LCD screen displays the Hedgehog's expression

jeanperardeljean.perardel 11/07/2021 at 22:160 Comments

Making a generic project allows a maximum of people to reproduce it. That's why I tried to make it compatible with all kind of controllers, even the less powerful ones. 

But I also use some specificities, only present on some controllers to bring more functionality to my project (USB-HID on Teensy, Wifi or Secure Element on MKR 1010). 

To manage several boards in his Arduino project without having compilation problems, I used lines like this 

#ifdef ARDUINO_SAMD_MKRWIFI1010
  #include <WiFiNINA.h>
  #include <BlynkSimpleWiFiNINA.h>
#endif

This will allow to include this library, only if I compile with a MKR 1010 target. 

To manage features like USB HID, I now use this kind of code :

  #ifdef USB_SERIAL
    Serial.println("PASSWORD");
  #endif
  #ifdef USB_HID
    Keyboard.print("PASSWORD");
  #endif

Discussions