Chosing a pull down resistor for an LDR: Axel Benz formula

LDR_circuitIn deciding on the value of the pull down resistor in a voltage divider with an LDR, one needs to take in account the range of light levels one wants to measure.
If you want to have the sensor in a bright area and use a 10KΩ pull-down, it will quickly saturate. That means that the voltage over the pull-down resistor will soon be 5V and you will not be able to differentiate between kinda bright and really bright. In that case, it is better to replace the 10KΩ pull-down with a 1KΩ pull-down, but then it will not be able to detect dark level differences as well but it will be able to detect bright light differences better. This is a trade-off that you will have to decide upon!

You can also use the “Axel Benz” formula by first measuring the minimum and maximum resistance value with a multimeter and then finding the resistor value with: Pull-Down-Resistor = squareroot(Rmin * Rmax), this will give you slightly better range calculations.

axel benz


Nokia 5110 display on Arduino

The Nokia 5110 LCD module is a small and cheap LCD with a lot of graphical possibilities and is quick to add to projects that need a display. The programming of the display is a bit difficult but there are a number of very good libraries available. Adafruit ofcourse has a library that is available here: here you will also need to install the GFX library that library is a bit slow but a faster hardware SPI library by Snigelen is available here: here.
Some additions to the Adafruit library have been made by avdweb
The arduino playground has a library: here
A library is also available: here
A further fast libray is available here with explanation here
Also a library by Henning Karlsen

The display driver is a PCD8544 chip, and it runs at 3.3V so you will need a 3.3V supply handy. Logic levels must be 3.3V to prevent damage so you must use some kind of level shifter (such as a 4050) or some resistors. It is possible to use a number of different lines to hook up the LCD. Normally it is 5 lines, but a configuration with 4 or even 3 lines is possible The Nokia 5110 LCD has 5 control lines; the interface is of the type SPI.

For a good understanding of how to hook up the Nokia LCD, it is good to understand that it is an SPI device.
Apart from power and ground (and power to the LED backlight if there is one) There are four basic signal lines to an SPI device. They are

  • MOSI (Master Out Slave In) also known as SIMO and SDI; DI, DIN, SI: because it is Serial Data In. It lets the master send data to slave.
  • MISO  (Master In Slave Out) aka SDO; DO, DOUT, SO which allows the slave to send data to the master. It isn’t always there.
  • SS  (Slave Select) also known as SCE, nCS, CS, CSB, CSN, nSS, STE which switches sending between master and slave.
  • SCLK  which is the clock pulse.

The Nokia5110 LCD has no MISO signal, but it has a:

  • D/C which selects between data and commands being sent.

and ofcourse:

  • RST  (Reset)
  • GND
  • Vcc which needs 3.3V

As long as you are using the Nokia LCD stand alone you are rather flexible in choosing what pins to use, however, if you want to use it in combination with another SPI device on the hardware SPI bus, you must use the proper SPI pins and you cannot use the MISO for any of the Nokia LCD pins as it has no MISO
The proper connection would be:
MOSI ->  MISO  (D12)
SCLK -> SCK (D13)
SS -> an available pin on Arduino, other than D11, traditionally D10 or D8 are used
D/C -> an available pin on Arduino, other than D11
RST -> an available pin on Arduino, other than D11, or an auto reset

Mostly, when no other SPI devices are used, the chip select can be connected to the GND, so 4 control lines remain. As said, it is possible to use only 3 control lines, by connecting the Nokia reset pin to the Arduino reset. This works only when the serial monitor is used, not with a standalone Arduino.

Another possibility is to generate a reset pulse on power up automatically, with a RC combination, to save one control line to the Arduino. This solution doesnt seem to be reliable though. The proper functioning seems to also depend on the capacitor across the 3.3V supply. Using only 4 or 3 lines of course only makes sense if your library allows that, otherwise the pins may not be connected but will be in use by your program. The Device  can tolerate a Vcc of 5 Volt, but it works best at 3.3Volt. When using it with a 5 Volt device, it is best to either have a level adapter or  resistors between the two devices.



Example of connection with resistors and 4 control lines


handy article