Archive for March, 2012

It turns out that many electronic components can run backwards and forwards. For example, it’s possible to use headphones as a microphone. Here’s a simple Arduino-based circuit that shows how to use an LED as a light sensor. The diagram below shows how to hook everything up.

LED Light Sensor Diagram

The basic idea is then to use analogRead() to detect the voltage across the LED. If the value is low, it means the LED is not detecting much light, while if the value is higher then there is more light present.

Three different versions of the code that goes along with this circuit is available at The SerialOutput folder has a sketch that just dumps the values it reads to the serial port. You can use this to find a good threshold value, depending on the exact light conditions you are seeing. The Threshold sketch simply turns the LED on pin 13 off when there is light, and on otherwise. You could use this as a simple night light. Finally, the Fading sketch adjusts the intensity of the LED based on how much light is detected. It requires the output LED to be connected to a PWM pin, so if you are using an Arduino Uno instead of a Mega, you’ll want to adjust the code and the circuit to use, for example, pin instead of pin 13 for the output.

Here’s a video of the fading example.

Arduino Examples

Posted: March 7, 2012 in Arduino
Tags: ,

This semester I am assisting Will Byrd in teaching A290: Arduino Development. As part of this, I’ve decided to post some example Arduino code on Github. Here’s the link to the repository:

In the coming days and weeks, I’ll try to post more detailed information about each of the examples.

Hello world!

Posted: March 4, 2012 in Uncategorized

Welcome to my blog! My name is Eric Holk, and I’m a Ph.D. Student at Indiana University studying programming languages for parallelism. This blog is where I’ll share various computing-related projects that I’m working on.