Paso 4: Cargar el código
Una vez haya conectado el fotón partícula a internet ahora es momento de subir el código a la Junta. El código contiene dos funciones que, cuando se encienden todos los LED en el botón de internet para un respectivo color. Ejemplo el conjunto de un nuevo correo electrónico de colores es rgb (250, 0, 0) que es rojo.
Puede crear funciones similares y cambiar el color de los LEDs como usted tiene gusto.
#include "SparkButton/SparkButton.h" // include spark internet button librarySparkButton b = SparkButton();void setup() { Spark.function("gmail",gmail); // function for email notification Spark.function("twitter",twitter); //function for twitter notification b.begin(); } void loop() { // no code in here } int def(){ b.allLedsOn(0,0,255); // default green color, change this to change the color of the mood lamp } int gmail(String args){ // email function b.allLedsOn(255,0,0); delay(600000); def(); // Change to default color after 10 minutes } int twitter(String args){ // twitter funciton b.allLedsOn(0,0,255); delay(600000); def(); // Change to default color after 10 minutes }