No, it will be fine Besides, you canât break anything with this sort of code. Itâll work or not and if it doesnât work you probably did something wrong, nothing to worry about
BLYNK_READ(V6)//pressure reading
{
int val = analogRead(0);
val = map(val, 210, 1080, 0, 145);
Blynk.virtualWrite(6, val);
//GREEN LED
if (val > 100)//If val = greater than 100, LED turns on
led1.on();//LED On
} else {//If val = less than 100 LED turns off
led1.off();//LED Off
}
//RED LED
if (val < 100)//If val = less than 100, LED turns on
led1.on();//LED On
} else {//If val = greater than 100 LED turns off
led1.off();//LED Off
}
}
In saying that, would this work? 2 in the one? and still use the frequency from the gauge to act as the timer?
Cheers.
Actually it has error:
Systems_Button.ino:93:5: error: expected unqualified-id before âelseâ
Systems_Button.ino:98:2: error: expected unqualified-id before âifâ
Systems_Button.ino:100:3: error: expected declaration before â}â token
Error compiling.
Yes, you are missing one â{â after the if(vla<100)
But in essence, you are correct this should work.
Thanks a bunch Lichtsignaal! really do appreciate it! If you donât mind one last question, how could you get one LED to change colour? thatâd really be the icing to the cake on my project.By the way this is my school project so should get a top notch mark!
Nice
You can use this:
Blynk.setProperty(V0, âcolorâ, â#D3435Câ);
To change the color of the LED (V0 being the pin the LED is attached to of course).
Something like this?
//GREEN LED
if (val > 100){//If val = greater than 100, LED turns on
led1.on();//LED On
Blynk.setProperty(V0, "green", "#23C48E");
} else {//If val = less than 100 LED turns off
led1.off();//LED Off
}
//RED LED
if (val < 100){//If val = less than 100, LED turns on
Blynk.setProperty(V0, "red", "#D3435C");
led2.on();//LED On
} else {//If val = greater than 100 LED turns off
led2.off();//LED Off
}
}
I think the âcolorâ part is just that, it indicates which property you want to adjust. the #xxxxxx is the hexadecimal color code, so you should change that to the appropriate color.
do you just put it on the line before led1.on? and would it change if i put it before both scenarios, so depending what scenario its on will automatically change colour?
oh and now it comes with errors:
Systems_Button.ino: In function âvoid BlynkWidgetRead6(BlynkReq&)â:
Systems_Button.ino:90:11: error: âclass BlynkEthernetâ has no member named âsetPropertyâ
Systems_Button.ino:98:12: error: âclass BlynkEthernetâ has no member named âsetPropertyâ
Error compiling.
Yes, you can do it however you want. Iâd keep it simple with just 1 LED and do something like:
if (val > 100){//If val = greater than 100, LED turns green
Blynk.setProperty(V0, "color", "#33cc33");
led1.on();//LED On
} else {//If val = less than 100 LED turns off
Blynk.setProperty(V0, "color", "#ff0033");
led1.on();//LED On
}
still get âerror compilingâ
Systems_Button.ino: In function âvoid BlynkWidgetRead6(BlynkReq&)â:
Systems_Button.ino:90:11: error: âclass BlynkEthernetâ has no member named âsetPropertyâ
Systems_Button.ino:93:11: error: âclass BlynkEthernetâ has no member named âsetPropertyâ
Did you update to the latest library? This function is pretty new I think.
of course. Thanks for your help! youre a wiz, I can only test this on monday but will be sure too! thanks again