L’Internet des Objets

L’Internet des Objets

21.1 Support Arduino

Page précédente Page suivante

Pour activer le support Arduino pour les M5stack, il faut ajouter la ligne suivante pour la liste des cartes à ajouter :

https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json

Puis, ajouter M5Stack dans le gestionnaire de cartes. Les cartes devraient alors être disponibles. Il faut ensuite ajouter les librairies M5Stack et ses dépendances. Le code suivant permet de tester si tout s’est bien passé.

#include <M5Stack.h>

/* After M5Core is started or reset
the program in the setUp () function will be run, and this part will only be run once.
After M5Core is started or reset, it will start to execute the program in the setup() function, and this part will only be executed once. */
void setup(){
  M5.begin(); //Init M5Core. Initialize M5Core
  M5.Power.begin(); //Init Power module. Initialize the power module
                    /* Power chip connected to gpio21, gpio22, I2C device
                      Set battery charging voltage and current
                      If used battery, please call this function in your project */
  M5.Lcd.print("Hello World"); // Print text on the screen (string) Print text on the screen (string)
}

/* After the program in setup() runs, it runs the program in loop()
The loop() function is an infinite loop in which the program runs repeatedly
After the program in the setup() function is executed, the program in the loop() function will be executed
The loop() function is an endless loop, in which the program will continue to run repeatedly */
void loop() {

}

La référence pour coder avec l’IDE Arduino est https://docs.m5stack.com/en/quick_start/m5core/arduino. Mais il semble que la documentation ne soit pas à jour. Il est donc recommandé de consulter aussi les exemples.

Page précédente Page suivante