ARDUINO: STROBE LIGHT EFFECT
- Layout for this exercise:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxagkRSGlw1y75UJqHzZXPALW9kYLzW2FyE-89fdSmsFCudn0hwuhqs2yfWmWO15EPPyjVInE_aXJ5ZzO_tsM_AANCQDMWQMy777jBNc1tiD6dumfiMX67eIIJz7LfB9xEFDTF0EwOEKeD/s640/screenshot.5.jpg)
1 - Introduction
- The objective of this exercise is to achieve the light effect of strobe based on emitting flashing light by 8 red and yellow LEDs, simulating the flag of Spain.
- The strobe light effect is a visual phenomenon caused by aliasing that occurs when continuous motion is represented by a series of short or instantaneous samples.
- It occurs when the view of a moving object or blinking light is represented by a series of short samples as distinct from a continuous view at a rate close to the sampling rate.
https://en.wikipedia.org/wiki/Stroboscopic_effect
- The schematics of this exercise is an Arduino board connected to 8 LEDs and a potentiometer connected to the analog pin A0.
2 - Code
- The code for this exercise:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlPGC7SV3eYWIuMMDFo3hs-SCZnQ2WJ_C5OXlMLHO32L-TJ4QeeynSqO7zBXQ95wd8Evpmxz5XLdIpqJg0cZ5uGk1uKW85ESqueSTag5Cxo2kPMzFK057EVuWpfq1xX67YRrFeC-JcYCGj/s1600/screenshot.1.jpg)
- Let's analyze the code.
- Setting the pins for the couple of LEDs (digital pins 12,11,10 and 9) and the potentiometer (analog pin A0):
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwweLrPOUV3BbhMdh9ZKeFolb_zyfDwt0yTH5PD3yZu1LbRerI9URL3FLrPZt6VJUANBoC8onOL8YHgYpfiRALH2Qb1Eqd9n1bAsO4qw8bJZwIMdQ8ZVEhNV_F22OrtZQt5a3WimNsj3Od/s1600/screenshot.2.jpg)
- The readings on the A0 are calibrated from 0 to 1023 giving an interval of 10 to 500 ms, what is a time enough short so that the human eye perceives the light as an overlay of flashes leading to the strobe effect.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix1s31gwaXveiyegRuspzYpbAMhmOpe_ERVQ17yOe-75RR57OxwJR25GH49cPil4LyAXM-ELWwl3JKnBNO-_UnucoI76gG6b3MxSEzPuZ-8PBM1j_QJOZaYuVFunH4YQbeXn15qQ0Ygio2/s1600/screenshot.3.jpg)
- As seen in the previous section the function repeater is applied to the digital pins 12, 11, 10 and 9:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO1MpUmRitXbOCTjRrWPg5wmhK0B3cPhljvyzE_pWa50OnJEN4bCUPCnGSs8awgzjOZENIx45_bj610zG9qlu6xTmEYdL9QwMxrASyOjsBms_iAZfHg0I1PRjTKyU8tjnRmLrM4lC8mkQB/s400/screenshot.4.jpg)
3 - Testing the circuit
- The video shows how the blinking light speed is controlled by the potentiometer in the interval of 10 to 500 ms, simulating the flashing colors of the Spanish flag: