I'm trying to implement a motion detection system with multiple sensors on Arduino Nanos all talking to a central Arduino Uno system using the inexpensive RF 433MHz receiver & transmitter chips. I've gotten the sensors on the Nano to work and send a 2 character code where the first character is the sensor number and the second character is a 1 (motion detected) and a 0 (motion finished).
The receiver Base_Unit receives the code and it is properly echoed in a simple serial.print of the message. My trouble is when I try to decode the message to determine the sensor number and the on/off code so I can turn on and off a specific LED to signal that a remote sensor has seen motion.
The difficulty lies in the conversion of *char (which I understand is a pointer) to a char variable so I can do an if test to define variables to use in if tests to illuminate the proper LED. I am enough of a newbie with Arduino/C program that I do not know how to deal with the *char definition.
I've attached both my Motion_Sensor.ino sketch for the transmitter and the Base_Unit.ino sketch for the receiver. The Base_Unit.ino sketch does not compile at present because of the invalid/ambiguous character statements.
However, a slightly different sketch did compile (but with several compiler warnings) and verified that the codes were being sent and received as a sensor detected motion and lack of motion. The problem lies in how I decipher the received code to do the if tests.
However, I believe I tried exactly what you suggest and it doesn't work. On compilation I get the following messages:
Base_Unit:45: error: conversion from 'uint8_t {aka unsigned char}' to 'String' is ambiguous
String Sensor = buf[0];*
^* D:\Jeff\Documents\Hobbies\Microprocessors\Arduino\Motion Sensor\Base_Unit\Base_Unit.ino:45:28: note: candidates are: In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:223:0,
^* C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:61:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'const _FlashStringHelper*' C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:59:2: note: String::String(const char*)
_ String(const char *cstr = "");
^* C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/WString.h:59:2: note: no known conversion for argument 1 from 'uint8_t {aka unsigned char}' to 'const char*' Base_Unit:46: error: conversion from 'uint8_t {aka unsigned char}' to 'String' is ambiguous