Hi,
i'm getting a problem when i read the analog through the serial monitor. What i mean is reading an analog sensor then convert it to digitalWrite. it's just work when i sending the 'a' code to the serial monitor.
like this that i'd tried:
if(100<sensorSensitive<200){
Serial.write('a');}
i changed the value of the sensor for easier declaration below:
if (Serial.available()>0){
byteRead=Serial.read();
if(byteRead=='a'){
digitalWrite(12,HIGH);
}
but it didn't work
is there anything that i'd missed?
please help if you have an idea
thank you
Ha.fiz
You can't do 2 comparisons in one statement, so this won't work:
if(100<sensorSensitive<200){
What you need is:
if(sensorSensitive >100 && sensorSensitive <200){
//only true if sensorSensitive is from 101 to 199
thanks for reply,
thanks 1 problem solved, but is still have a problem with the sending the 'a' code
actually i need to receive the sensor to "send" it to the serial
as we see in picture below(in the attachment) that the arduino had received the 'a' code
but the code
if (Serial.available()>0){
byteRead=Serial.read();
if(byteRead=='a'){
digitalWrite(12,HIGH);
}
didn't work
but when i typing 'a' word and send it, it work properly?
could anybody fix this
thank you for reading this
Ha-fiz
Try again.
What are you trying to do?
What Arduinos do you have?
How have you wired them up?
What did you expect to happen?
What actually happened?
Can you post the code for the analog side?
Ha-fiz:
didn't work
but when i typing 'a' word and send it, it work properly?
I can't understand what is the difference between the two things you have been trying.
The code you posted should detect an 'a' that is sent from the Serial Monitor.
What way have you set the Line Ending box in the Serial Monitor.
Post your entire program - not just the snippet where you think the problem is.
..R
Robin2:
I can't understand what is the difference between the two things you have been trying.
The code you posted should detect an 'a' that is sent from the Serial Monitor.
What way have you set the Line Ending box in the Serial Monitor.
From his pictures he seems to have selected 'no line ending'.