Plug USB and automatically run its code

Hello, I'm new to arduino but I have heard about it for a long time...
In my design class we are making lights/lamps built for a target audience etc. and while the main part of our unit is the outer design of the lamp, I wanted to make a lamp for programmers where you can use a simple on off switch but because it is for programmers there would also be a spot for a usb storage that the arduino could detect the usb and compile and run its code? That way you can program rgb lights to do strobe effects etc.

While I don't even know if my teacher would say yes, our school does have extra arduinos for projects like these, and knowing how to do this (with your help) will allow me to show my teacher how I can do this and still work on what my grades are. (At my school, stuff like this is going "above and beyond" so I can get perfect marks.)

TL;DR:
Need arduino to simply turn on/off a light and detect if a USB is plugged in then compile and run it's code.

Not doing well so far in explaining your idea.

What is all this about USB and compiling and running code? :roll_eyes:

Do you want to make some sort of Arduino Programmable RGB lamp? In which the user would select animations through some sort of usb connection?

Basically I want to plugin a usb to the arduino and the arduino to run its code

and where will the other end of USB be connected? Are you asking about how to upload programs to the Arduino board? You can't just connect the USB and the code will start compiling in the board. You need to download Arduino IDE and then properly verify and upload the code and then the Arduino board you are using will start compiling (or running) the code.

OTA updates may help, Do research about OTA ESP8266 or OTA ESP32 in Google.

As I said, you need to properly explain what you fancy doing and why.

What sort of "USB" would you "plug", what sort of "code" might it contain and how do you actually imagine connecting it to the Arduino?

This a very major extension of the "XY Problem".

Have you actually used and Arduino to do something?