new here and wondering if someone could help. trying to take a sting as an input to turn some leds on and off, however when i try to use the web address with “…V3=on” or “V3 =off” if doesnt seem to work.
anyone able to assist?
thanks in advance
@taneesh Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
There is no ‘web address’ (url) handling code in the snippet you’ve posted.
If you’re meaning that neither of the if statements in your sketch evaluate as true then I’d suggest that you start by using a serial print command to visualise the data coming from your param.asStr() command.
I use a serial print command in the v3 funciton to check what output I am getting in the serial monitor. I am alway getting the right string printed in the serial monitor e.g “on” is appearing but my if statements are not working when it gets the correct word input, it doesn’t seem to want to run what is within the if function when it receives the correct word
I think it would be helpful if you explained in much more detail exactly what it is that you are trying to achieve, as well as sharing your updated code and serial output.
So essentially I’m running some stuff through siri shortcuts which when an nfc tag is scanned, it will do a bunch of stuff then run a url command to the blynk server virtual pins.
for example when the nfc tag is scanned it will get contents of URL:
The reason I want to use strings rather than integers for high and low is because i want to be able to control the colours of the LEDs, for example: https://lon1.blynk.cloud/external/api/update?token=“…”&V3=blue ----- this would run the function to set the LED colours to blue.
Below is the code for where i have put my serial prints as well as the serial monitor.
BLYNK_WRITE(V3)
{
Serial.println(param.asStr()); //prints what value v3 is equal to in the url, this is correct all the time
if(param.asStr() == "on"){ //this if statment doesn't run even if the previous serial print is correct and i did type 'on'
Serial.println("led on");
for (int i=0; i<36; i++) {
leds1[i] = CRGB::White;
FastLED.show();
delay(25);
}
}
else {
for (int i=0; i<36; i++) {
Serial.println("led off");
leds1[i] = CRGB::Black;
FastLED.show();
delay(25);
}
}
}
Sorry, I didn’t spot that line in the sketch, I’d expected you to save the incoming value to a variable and print that, as well as in the if statement.
There is a possibility that there are trailing characters at the end of the string, so assigning the value to a variable then doing a trim() on the result would solve that.