Gast
#2099903
Hallo liebes Forum...
ich plage mich nun schon seit einiger zeit mit dem Arduino Uno herum.
Habe schon vieles Versucht konnte den FEhler im Code allerdings nicht
ausfindig machen. Vielleicht kann mir hier jemand weiterhelfen.
Hier der Code: sollte nomalerweise verständlich sein.
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
char inString[5]; // Space for the string
char string2[] = "start\0";
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
int i = 1;
void loop()
{
if(Serial.available() > 0)
// there you know there is data
{
for(index=0; index<5; index++)
{
inChar = Serial.read(); // Read a character
inString[index] = inChar; // Store it
inString[i] = '\0'; // Null terminate the string
i++;
}
}
if (inString[0] == 's' && inString[1]== 't' && inString[2] == 'a' &&
inString[3] == 'r' && inString[4] == 't')
{
Serial.println("Start empfangen\n");
digitalWrite(13, HIGH); // set the LED on
}
if (inString==string2)
{
Serial.write("Start empfangen\n");
digitalWrite(13, HIGH); // set the LED on
}
if (!strcmp(inString, string2))
{
Serial.write("Stopp empfangen\n");
digitalWrite(13, LOW); // set the LED off
}
}
mfg
