Skip to main content

LED Strobe Light

I ordered a small strobe light more than a month ago from china, but it wasn’t delivered in time, so I made one from a LED light I had at home.

First, I wired this LED light through a NPN transistor. It couldn’t be wired directly to Arduino because it requires higher current than Arduino can provide. I’ve also wired a 10K Potentiometer for tuning the frequency of blinking.

Wiring diagram

Resistor wired from pin 2 is 1K Ohm and the pulldown resistor connecting transistor to the ground is 10K Ohm.

Wiring
Wiring

Programming everything was as simple turning pin on and off with delays in between linked to potentiometer. At higher frequencies I noticed that light was actually lit longer than it was off so the effect wasn’t as good as I expected it to be.

I had to adjust the delay before light turns on again to be longer at higher frequencies, but stay about the same at higher. I drew a graph time on-time off to represent this and figured out I could shift and stretch function y = -1/x to form the same line. The results were much better then.

Graph
Graph

Here is the code for Arduino.

A clip of the strobe light working.

WeMos D1 ESP8266 Web Controlled Switch

Last year I made Room automation with Raspberry Pi and few Arduinos for switching lights and air conditioner on and off using my phone. It required lots of components for accomplishing a simple task. The reason was that Arduino itself cannot connect to wifi and NRF24L01+ module doesn’t support TCP/IP protocol, so I needed Raspberry Pi for wifi connection. Also using new Raspberry Pi for each light switch is just too expensive. This time I used WeMos ESP8266.

ESP866 is an inexpensive Wifi Module for Arduino that supports 802.11 b/g/n protocols and it can also run Arduino code. There are multiple versions of this SOC. Some require serial to USB adapter for programming and some have micro USB port. They also vary by amount of GPIO ports and memory they have.

List of parts that I also used for this project:

  • WeMos D1 ESP8266
  • Relay module
  • MB102 Breadboard Power Supply Module
  • Old notebooks power adapter

For assembly I connected notebook’s PSU to MB102 PSU module, MB102 to ESP8266 with USB cable and GPIO ports 0, 2 and ground on ESP8266 to Relay module.

ESP8266  WeMos
ESP8266 WeMos

I modified ESP8266 library example code and uploaded it on the WeMos ESP8266:

Module automatically connects to wifi when powered and receives an IP address from router (192.168.1.45 for example). It’s IP may change every time module disconnects from wifi, so I assigned it static IP address on my router.

You can switch GPIO on by sending HTML request to “http://[ESP8266s ip address]/gpio/0” and to turn it off “~/gpio/1”. This is done simply by visiting url in a web browser.
Disadvantage of the code from libraries example is that you can’t tell whether GPIO is on or off. I modified it so that html response includes info about its status when you visit ~/status.

Turning the air conditioner on by typing http://192.168.1.45/gpio/0 into a browser and making sure that it’s on or off by visiting http://192.168.1.45/status it’s not very practical, so I made a simple web interface and added it to my homes dashboard webpage.

It displays a button with text “Turn on” or “Turn off” depending on the GPIOs current status. When you click it, it sends a html request to the module to change its GPIO state.
You can use as many ESP8266 modules as you want and manage them from a centralized web application.

Everything connected
Everything connected

Edit: Someone on Reddit requested code for managing multiple ESP8266s. So here is the code. To add new module, just add its IP address and name in the array.

Here is a video demonstration of last years system. Front-end webapp is the same and it functions the same.

Laser Sensor Timer using Arduino

I’ve made this project during project week in high school. This timer can be useful for timing races over short distances, because the result is more accurate than using handheld stopwatch. The average reaction time of a human is approximately 0.25s which is a lot when the total time can be as low as about 7 seconds.

List of parts that I used to make this project:

A laser is pointed to photoresistor which is connected to analog pin on the arduino. Using code below, you can read the value of analog ping (photoresistor) in range of 1 to 1000. The more photons fall on the photoresistor in a given time, the higher is the read value. The value of ambient light read from analog pin is in my case 400, and 800 while the laser is pointed at the photocell.

We can use this to determine whether there is a clear path between laser and photocell or not. Now we just need a display and a button to start the timer. Well we can also wire a starting pistol instead. Here is my diagram: (R1, connected to button, is 10k and R2 is 1.5k)

Arduino Timer Diagram
Arduino Timer Diagram

I used OLED 128×64 I2C display, which requires these two libraries: SSD1306 and GFX. You can use any Arduino compatible display.

Components on a breadboard
Components on a breadboard

And here is my final code. For timing, I’m using millis() function, which returns the number of milliseconds since the Arduino board began running the current program. When the start button is pressed, it saves value of millis in a variable and also current value of photoResistor. Then the program is displaying current time and constantly checking value of photoresistor. If it drops below 90% of a value at the beginning, it means that the path between laser and photoresistor is broken.
When I first made the program in school, I made it stop the timer at this event. But if we are using it for running, where you need to cross the finish line, timer shouldn’t stop just yet. Instead, it should wait until runner goes past the line and then stop the timer. So it waits for laser to shine on the photoresistor again and then stops the timer.

Timer System
Timer System

For now, timer can only store one value and if it was used outside on a bright day, difference between the values of ambient light and the laser on the photoresistor wouldn’t be sufficient. You can make cover for photoresistor so that only light from laser would fall on it, thus making the system more reliable. For keeping the laser directed, I used laser on distance meter, which I attached on camera tripod.

Here is a test video of my timer.