How can I make a light blink when I open a program like a media player.
When the video starts, the code will start. The video will be the trigger.
How can I make a light blink when I open a program like a media player.
When the video starts, the code will start. The video will be the trigger.
Your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g you write, not for questions. Feel free to write a tutorial once you have mastered your problem
Couldn't you use that fact (the fact that you did something explicit, and you know that you do it) to set a flag? Then have some blinkwithoutdelay in a function and run the function if the flag is set?
(But I have no idea how you would then turn it off... does the media player ever say it's finished? )
The light will only be turned on for a few seconds. When a new video is played it will turn the light on again.
Ok well grab millis() into say startedAtMillis and then check for the gap between the fixed startedAtMillis and the new, ever-increasing millis() to be greater than a few seconds and then clear the flag.
Btw, if by that you mean just one on-then-off cycle, not blinking on-off-on-off-etc, it's even easier. Capture the time when the video starts and turn led on, each time through loop() check the elapsed time, turn off if enough time has passed.
Hello Cardines
Post your current sketch, well formated, with comments and in so called code tags "</>" and a schematic, not a Fritzy diagram, to see how we can help.
Have a nice day and enjoy coding in C++.
Дайте миру шанс
TBC are you asking how to get an Arduino program running on an Arduino board to react to the fact that you open program (or do something, whatever) on a PC or other device?
Not impossible, but before we go to any real thinking about it, please elaborate on the trigger condition.
Turning on an LED for awhile, with or without flashing for some time period is the easy part. Can you code what you want with a simulated trigger, say a pushbutton connect to an Arduino input pin?
a7
And yet again, the first question is - why would you want to use an Arduino to do this?
Once you figure out how to detect on the PC, the instantiation of the media player, the PC can blink a light for you using just the old parallel port, a USB parallel port adapter, or a USB serial adapter.
the PC is quite a capable processor, you know?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.