Arduino (using elegoo board) only works when plugged into computer

The resistors in series with the LEDs would protect the Arduino outputs from trying to supply too much current. I'd suggest using a 330ohm resistor.