Hi, I am a yr.11 making a rainsensor for my electronics porduct.
I want my product to be able to tell me, when its raining and how heavy the fall is.
Major Components:
Arduino Uno eleven
MH-RD raindrops module (flying fish)
LED (x8)
Steps:
no water = all led's low
spitting = green led's high
slight rain = yellow led's high, green low
rain = orange led's high, yellow & green low
heavy rain = red led's high, orange, yellow & green led's low.
The rain module gives you values on the AO between 1060~ to 50~, therefore, I have been trying to use if else statements and the AO values in =>, etc. But I keep getting an error message saying that my if else statements don't have a previous if. I would really appreciate your help.
The semikolon, ; ends the statement, ends the "if", and the else's, and that's not what You want. The "if" then becomes a "nop", No Operation statement.
Hi Ethan; you may find using a switch - case structure makes your code easier to follow.
you can use a range of values here is a simple example
switch (arr[i])
{
case 1 ... 6:
printf("%d in range 1 to 6\n", arr[i]);
break;
case 19 ... 20:
printf("%d in range 19 to 20\n", arr[i]);
break;
default:
printf("%d not in range\n", arr[i]);
break;
}