Jump to content
43oh

CC3200 to IFTTT - I am missing one piece to complete my project


Recommended Posts

The code I am using allows me to press SW2 or SW3 and send a notification to IFTTT. I can't figure out how to identify which switch was press so I can send that information to IFTTT. Currently I can press SW2 and press SW3 and both will send a notification to IFTTT but I don't know how I can separately identify which button was pressed. Any direction would be appreciated. 

 

Code Below

 

 /* Enable internal pullup. 
   * Without the pin will float and the example will not work */
  pinMode(PUSH1, INPUT_PULLUP);
  attachInterrupt(PUSH1, sendRequest, FALLING); // Interrupt is fired whenever button is pressed
  
  Serial.println("Button 1 has been activated!");
  
  
  /* Enable internal pullup. 
   * Without the pin will float and the example will not work */
  pinMode(PUSH2, INPUT_PULLUP);
  attachInterrupt(PUSH2, sendRequest, FALLING); // Interrupt is fired whenever button is pressed
  
  Serial.println("Button 2 has been activated");
}
 
void loop() {
  String IFTTT_KEY = "KEY";
  String IFTTT_EVENT = "Button 1 has been activated"; 
  if(trigger == 1){
    ifttt_trigger(IFTTT_KEY, IFTTT_EVENT); 
    Serial.println("Button 1 has been activated");
    trigger = 0;
  }
 
}
Link to post
Share on other sites
  • 4 weeks later...

Use different functions for each button in attachInterrupt(): e.g. sendRequest1 and sendRequest2 then create another function calling it from the  sendRequest1 / sendRequest2 that takes the button number as argument to be able to distinguish between buttons. Set trigger to the button number and then process that in loop().

Link to post
Share on other sites
  • 8 months later...
On 10/4/2016 at 1:17 PM, energia said:

Use different functions for each button in attachInterrupt(): e.g. sendRequest1 and sendRequest2 then create another function calling it from the  sendRequest1 / sendRequest2 that takes the button number as argument to be able to distinguish between buttons. Set trigger to the button number and then process that in loop().

Is there example code I can look at?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...