Need Major Help

I'm a high school student working at a college Robotics Lab, and let's just say I'm not that experienced using C or Arduino.

I'm trying to make it so that when you enter something on the Arduino, such as the letter "V", it will output something, in this case "Remote Sensor Data Collector V1.01". Oh yeah, and it has to be bluetooth compatible as well (which IS working), if that has anything to do with it.

As of now, I have:

int sensorPin = 0;       
int sensorValue = 0;  
float realVolt = 0;
float resist = 0;
float lightInt = 0;
int bluetooth = 0;
char myChar = 0;
void setup() {
  Serial.begin(9600);
  pinMode(bluetooth, OUTPUT);
  Serial.println("Test: ");
}
  for(char == 'V'){ Serial.println(Remote Sensor Data Collector V1.01); }

void loop() {
  sensorValue = analogRead(sensorPin);    
  realVolt = 5-(sensorValue/204.8);
  //realVolt = 2*(2.5-(sensorValue/409.6));
  resist = (110/realVolt) - 22;
  lightInt = (pow(10,((resist-15)/-6.95)));
  ;
  Serial.print(lightInt, DEC);  
  Serial.println (" lux");
  
  delay (5000);
}

I keep getting "error: expected unqualified-id before 'for'".
Thanks in advance.

Oh yeah, everything works correctly when u delete:

char myChar = 0;

and

for(char == 'V'){ Serial.println(Remote Sensor Data Collector); }

All executable code needs to be in a function. Which function is the offending line in? When do you think it will be (or should be) executed?

By the way, a for loop takes 3 clauses, separated by ;. Your for statement is missing 2 clauses and the ;s.

Finally, the data sent to Serial.print(ln) needs to be in quotes.

Line 13 is where the error is located.
Basically what I want is for the Arduino to reply "Remote Sensor Data Collector V1.01" when I enter "V".

fixed the quotes lol

int sensorPin = 0;
int sensorValue = 0;  
float realVolt = 0;
float resist = 0;
float lightInt = 0;
int bluetooth = 0;
char myChar = 0;
void setup() {
  Serial.begin(9600);
  pinMode(bluetooth, OUTPUT);
  Serial.println("Test: ");
}
  for(char == 'V'){ Serial.println("Remote Sensor Data Collector V1.01"); }

void loop() {
  sensorValue = analogRead(sensorPin);    
  realVolt = 5-(sensorValue/204.8);
  //realVolt = 2*(2.5-(sensorValue/409.6));
  resist = (110/realVolt) - 22;
  lightInt = (pow(10,((resist-15)/-6.95)));
  ;
  Serial.print(lightInt, DEC);  
  Serial.println (" lux");
  
  delay (5000);
}

How would I go about having 3 clauses in "for"? Or should I be using "if"?

You should probably be using if.

Where does char (if(char == 'V')) get a value?

The statement that is causing the problem needs to be in a function, not between functions.

Ok, if I want to input “V” and receive “Remote Sensor Data Collector V1.01”, what do i set mychar as?

char myChar = ???

void setup(){
  Serial.begin(19200);
  if (myChar = 'V'){ Serial.print('Remote Sensor Data Collector V1.01'); }
}

Is this the right format?

Where do you intend to input the "V"? If the application that receives the "V" sends it to the serial port, the Arduino needs to read that serial data:

void loop()
{
   if(Serial.available() > 0)
   {
      char inChar = Serial.read();
      if(inChar == "V")
         Serial.println("Remote...");
   }

   // Rest of loop code
}

I just type it while it's running.
So, if I type "V", it will reply with "Remote Sensor Data Collector V1.01".

Okay, so I got this, but I don't get a response after typing a capital V

void setup(){
  Serial.begin(9600);
}
void loop()
{
   if(Serial.available() > 0)
   {
      char inChar = Serial.read();
      if(inChar == 'V\n')
         Serial.println('Remote Sensor Data Collector V1.01\n');
   }
   delay (1000);
}

YESS!!!
I get “12337” as a response, but it’s a start.

int bluetooth = 0;
void setup(){
  Serial.begin(9600);
  pinMode(bluetooth, OUTPUT);
}
void loop()
{
   if(Serial.available() > 0)
   {
      char inChar = Serial.read();
      if(inChar == 'V')
         Serial.println('Remote Sensor Data Collector V1.01');
   }
   delay (1000);
}
 Serial.println([glow]"[/glow]Remote Sensor Data Collector V1.01[glow]"[/glow]);

Lol changed it just before you posted :smiley:

Thank you SM