Go Down

Topic: JavaScript -> ? -> arduino (Read 1 time) previous topic - next topic

cman

I have a mega and a tl wr703n on the way.
I'd like to pull up a page hosted on the 703 and use JavaScript (ajax) to control the mega which will generate PWM.
I'm a web guy so this seems like a reasonable undertaking to me.
I have no experience with arduino though.  I am goin to run openwrt on the 703.

My question is this...
Can the arduino interface with JavaScript natively, or is there some kind of translator that has to sit between the js and the arduino? If so is that open source?
I feel like if I could find one example of say turning on a led with js then I would understand a bit better.

Any suggestions where to start?
I'm eager to start understanding.

Goofballtech

Arduino is built on c++. No javascript that i know of.

How do you plan to get the data from your router to the arduino? Perhaps UDP or TCP and a networking shield?

You can have the javascript output a packet\ that contains the information you need then have the arduino recieve that packet and use it to control whatever needs the PWM signal.

holmes4

You need to send/get data from the Arduino to and from the PC. You can do this in lots of ways. Via the comms port over e-net, WiFi and many others.

So the question is can you get javascript to talk over any of these things. Now if you had said java that would be easy.

@goffballtech - What the Arduino uses C/C++ does not matter at all!.

Mark

Goofballtech



@goffballtech - What the Arduino uses C/C++ does not matter at all!.

Mark


It matters very much if the OP's question was aimed at using
Quote
JavaScript (ajax) to control the mega which will generate PWM.


Javascript will not "control" the mega. Javascript will send a set of data that will be received by the mega and interpreted to produce the proper command. These are very different things. This is what the remaining portion of my reply was addressing.

cman

Hmm. I guess I need to be a little more clear, sorry about that. A pc won't be involved other than to use a browser to acces the webpage and manipulate a variable value.
The router will host the web page. The router will connect to the mega via USB. I would like the webpage to use JavaScript to trigger the arduino to generate pwm to speed up or slow down a motor based on values from the JavaScript.  So I guess my question may be how to I pass these variables from JavaScript to the arduino ... I've seen some custom stuff ... Like node.js.

I'm just wondering what is the standard way to get data from js to arduino?

Thanks for your help. I hate I don't know enough yet to even phrase the question correctly.

Go Up