Changing parts of code on the fly via wifi and android app

Hi all,

I am starting a new project and remembered I have a Spark Core bought from KS and therefore wanted to give it a try (finally !!!) and play with the wifi feature.

Good thing is that for the last month I have been working with Arduinos and I feel more confident now.
Usually, I communicate via serial port with my Arduino, or via physical devices (buttons, pot etc). But now, I really want to take advantage of the wifi feature to send some stuff to the Arduino.

Here is basically what I want to do :

I have a set of LEDs that will display a message (text) or patterns for effects. The content of the message or pattern is coded in a certain way (basically it is not “test = ‘hello world’”, it’s more complicated than that because of the animations, scrolling etc). The whole thing is hardcoded in the arduino and then the stuff are “displayed” on loop (i.e. message 1, then animations, then message 2, then back to message 1). This is the project of my inspiration:

What I would like to do is to be able to send what I want to display, via wifi and even better if I could do this via my Android phone.
I would have an app where I would select predefined animations, or where I could write a text, then the app would convert it into the code, and then it would be sent as a data to the Spark Core.

My question is the following : can this be possible ? can I have my program on the Spark Core, and then send via wifi some data, that would be complementary to my code and lead to an actions. Can this be done via wifi (since it is a Spark core feature)?
If so, where could I look at in order to start playing around, and even better, to do a simple Android app to do so?

The code on the instructable page (the ‘animations’ part in the middle and at the end of the code) is what I want to be able to send via wifi on the fly, the rest would remain unchanged, hence making the whole thing ‘variable’ and being able to send text/animation on demand, and not having to rewrite the whole code to change the text I want to display:

Thank you very much for any help !


So, you don’t really need to send ‘code’ rather just the data for which you want to display… the program embedded on your Core or Photon would then react based on the kind of data you send. There are many examples of this on the forum, though I cannot recall seeing exactly your use case (a pixel animation file).

So yes you could do that. The size of the data file that you wish to send may require you to add external memory.

@day, just to add to what @BulldogLowell said, the Photon code would need to implement all the effects you want in firmware. The “command” is send from your phone would contain the sequence of effects you want displayed along with any data (text, etc.) and your firmware would parse those commands and go about displaying them in a loop. Can I ask what LED display you intend to use?

Hi and thank you for your answers !

@BulldogLowell : so you mean, I would rewrite a function that would take my input, and make an output that looks like the animation code that you can see in the txt file (last link) ? so I could send "hello world ! " and the Core would do the rest. but what about animations ? if I want to do a wave, then fake eyes etc, I would need to create all animations first, then send “#eyes#” or “#wave#” etc, that’s what you meant ?
if so, that seems like a good deal, I won’t have total freedom on creating effects on the fly, only choosing from what I wrote before, but that’s ok.
About the external memory, what would be the data file size limit ? sending a sentence or keywords would do the trick or is that already too much of memory ?

@peekay123 : ok I see, so in fact, everything would be pre written on the Core, then I would send either keywords for effects, or a text, for…a text, and the Core would do the rest, converting the input to the right ouput
I use all the components that you see on the instructables link, it was a kickstarter project at first, so I have all that you see on the page. Basically, it’s a home made LED display.

Do you happen to know where I can find examples of such code (sending command via wifi, not updating the firmware via wifi) ?
Also, I heard about Android apps. I never wrote any, so I am wondering if there is a kind of template app, that I would be able to use and change to my needs and that would do the trick (sending text via wifi) ?

Thank you for your help !

@day, if you display is small, you could send “image” data to do simple, sprite-type animations. If your bitmaps are monochrome and small, they could be transferred in a few bytes. The core would have all the display and animation logic. The core has an external 1MB flash that can be used via the flash-eeprom library. I would be great for storing animations and stuff.

If you search for “neopixel” or rgbpongclock in the forums, you’ll see examples of somewhat similar projects.

1 Like