Step 17LCD, the Intervalometer and ADC
You first need to solder some leads onto the LCD. It should have solder pads for the purpose and if you are careful, shouldn't cause you too much trouble. Don't take off the protective film over the screen, it protects against flux spattering and you may damage it if you take it off before you finish.
The pins on the LCD are as follows:
1 GND
2 VCC
3 Contrast
4 RS
5 R/W
6 E
7 DB0
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 LED+
16 LED-
Connect GND to ground, VCC will go to the +5V rail.
The contrast pin should go straight to ground too, though in many diagrams it's connected to a potentiometer (i've never seen the point). It's worth mentioning that you should check with a resistor to see what value you need. My red LCD is happy with ground, my blue LCD (the one i ended up actually using) required a small resistor.
LED+ should be connected via a 2.2k resistor to the +3V rail and LED- to ground. You can simply wire it straight to the voltage rail, however it will draw 30mA all the time. With a resistor in series, you will limit the current significantly - of the order of around 15-20x less - without much degradation in brightness (it's more than acceptable to use in the dark).
The LCD library uses a 4-bit interface, so we only need four pins. Thus we disregard the first four data pins and only use DB4..7. DB4,5,6 should be connected to pins 2,3 and 4. DB7 on the other hand will be connected up to pin 14. The reason for this is as follows: we need PD2 (pin 5) as an external interrupt pin*. On other microcontrollers such as the ATMega88, you can use (almost) any pin as an external interrupt, but this way you can use either the Mega8 or the Mega88/168.
You should then connect RS to PD6, pin 12 , R/W to PD5, pin 11 and E to PD4, pin 6 .
If you want to use different ports, look in lcd.h and change the definitions!
That's all you need for the LCD, now onto some more buttons. You're going to need to wire up another 5. These are mode and the four directional buttons. Wire up a button to each of pins 15-19. The process should be the same as in the previous step, so i haven't provided needless pictures for each one.
Finally, load up and run the full application as provided in step 12/13.
When you run the program, you should be shown a "splash" screen and the the first shooting mode, manual triggering. To take a picture, press shoot (as before). Press mode to cycle between menu options. For the interval timer, you may set the value of each unit of time using the up/down buttons and switch between units using left/right - hopefully intuitive...!
The next section deals with the ADC (which should be enabled by the code below).
This is the code that will stay on your chip!
*In this revision i planned to use external interrupts but never did, however the code is still written for this pin configuration.
| « Previous Step | Download PDFView All Steps | Next Step » |
































































what are these pins?
#defineLCD_PORT PORTD /**< port for the LCDlines */
#defineLCD_DATA0_PORT PORTB /**< port for 4bitdata bit 0 */
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
#defineLCD_DATA0_PIN 0 /**<pin for 4bit data bit 0 */
#defineLCD_DATA1_PIN 2 /**<pin for 4bit data bit 1 */
#defineLCD_DATA2_PIN 1 /**<pin for 4bit data bit 2 */
#defineLCD_DATA3_PIN 0 /**<pin for 4bit data bit 3 */
#defineLCD_RS_PORT LCD_PORT /**< port for RSline */
#defineLCD_RS_PIN 6 /**<pin for RSline */
#defineLCD_RW_PORT LCD_PORT /**< port forRWline */
#defineLCD_RW_PIN 5 /**<pin for RWline */
#defineLCD_E_PORT LCD_PORT /**< port for Enableline */
#defineLCD_E_PIN 4 /**<pin for Enable line */
This is from lcd.h.
The pins are correct on the schematic to my knowledge (check onabreadboard before you build to be sure): http://img8.imageshack.us/img8/8904/cameracontrollerschemat.png/4743/cameracontrollerschematm.png<br />
From the above, LCD_PORT is PortD.
RS - PD6, pin 12
RW - PD5, pin 11
E - PD4, pin 6