Hi all,
Hoping someone can tell me whats wrong here. Works perfect and will return the index of the first instance of any letter or number accept for the letter "H" (returns integer value 2). New to programming and have tried to find the answer but no luck.
// include the library code:
#include <string.h>
#include <SoftwareSerial.h>
char HC12ReadBuffer[]= "D_T:58 D_H:88 R_T:24 R_H:90";
char* Pointer='H';
int Return;
void setup() {
Serial.begin(9600); // Open serial port to PC
delay(2000);
}
void loop() {
LCD_Send();
Return = find(Pointer);
}
void LCD_Send() {
delay (2000);
Serial.println(Return);
}
int find(char* s) {
for(int i = 0; HC12ReadBuffer[i]; i++) {
if(!strcmp(s, HC12ReadBuffer[i])) return i;
}
return -1; // -1 means "not found"
}