HC-05 Bluetooth module not working correctly (with videos)

I'm using this hc-05 Bluetooth module to communicate between my laptop and an Arduino mega 2560. I'm using Processing to send the data from my computer.

The Bluetooth module stops receiving data every 2 seconds and blinks and then starts receiving data again. Everything else works fine, but I don't know why this is happening. Here is the Arduino code, and the Processing code. Here is a video I recorded of the the led and hc-05 module. Here's a video of the serial monitor receiving the data from the Bluetooth module that received the data from the my laptop. The data is being sent correctly, but the hc-05 module isn't receiving it correctly. I tried switching out the hc-05 with another one and issue persisted. Can somebody tell me why this is happening and what I can do to fix it?

Read the forum guidelines. Post your test code, here, in code tags. Use the IDE autoformat tool (ctrl-t or Tools, Auto Format) to indent the code for readability before posting code.

If the code below works with a standard Bluetooth terminal, you are blaming the wrong thing. The real villain may be revealed in your code, which is currently a state secret - or might as well be. Use software serial if you are inclined, the result should be the same. There is nothing to suggest your wiring isn't kosher - yet, but details of your power supply won't go astray.

void setup() {

void loop() {