Пример #1
0
void Simon::setup() {
    b = InternetButton();
    solution = new Position[0];
    solutionSize = 0;

    state = Welcome;

    difficulty = 3;
    successMax = 0;
    successCount = 0;
    
    
    RGB.control(true);
    b.begin();
    b.allLedsOff();
}
Пример #2
0
#include "InternetButton/InternetButton.h"
#include "math.h"

/* Let me show you how easy it is to put the Button on the Internet.
Useful info, like how to access the data from your browser, can be
found here: https://docs.particle.io/reference/firmware/photon/#particle-function-

The code to control the number of illuminated LEDs is here:
https://github.com/spark/InternetButton/blob/master/controlKnob.html
Try naming one of your devices "InternetButton" and running controlKnob in your browser or on your phone!
Note that the Core or Photon *must* be named "InternetButton" because the javascript looks for it.
*/

InternetButton b = InternetButton();
float brightness = 0.1;
int red, green, blue;
int howMany = 6;
int whichColor = 100;
bool changed = false;

void setup() {
    // Use b.begin(1); if you have the original SparkButton, which does not have a buzzer or a plastic enclosure
    // to use, just add a '1' between the parentheses in the code below.
    b.begin();

    //This is all you need to make the function controller() available to the internet
    //The API name and the local name don't need to be the same; just my style
    Particle.function("controller", controller);

    //This function figures out what combination color, brightness and LEDs to display
Пример #3
0
#include "InternetButton/InternetButton.h"
#include "InternetButton2.h"


// Create a Button named b. It will be your friend, and you two will spend lots of time together.
// You may be wondering about those two slashes and this gray text- they're called comments, and
// don't affect the code. Think of this as the voice of the narrator.
InternetButton2 b = InternetButton();

// The code in setup() runs once when the device is powered on or reset. Used for setting up states, modes, etc
void setup() {
    // Tell b to get everything ready to go
    // Use b.begin(1); if you have the original SparkButton, which does not have a buzzer or a plastic enclosure
    // to use, just add a '1' between the parentheses in the code below.
    b.begin();
}

/* loop(), in contrast to setup(), runs all the time. Over and over again.
Remember this particularly if there are things you DON'T want to run a lot. Like Spark.publish() */
void loop() {
    // Let's turn an LED on. How about #6, which is at the 6 o'clock position? Let's make it blue and bright.
    b.ledOn(6, 0, 0, 255);
    // The format here is (LED, red, green, blue), so we're making a color with no red or green, but ALL the blue
    // You should know that the range of brightness here is 0-255, so 0 is off and 255 is the most possible.
    // After you use this code, try making the LED white- all the red, green, and blue.

    // Since the LED is now on, let's have it stay that way for one second
    // Delay pauses the code for the amount of time given, in milliseconds- so 1000 millis is one whole second
    delay(1000);

    // And to blink the LED, we'll need to turn it back off and then pause for another second
Пример #4
0
#include "InternetButton/InternetButton.h"

InternetButton button = InternetButton();
void setup() {
  //agregar un 1 si es el SparkButton original
  button.begin(); 
  Particle.function("allOn", allOn);
  Particle.function("allOff", allOff);
}

void loop() {
}

int allOn(String args) {
  int firstCommaPosition = args.indexOf(",");
  int lastCommaPosition = args.lastIndexOf(",");

  int r = atoi(args.substring(0,firstCommaPosition));
  int g = atoi(args.substring(
                      firstCommaPosition+1,lastCommaPosition));
  int b = atoi(args.substring(lastCommaPosition+1));
  
  button.allLedsOn(r,g,b);
  return 1;
}

int allOff(String args) {
  button.allLedsOff();
  return 1;
}