On Thursday I shared the start of the hardware side of my new project. I want to use flashing squares on a computer monitor to program a microcontroller via two photoresistors. I’ve been thinking of how to control it in a way that is useful and ended up drawing this somewhat elaborate flow chart.
Of the two photoresistors, one serves as a clock signal (PR1) and the other serves as a data signal (PR2). My program flow will loop until a low level is seen on the clock, then it will loop until it see a high level on the clock. At this point PR2 will be read to pull in a 1 or a 0. Along the way I’ll watch for a timeout, at which point I’ll do some data processing and then exit.
Hopefully this will be a robust setup. It should mean that timing is not an issue from the microcontroller side of things. The next problem will be to write a web interface that is used to do the actual programming. I think this will prove a bit tougher, but we’ll see.
I’m starting on a new project and thought I’d share the first step. I eventually want to use two photoresistors to push data into the microcontroller. You’ve got to crawl before you can walk and I’ve set up a simple circuit to make sure everything is working.
Using a voltage divider that includes a CdS photoresistor I can take a measurement using the ADC that correlates to the intensity of light shining on that CdS sensor. In the video after the break I’m using a set of LEDs on the development board as a signal. When light intensity is low the LEDs are on. When I use a flashlight to increase the light intensity the LEDs go off.
This proves that I have everything set up correctly before I make my firmware more complicated. I followed along with the ADC tutorial over at AVR freaks to get this far. Eventually I’ll use two photoresistors, one to sense the clock and the other to sense the data. That will require interrupt based ADC readings. For now I’m using the free ranging mode. Keep reading to see the code.
A voltage divider uses two or more resistive elements to output a lower voltage than was input. This can have many functions, like allowing communications between devices operating at different voltages, and acting as inputs for devices that have variable resistance. After the break I’ll look at some of those uses, and cover the basic principles of voltage dividers.