Tiny question google can't really answer

Hey quick question about something I’m a bit confused about. I’m writing some super simple code using examples of course and in the code the example has the word " data" as the character for received data from a bluetooth module, I thought it was similar to something like assigning a name to an LED so I could change it but when I did the compiler told me it wasn’t declared but the word data by itself was declared without error. I tried googling it but obviously things like " arduino data " don’t show me at all what I’m looking for.

Side note, data shows up orange and not black if that means anything.

If for some reason you need the code here ya go.

Thanks to anyone who was willing to answer my silly question, have a nice day to you all!

#include <Servo.h>
Servo servoone;
char data = 0;
void setup() {
servoone.attach(6);
Serial.begin(9600);

}

void loop() {
 if(Serial.available() > 0);
 {
doggo = Serial.read();
  Serial.println(data);
  if(data  == '1');
  {
    Serial.print("WE RECIEVED A THING");
  }
 }

}

If you want to change the name of a variable you must change all occurrences of it in the program. My guess is that you did not change the line that defines the variable

char data = 0;

...R

data is just a name. You can change it to whatever you like, as long as you change EVERY occurrence.

doggo = Serial.read();
  Serial.println(data);

doggo isn't defined.

char doggo = 0;
void setup() {
servoone.attach(6);
Serial.begin(9600);

}

void loop() {
 if(Serial.available() > 0);
 {
doggo = Serial.read();
  Serial.println(doggo );
  if(doggo == '1');

This snippet would compile, if it were complete.

Oh whoops I forgot that I changed it to doggo as a test before I uploaded it here, my bad.

if I change occurrences it still gives the error

Robin2: If you want to change the name of a variable you must change all occurrences of it in the program. My guess is that you did not change the line that defines the variable

char data = 0;

...R

Originally there wasn't a thing that defined the variable. it was just " data = Serial.read" My main question is why doesn't data need to be defined but any other word does? I can easily put " char doggo = Serial.read" and it works fine but that's not the issue

My main question is why doesn't data need to be defined but any other word does?

data DOES need to be defined somewhere.

Post a sketch where you do not assign data a type, and some proof that it compiles.

PaulS: data is just a name. You can change it to whatever you like, as long as you change EVERY occurrence.

doggo = Serial.read();
  Serial.println(data);

doggo isn't defined.

char doggo = 0;
void setup() {
servoone.attach(6);
Serial.begin(9600);

}

void loop() { if(Serial.available() > 0); { doggo = Serial.read();  Serial.println(doggo );  if(doggo == '1');



This snippet would compile, if it were complete.

Ohhhhhhh now I understand!! I didn't realize that data was defined before the setup whoops, thanks so much for explaining guys, really appreciate it