I read all the previous posts on this subject (Blynk.virtualWrite) and cannot find a way to solve my problem.
I am running a microPython sketch and everything works well with sliders and switches using the web-based console or the android app.
When I add this line of code to my sketch, I get an error message
Blynk.virtualWrite(V0, 0)
“SyntaxError: invalid syntax”
When I change it to
@Blynk.virtualWrite(V0, 0)
I get the error message
NameError: name ‘Blynk’ isn’t defined
When I change it to
@blynk.virtualWrite(V0, 0)
I get the error message
AttributeError: ‘Blynk’ object has no attribute ‘virtualWrite’
My system
Raspberry Pi Pico W,
Thonny micropython IDE
Blynk for Python v1.0.0 (rp2)
The relevant portion of my code that produces an error when I add the virtualWrite command is:
blynk = BlynkLib.Blynk(BLYNK_AUTH)
@blynk.on("connected")
def blynk_connected(ping):
print('Blynk ready. Ping:', ping, 'ms')
# Register virtual pin handler
@blynk.on("V0") #virtual pin V0
@Blynk.virtualWrite(V0, 0) # problem command