This challenge is inspired by Blink the CAPS LOCK by zeppelin.

Most webcams feature a small integrated LED light, indicating if the webcam is in use, as controlled by a hardware mechanism to prevent spying.

1. Turn it on.
2. Wait for 0.5 (±0.1) seconds.
3. Turn it off again.
4. Wait for 0.5 (±0.1) seconds;
5. Repeat.

## Rules

• If your language is missing a subsecond sleep command, your program may use a 1 second delay instead, at a penalty of an additional byte. (replacing .5 with 1)
• If your language, for some reason, doesn't support .5, your penalty is 2 bytes. (replacing 0.5 with 1)
• Your program must loop unless halted by the user.
• Your LED can start either on or off; whichever is more beneficial can be used.
• If your LED has a turning-off delay, then it doesn't have to be taken into account, unless if you want to provide an additional version.

### Scoring

This is , which means the shortest answer in bytes wins.

• My laptop's webcam LED takes a while (around 0.3 seconds, it seems) to turn off after the video device stops being accessed. Does this have to be taken into account? – Doorknob Feb 26 '17 at 17:40
• @Doorknob No, but you can provide a version that takes it into account if you'd like. – haykam Feb 26 '17 at 17:42
• The penalty should only be 1 byte, since you can just use .5 – Elronnd Mar 1 '17 at 0:46
• @Elronnd I was going to add that, but I forgot. – haykam Mar 1 '17 at 2:10

# MATLAB, 40 bytes

while 1;w=webcam;pause(.5);delete(w);end


Creates an infinite while loop and each time through the loop, a webcam object is initialized (turns on the webcam), the script is paused for 0.5 seconds using pause, and then the webcam object is deleted (turning the webcam off).

• The delay between each blink is more than 0.5 – haykam Feb 26 '17 at 23:25
• @haykam The directions (and comments) indicate that inaccuracies due to the hardware are acceptable unless I'm misreading them. – Suever Feb 26 '17 at 23:30
• Ok... do you mind maybe adding an additional golf that does it so it looks like 0.5s? – haykam Feb 26 '17 at 23:31
• @haykam It's impossible, it's a limitation of MATLAB (and maybe the hardware itself). I am already showing it being turned off and back on as fast as possible. – Suever Feb 26 '17 at 23:32
• Last beep was good – haykam Feb 27 '17 at 1:52

# Python, 82 bytes

(Uses OpenCV for accessing the webcam.)

import cv2,time
s=time.sleep
while 1:w=cv2.VideoCapture(0);s(.5);w.release();s(.5)


# Javascript (ES6), 100 bytes

(f=_=>navigator.getUserMedia({video:1},x=>s(_=>x.getTracks()[0].stop(s(f,500)),500),s=setTimeout))()


During my testing, I saw a delay between the camera being activated and the LED turning on, so the timing may not be perfect. It also must run on an https:// page.

• @haykam thanks for the edit, but for some reason this script doesn't work inside the snippet iframe sandbox – nderscore Feb 27 '17 at 21:36
• Ok then. I won't start an edit war. ;) – haykam Feb 28 '17 at 3:18

## Scratch in scratchblocks2, 61 bytes

when gf clicked
turn video[on v
wait(.5)secs
turn video[off v


Sorry about the absolutely terrible video. My LED has a slight turning-on delay, it is very faint, and the GIF is 18 MB.

• @JonathanFrech I've taken a look at some Scratch answers and they all seem to use scratchblocks2. Secondly, I was doing what the challenge required? – W. K. Nov 19 '18 at 12:05
• "Please include a GIF or video of the webcam blinking, if possible. If an answer doesn't have the GIF, please add a GIF of the program running." I included everything else above it. – W. K. Nov 20 '18 at 1:27
• You are right. I seldom see a Scratch answer but it appears that your answer satisfies both the current byte count consensus and challenge-specific rules. Sorry for my partially uninformed critique. – Jonathan Frech Nov 20 '18 at 12:49