Letting my project run when Arduino detects USB power.

So I have an idea but I don't know if it is even possible,

I have a RGB strip connected to my arduino and I want to start programming it and put it behind my desk. The problem is that it is an WS2812B RGB strip and it needs external power (I know that every strip needs it). So my Arduino is powered by the external power supply.

Something came in my mind today and that is to plug the arduino's usb port in my computer and let it detect when it recieves power (so when my pc turns on). I don't know if this is possible or anything because I can't seem to find any thing on this. I also don't know how I should define the "pin name" of the USB port because it isn't something that I can find (if it is even possible :wink: ).

If there are any questions please let me know!

Kind Regard.

If the USB is the only thing powering the Arduino then it will only run when you have USB power so there is nothing to do.

Which Arduino?

If I understand it correctly, the Arduino is powered permanently but you only want it to do something when it sees power on the USB port.

If so, one solution might be to solder a wire from the USB connector (pin 1 in the schematic carries the USB 5V) and connect that to an analog pin. I would add a voltage divider (e.g. 1k and 3k9) to reduce the voltage a bit (theoretical protection) and to make the pin see a low if nothing is connected. You can use analogRead to measure the voltage and if it's above a certain level (determined by the voltage divider), let the arduino continue where it left off.

A pure software solution would be to have an application running on the PC that communicates with the Ardiuno; if it does not see data for e.g. 5 seconds, it will stop doing what it is doing. This implies that the Arduino only will start working once the PC is fully started.

Hey Sterretje thanks for taking the time to send a reply!

It is a Arduino Uno. The Arduino is constantly powered yes. I will try see if it is possible what you said.
I know some people do it by starting a program on your computer to send serial data to let the Arduino know something is up. If this is the only option I sure will do that but I will first do your first suggestion.

Regards.