Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define REDPIN D2
- #define GREENPIN D1
- #define BLUEPIN D0
- /* Function prototypes -------------------------------------------------------*/
- int setToPartyMode(String command);
- /* This function is called once at start up ----------------------------------*/
- void setup()
- {
- //Setup the Tinker application here
- pinMode(REDPIN, OUTPUT);
- pinMode(GREENPIN, OUTPUT);
- pinMode(BLUEPIN, OUTPUT);
- digitalWrite(REDPIN, HIGH);
- digitalWrite(GREENPIN, HIGH);
- digitalWrite(BLUEPIN, HIGH);
- //Register all the Tinker functions
- Particle.function("partymode", setToPartyMode);
- }
- /* This function loops forever --------------------------------------------*/
- void loop()
- {
- //This will run in a loop
- }
- /*******************************************************************************
- * Function Name : setToPartyMode
- * Description : Writes an analog value (PWM) to the specified pin
- * Input : Pin and Value (0 to 255)
- * Output : None.
- * Return : 1 on success and a negative number on failure
- *******************************************************************************/
- int setToPartyMode(String command)
- {
- if (command == "turn on lights")
- {
- digitalWrite(REDPIN, LOW);
- digitalWrite(GREENPIN, LOW);
- digitalWrite(BLUEPIN, LOW);
- return 1;
- }
- else if (command == "turn off lights")
- {
- digitalWrite(REDPIN, HIGH);
- digitalWrite(GREENPIN, HIGH);
- digitalWrite(BLUEPIN, HIGH);
- return 1;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment