1 Reply Latest reply on Jul 19, 2017 10:24 AM by Intel Corporation

    Turning on LED on Edison board

    madisoncrusso

      Using Twitter's API, I have written a command to send an alert whenever a Tweet containing specific words is found in my news timeline. These words are currently broken out into three different arrays. I would now, however, like to use this alert to turn on an LED whenever a word in one of these arrays is found.

       

      This is the code I am using for the LED:

       

      var groveSensor = require('jsupm_grove');

       

      var led = new groveSensor.GroveLed(3);

        led.on();

       

       

      I am just not sure how to display it in my API... Currently, I have the code at the top, before the API, and then the "on" / 'off" command after each array. This has only resulted in the LED's turning off, though.

       

      var params = {screen_name: 'myusername'};
      client.get('statuses/home_timeline', params, function(error, tweets, response)
      {

       

      if (!error) {
      for (var i=0;i<tweets.length;i++){
      for (var ii=0;ii<techArray.length;ii++){
      if(tweets[i].text.indexOf(techArray[ii])>-1&&tweets[i].id_str*1>lastId)
      {

       

      console.log("-----found a tech article - " + tweets[i].text + "-------"
      + tweets[i].text.indexOf(techArray[ii]));

       

      var led = new groveSensor.GroveLed(3);
      led.on();

      }

       

      else {

      var led = new groveSensor.GroveLed(3);

      led.off();

       

      }

       

      Any idea where/how I should actually write this command?