Pages: [1]   Go Down
Author Topic: Client and Server as - Processing and Arduino.  (Read 525 times)
0 Members and 1 Guest are viewing this topic.
Derbyshire
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I am trying to achieve a arduino server that sends data to clients after a certain client message request.

My client sends a message GET to the server asking for some data (Processing sends this). As:

 [loop function here with delay]
  myClient.write("X");


I have arduino receiving this message, and it can be seen in the serial monitor with:

      char thisChar = client.read();

        Serial.println(thisChar);

The message comes out as:
X
X
X
etc


I am trying to apply a IF statement to the client.read().


For example:

if(thisChar = 'X'){
Serial.println("X received and recognised");
server.write("X recognised");


Essentially I do not have the basic knowledge to convert the client message into something arduino understands - and then can take actions on this.

If anyone could help me out in this - it would be much appreciated.

I imagine it wont be anything too crazy.


Many thanks.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if(thisChar = 'X'){

A single equal sign is an assignment. You need the double equal sign for a comparison.

Code:
if(thisChar == 'X'){

http://arduino.cc/en/Reference/Assignment
http://arduino.cc/en/Reference/If
Logged

Derbyshire
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

smiley-grin! Thank you dxw00d,

I thought it might be something minor yet critical.
Logged

Pages: [1]   Go Up
Jump to: