Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MRuss7
Beginner
907 Views

Turning on LED on Edison board

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 for (var ii=0;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?

Tags (1)
0 Kudos
1 Reply
idata
Community Manager
44 Views

Hello madisoncrusso,

 

 

Thank you for your interest in the Intel® Edison Breakout Board.

 

 

I have to inform you that code debugging is out of the scope of this technical support team.

 

 

I noticed that you posted your inquiry here https://stackoverflow.com/questions/45163142/command-to-turn-on-led-after-finding-word-from-array, I'll suggest you to follow Whitney's suggestion and create an independent LED.js file to test the code that you want to add to the API.

 

 

For more information on using the Edison module with Twitter, you may want to check the following links:

 

https://www.hackster.io/martinkronberg/intel-edison-twitter-api-and-cute-dogs-7619ad

 

http://www.instructables.com/id/Tweet-with-your-Intel-Edison/

 

https://diyhacking.com/home-automation-using-intel-edison-board/ https://diyhacking.com/home-automation-using-intel-edison-board/

 

 

If you have any question related to the Edison module, don't hesitate to contact us.

 

 

Have a nice day.

 

 

Regards,

 

Andres V.
Reply