Post about your Basic project here

Moderator: Mmiscool

User avatar
By viscomjim
#38373 Image

My daughter is having her first child, my first grandchild, and I built a framed mirror with some graphics and her name etched from the backside, so light from the back of the mirror will travel through the etched areas. I put rgb leds inside the frame to light it up using neo pixels. This little program, maybe not the most efficient way of doing it, works quite well using twitter to change the color of the backlights. So any one of her friends can tweet a hashtag and change the color if they know the hash tag.

Since I haven't figured out how twitter can pass values along with the hashtag, the color has to be part of the hashtag, no big deal... something like this... #kidsnamepink, or #kidsnamewhite, etc. So then I just check the hashtag and see if a predefined color name is there and change the color accordingly. It seems that you can add as many triggers as you like to one thingspeak channel, so I have added a few. I check the channel every 5 seconds to see if the color is different.

This is an example of using twitter to do something, very similar to cheerlights, but where you can pass data without having your own special filter word like "cheerlights". Because of this you have to use a filter word that thingspeak will catch. These are the ones that work...

#thingspeak
thingspeak
#tweetcontrol
tweetcontrol
#cheeerlights
cheerlights

So to control your own stuff, you have to tweet something like this...

#tweetcontrol #kidsnamered

And the lights will turn red. Works well and can be adapted to do ANYTHING!!!!

The cool part about the way TS checks is that you can put any amount of text in your tweet as long as the filter word and trigger word are present. So "I command #tweetcontrol to change color to #kidsnamered" will also work.

Here are the details to setting up your triggers...

http://www.mathworks.com/help/thingspea ... hworks.com

Here is my first pass at the code, hope to improve it as time goes on.

Have fun!

Code: Select allmemclear
timer 5000 [checkts]
wait
[checkts]
cls
button "Exit " [Exit]
tsread$ = readts(TSREADKEY,CHANNEL#,1)

serialprintln ""
serialprintln "***************************************************"
serialprintln ""
serialprint "READ FROM TS = "
serialprintln tsread$
serialprintln ""
serialprintln "***************************************************"
if instr(tsread$,"purple") > 0 then goto [dopurple]
if instr(tsread$,"red") > 0 then goto [dored]
if instr(tsread$,"blue") > 0 then goto [doblue]
if instr(tsread$,"green") > 0 then goto [dogreen]
if instr(tsread$,"yellow") > 0 then goto [doyellow]
if instr(tsread$,"pink") > 0 then goto [dopink]
if instr(tsread$,"teal") > 0 then goto [doteal]
if instr(tsread$,"orange") > 0 then goto [doorange]
if instr(tsread$,"white") > 0 then goto [dowhite]
wait
[dored]
serialprintln "red"
redled = 255
grnled = 0
bluled = 0
gosub [setledcolor]
wait
[dogreen]
serialprintln "green"
redled = 0
grnled = 255
bluled = 0
gosub [setledcolor]
wait
[doblue]
serialprintln "blue"
redled = 0
grnled = 0
bluled = 255
gosub [setledcolor]
wait
[doyellow]
serialprintln "yellow"
redled = 255
grnled = 255
bluled = 0
gosub [setledcolor]
wait
[dopink]
serialprintln "pink"
redled = 255
grnled = 102
bluled = 178
gosub [setledcolor]
wait
[doteal]
serialprintln "teal"
redled = 0
grnled = 204
bluled = 204
gosub [setledcolor]
wait
[doorange]
serialprintln "orange"
redled = 255
grnled = 128
bluled = 0
gosub [setledcolor]
wait
[dopurple]
serialprintln "purple"
redled = 127
grnled = 0
bluled = 255
gosub [setledcolor]
wait
[dowhite]
serialprintln "white"
redled = 255
grnled = 255
bluled = 255
gosub [setledcolor]
wait
[setledcolor]
neostripcolor(0,4,redled,grnled,bluled)
return

[Exit]
timer 0
wprint "<a href='/'>Menu</a>"
end


You have to set up your own TS account and use the ThingHTTP and TweetControl apps as described in the documentation. This is where you will get your read and write keys and be able to set up your Twitter triggers.

P.S. this works only with the nodeMCU board, not the esp-01. Use gpio as described at http://www.esp8266basic.com (D8). I AM TAPPING MY HEALS TOGETHER... I wish this would work on the esp-01, I wish this would work on the esp-01, I wish...

Here is code without serial output that was used for debugging...

Code: Select allmemclear
timer 5000 [checkts]
wait
[checkts]
cls
tsread$ = readts(TSREADKEY,CHANNEL#,1)
if instr(tsread$,"purple") > 0 then goto [dopurple]
if instr(tsread$,"red") > 0 then goto [dored]
if instr(tsread$,"blue") > 0 then goto [doblue]
if instr(tsread$,"green") > 0 then goto [dogreen]
if instr(tsread$,"yellow") > 0 then goto [doyellow]
if instr(tsread$,"pink") > 0 then goto [dopink]
if instr(tsread$,"teal") > 0 then goto [doteal]
if instr(tsread$,"orange") > 0 then goto [doorange]
if instr(tsread$,"white") > 0 then goto [dowhite]
wait
[dored]
redled = 255
grnled = 0
bluled = 0
gosub [setledcolor]
wait
[dogreen]
redled = 0
grnled = 255
bluled = 0
gosub [setledcolor]
wait
[doblue]
redled = 0
grnled = 0
bluled = 255
gosub [setledcolor]
wait
[doyellow]
redled = 255
grnled = 255
bluled = 0
gosub [setledcolor]
wait
[dopink]
redled = 255
grnled = 102
bluled = 178
gosub [setledcolor]
wait
[doteal]
redled = 0
grnled = 204
bluled = 204
gosub [setledcolor]
wait
[doorange]
redled = 255
grnled = 128
bluled = 0
gosub [setledcolor]
wait
[dopurple]
redled = 127
grnled = 0
bluled = 255
gosub [setledcolor]
wait
[dowhite]
redled = 255
grnled = 255
bluled = 255
gosub [setledcolor]
wait
[setledcolor]
neostripcolor(0,4,redled,grnled,bluled)
return
end


Change the "4" in the 3rd to last line depending on how many leds you are using. 4 was just for testing. I believe you can go up to 1024, but not sure.
Last edited by viscomjim on Tue Jan 12, 2016 9:31 pm, edited 6 times in total.
User avatar
By Mmiscool
#38630 This is awesome. Thank you for sharing. Just an FYI. I submitted a link to this to hack a day.
User avatar
By Mmiscool
#39114 Looks like this was featured on hack a day

http://hackaday.com/2016/01/15/hacker-w ... led-frame/