Guest User

Untitled

a guest
Aug 9th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. #define REDPIN D2
  2. #define GREENPIN D1
  3. #define BLUEPIN D0
  4.  
  5. /* Function prototypes -------------------------------------------------------*/
  6. int setToPartyMode(String command);
  7.  
  8. /* This function is called once at start up ----------------------------------*/
  9. void setup()
  10. {
  11.     //Setup the Tinker application here
  12.     pinMode(REDPIN, OUTPUT);
  13.  
  14.     pinMode(GREENPIN, OUTPUT);
  15.  
  16.     pinMode(BLUEPIN, OUTPUT);
  17.     digitalWrite(REDPIN, HIGH);
  18.     digitalWrite(GREENPIN, HIGH);
  19.     digitalWrite(BLUEPIN, HIGH);
  20.     //Register all the Tinker functions
  21.     Particle.function("partymode", setToPartyMode);
  22.  
  23.    
  24. }
  25.  
  26. /* This function loops forever --------------------------------------------*/
  27. void loop()
  28. {
  29.     //This will run in a loop
  30. }
  31.  
  32. /*******************************************************************************
  33.  * Function Name  : setToPartyMode
  34.  * Description    : Writes an analog value (PWM) to the specified pin
  35.  * Input          : Pin and Value (0 to 255)
  36.  * Output         : None.
  37.  * Return         : 1 on success and a negative number on failure
  38.  *******************************************************************************/
  39. int setToPartyMode(String command)
  40. {
  41.     if (command == "turn on lights")
  42.     {
  43.         digitalWrite(REDPIN, LOW);
  44.    
  45.         digitalWrite(GREENPIN, LOW);
  46.    
  47.         digitalWrite(BLUEPIN, LOW);
  48.        
  49.         return 1;
  50.     }
  51.     else if (command == "turn off lights")
  52.     {
  53.         digitalWrite(REDPIN, HIGH);
  54.    
  55.         digitalWrite(GREENPIN, HIGH);
  56.    
  57.         digitalWrite(BLUEPIN, HIGH);
  58.        
  59.         return 1;
  60.     }
  61.     return -1;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment