Hi I want to build the master and slaver arduino connected via UART port. In my master code I want it to be able to tell the temperature every time I drag the temperature bar and send out the message: normal, alert, and danger. After the message was sent out the slaver board will use it as the input to turn on individual LED: green, yellow, and red
I was able to get the mastercode to run perfectly fine. However, there was something wrong with my slaver code, it couldn't change anylight other than green. I tried to troubleshoot the issue, but I couldn't understand why, maybe there was sth wrong during the data transfer
This is my master code
char chArray[7];
int tmp36=A0;
int allowableTemp = 0;
double temp;
double tempC;
void setup()
{
Serial.begin(9600);
pinMode(tmp36, INPUT);
}
void loop()
{
allowableTemp = 30;
temp = analogRead(tmp36);
temp = temp / 1024; //* find percentage of input reading
temp = temp * 5; //* multiply by 5V to get voltage
temp = temp - 0.5; //* Subtract the offset
tempC = temp * 100; //* Convert to degree
if (tempC < allowableTemp) //temp below 30
{
strcpy(chArray,"normal"); // blink normal
}
else if (tempC >= allowableTemp && tempC < allowableTemp + 40) //temp between 30 and 70
{
strcpy(chArray,"alert"); //blink alert
}
You don't need to worry about it. It is automatically created when you include the following lines (at the places you see in the sketch) in the sketch: