error: expected ',' before '.' token -- solution???

Hello, I’m in the process of making an accelerometer-gesture-controlled robot that works over wifi. I’m using Adafruit Feather HUZZAH ESP8226 modules to transmit the signal from the accelerometer to the robot. The way I am doing this is through string messages. The concept should work, but I am puzzled over a different problem. There are two programs, one that interprets accelerometer gestures to create string messages and transmit them, and another one that interprets the string messages to create motor movements. The code I am having trouble with is the one that interprets recieved string messages. When I tried to upload my code I got this error: exit status 1 expected ‘,’ before ‘.’ token. My code is below:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <WiFiServer.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();

// And connect 2 DC motors to port M3 & M4 !
Adafruit_DCMotor *FL_MOTOR = AFMS.getMotor(1);
Adafruit_DCMotor *FR_MOTOR = AFMS.getMotor(2);
Adafruit_DCMotor *BL_MOTOR = AFMS.getMotor(3);
Adafruit_DCMotor *BR_MOTOR = AFMS.getMotor(4);

const char *ssid = “SumoRobot”;
const char *password = “ZumoShield”;

WiFiServer server(80);

void setup() {
Serial.begin(115200);
pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(BUILTIN_LED, LOW);
Wire.begin();
WiFi.softAP(ssid, password);

IPAddress myIP = WiFi.softAPIP();
server.begin();
}

WiFiClient client;

void loop() {
if (!client.connected())
{
WiFiClient client = server.available();
}
if (client)
{
while (!client.available())
{
delay(1);
}
String s = client.readStringUntil(’\r’);
if ([s.char() == ‘F’])
{
forward();
}
}
client.flush();
}

void brake() {

// Stop
FL_MOTOR->setSpeed(0);
FL_MOTOR->run( RELEASE );

FR_MOTOR->setSpeed(0);
FR_MOTOR->run( RELEASE );

BL_MOTOR->setSpeed(0);
BL_MOTOR->run( RELEASE );

BR_MOTOR->setSpeed(0);
BR_MOTOR->run( RELEASE );

}

void forward() {

// Forward
FL_MOTOR->setSpeed(100);
FL_MOTOR->run( FORWARD );

FR_MOTOR->setSpeed(100);
FR_MOTOR->run( FORWARD );

BL_MOTOR->setSpeed(100);
BL_MOTOR->run( FORWARD );

BR_MOTOR->setSpeed(100);
BR_MOTOR->run( FORWARD );

}

void reverse() {

// Backward
FL_MOTOR->setSpeed(100);
FL_MOTOR->run( BACKWARD );

FR_MOTOR->setSpeed(100);
FR_MOTOR->run( BACKWARD );

BL_MOTOR->setSpeed(100);
BL_MOTOR->run( BACKWARD );

BR_MOTOR->setSpeed(100);
BR_MOTOR->run( BACKWARD );

}

The error message should include the line number where the compiler realizes that there is an error. Look in that line and the line before. If you can't find the error, post the entire error message.

Please read the how to use the forum-please read stickies to see how to format and post code.

  if ([s.char() == 'F'])

Why did you put square brackets there?

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

The error is in the line that PaulMurrayCbr pointed out. It's not just the square brackets.

if (s.indexOf('F') >= 0)

May do what you want. This will return -1 if 'F' is not in the String or the index of the character in the String (>= 0) if the String contains the character.
https://www.arduino.cc/en/Reference/StringLastIndexOf

You can edit your original post to put the code in code tags (Please).

Or perhaps you meant "If the first character of the String is 'F'":

    if (s[0] == 'F')

(Note that 'F' is an integer containing the ASCII value of the character 'F'.)

Or perhaps you meant "If the String is "F"":

    if (s == "F")

(Note that "F" is a pointer to a character string containing the letter F and a terminating null character.)

Or perhaps you meant "If the String is "F"":

    if (s == "F")

(Note that "F" is a pointer to a character string containing the letter F and a terminating null character.)
[/quote]

This was my answer. I will read the forum instructions. Thanks, because changing that allowed my code to compile!