Send code to arduino

Hi guys !
I was wondering If there was a way to send a part of code from the Photon to an Arduino. A function or a IF statement. The idea here is to be able to send new mood from a web page to an Arduino.
Any idea are welcome !

Thanks !

If you got some sort of interpreter running on your Arduino that takes strings as input, interprets it and runs the script then yes.

Anything else would be a bit complicated (to say the least)

When you are writing Arduino code (or for the Photon) the text you write is nothing like the bits and bytes the device sees.
It goes through a lot of “translation” done by a powerful set of tools to turn it into hardware specific machine code.
But even if you’d send over machine code, having the µC run that code from RAM rather than flash as usual would require a lot of work on and by the original Arduino firmware.

Not saying it’s impossible, but I’d see it highly unlikely.

One the other hand reflashing the Arduino the “normal” way via a computer that receives code snippets from anywhere (including a Photon), incorporates it into an Arduino sketch and flashes it to the Arduino (maybe triggered by a Photon) is definetly doable, but seems not too practical :wink:

What do you mean by some sort of interpreter ? Do you have an exemple ?

And I guess It would be the same thing for the Photon ? There is no way to be able to code on a text box in a web page and send this code to the Photon so that it can run it ?

Thanks for your answers !

The easiest would be to send certain commands to the arduino. Let the Core/Photon do the If/else statements and then send a certain command to the arduino. The arduino would take the command and execute actions accordingly to it.

Scripting would be hard to do though. (scripting is what you suggested in your TS)

Yes that was my alternative, but that limit the possibilities.

Explain your project a bit more so it is easier for us to help :slight_smile:

Well I made a mood lamp based on WS2811 led strips and I want to be able to create mood from the web app that I made, not only change some options (variables) from the mood that I have already created. Right now I’m using a MySQL database for the communication, but I was thinking about communicating directly with the Photon (with Spark function). The strips are connect to the Arduino and the Spark is filtering the data coming from the web.

I think that resume the project !

There are interpreted languages (e.g. BASIC, Python, JavaScript, ...) and compiled languages (e.g. C/C++, ...)

http://www.programmerinterview.com/index.php/general-miscellaneous/whats-the-difference-between-a-compiled-and-an-interpreted-language/

What @TheHawk1337 suggested above could be considered a very basic non-standard-language interpreter that translates your commands into a predefined set of actions and executes them.

1 Like