I am writing a program to control an LED using the Lolin(wemos) d1 mini board and Arduino IDE, and testing it by turning it on and off with my smartphone(blynk IoT). Until recently, I was able to control the LED on or off from my PC or laptop, but for some reason, I can no longer control the LED from my PC or laptop. However, the LED is still working well with my smartphone.
My PC and laptop are using windows10.
Dear Sir,
I am using digital types for datastreams.
I have same result after rebooting.
I have several wemos modules but only one device on testing.
I am a teacher in South Korea.
Last semester, I successfully taught my students with the same parts and the same program.
But since last July, I can’t control it on my PC or laptop.
I have tested with several wemos modules before the class and they all give the same result.
So I thought that the ability to control it from a PC was gone.
Again, I can use the LEDs on the wemos module with the smartphone app without any problems.
What could be the problem?
Of course, I’m using the same account.
However, while testing again today, I noticed something very unusual. I was able to turn off the LED on the Wemos module from my PC.
However, to turn on the LED, I had to use my smartphone. I can’t turn it on from the PC, but I can turn it off.
And every time I turned the “BlueLed” button on/off on the PC, the button would move a little bit to the left, but then return to its original position. At the same time, I can see that the LED on the wemos flashes every time I move the button on the PC. That means it’s responding.
However, even though I can turn it on/off on my smartphone, I can only turn it off on my PC.
Why is this behavior?
I set the BlueLed of wemos to digital type.
@minbkwan 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.
This source code is in its early stages and in the next step I will introduce better code to students like interrupt code(attachInterrupt).
The current problem used to work well in the past, so I’ll study it a little more.
Thank you for helping me.
But before you do that you should remove the blocking delays, use GPIO numbers exclusively rather than “D” designations, use log.event more sensibly, stop using legacy WidgetLED, use BlynkTimer rather than SimpleTimer, and use virtual datastreams rather than digital.
The reason why D1 and D4 are used is because they use the wemos module, which tells students that D4 is the same as GPIO2. I think it is more educational to do so.
SimpleTimer is also more helpful to students when compared to BlynkTimer.
Anyway, thank you again for your help
It’s better to use GPIO numbers throughout, and adding comments regarding which NodeMCU pins these map to for a number of reasons.
The code is easier to port to different hardware
It’s far easier to spot pin conflicts if all pin references use the same naming conventions - GPIOs or “D” references
If you’re going to use Blynk digital datastreams (which I don’t recommend) then these use GPIOs rather than “D” numbers.
If a professional developer used “D” numbers over GPIOs then they wouldn’t last very long in a business environment. In my opinion you should teach your students to use best practice.
I agree with you about the compatibility of the code.
However, I think it’s important to present that process to students and gradually introduce them to good examples of better code.
Thanks for your advice, as always.