Compute Serial Transmition

I have an Ethernet shield and a Mega 2560. What I would like to do is receive a UDP transmission like "2+2" or some other math problem, and then have the Arduino solve it and send back (for this example) 4. Could you do something like this?

Yes Have you got any code to send the calculation to the Arduino and, perhaps, display it on the Serial monitor as a first step ?

Does http://arduino.cc/en/Tutorial/UDPSendReceiveString help ?

Did you try a Google search for arduino udp library like I did ?

The Bitlash interpreter can do the arithmetic and serial i/o and parsing part. Bitlash comes with ethernet client examples for TCP (telnet) and HTTP that you could use as a starting point for a UDP client.

See http://bitlash.net for code, doc, and examples.

-br

UKHeliBob: Yes Have you got any code to send the calculation to the Arduino and, perhaps, display it on the Serial monitor as a first step ?

Does http://arduino.cc/en/Tutorial/UDPSendReceiveString help ?

Did you try a Google search for arduino udp library like I did ?

I am familiar with sending the packets over the network and have with this setup. It works great. I send packets from my computer, and my iphone both with replies. Now I want to take the next step and make it do something.

tfoote: I am familiar with sending the packets over the network and have with this setup. It works great. I send packets from my computer, and my iphone both with replies. Now I want to take the next step and make it do something.

Well, you certainly have our permission to proceed.

Well, you certainly have our permission to proceed.

Hey, you stole my line.

tfoote: I am familiar with sending the packets over the network and have with this setup. It works great. I send packets from my computer, and my iphone both with replies. Now I want to take the next step and make it do something.

You are already doing something on receipt of data, ie replying. So. where are you stuck in making it do something else ?

UKHeliBob: You are already doing something on receipt of data, ie replying. So. where are you stuck in making it do something else ?

well i want to use the data that it is given to solve the problem. So if you get "2+2" it comes in a string. How do you get it to the int 4? In conclusion: Input: String "2+2" Output: int 4

You need to parse the string. Identify and save the numeric portions to variables, identify the arithmetic operator and apply it to the numbers to get a result and pass the result back.

The strtok and atoi functions would be of great help I would think.

Thank You All! :)

String functions that make string parsing fairly easy.

http://arduino.cc/en/Reference/StringObject

Are you allowed to use the 'S' word in here ?