User Tools

Site Tools


products:i2cspilcdbackpack:index.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:i2cspilcdbackpack:index.html [2010/11/02 00:53]
ladyada
products:i2cspilcdbackpack:index.html [2016/01/28 18:05] (current)
Line 1: Line 1:
  
 +====== Introduction ======
 +
 +{{  /​products/​i2cspilcdbackpack/​i2cconnect_t.jpg ​ |/​products/​i2cspilcdbackpack/​i2cconnect.jpg}}
 +
 +LCDs are a fun and easy way to have your microcontroller project talk back to you. Character LCDs are common, and easy to get, available in tons of colors and sizes. [[http://​www.ladyada.net/​learn/​lcd/​charlcd.html|We'​ve written tutorials on using character LCDs with an Arduino]] (or similar microcontroller) but find that the number of pins necessary to control the LCD can be restrictive,​ especially with ambitious projects. We wanted to make a '​backpack'​ (add-on circuit) that would reduce the number of pins without a lot of expense. ​
 +
 +By using simple i2c and SPI input/​output expanders we have reduced the number of pins (only 2 pins are needed for i2c) while still making it easy to interface with the LCD. For Arduino users, we provide a easy-to-use library that is backwards compatible with projects using the '6 pin' wiring.
 +
 +{{  /​products/​i2cspilcdbackpack/​i2cwire_t.jpg ​ |/​products/​i2cspilcdbackpack/​i2cwire.jpg}}
 +
 +For advanced users, this project can be used for general purpose I/O expansion, the MCP23008 has 8 i/o pins (7 are connected) with optional pullups, the SPI 74HC595 has 7 outputs.
 +
 +Assembled and tested backpacks are available for purchase for only $10 in the Adafruit shop!
  
 ====== Which LCD to use ====== ====== Which LCD to use ======
Line 31: Line 44:
 {{  :​products:​i2cspilcdbackpack:​terminalsoldered_t.jpg ​ |:​products:​i2cspilcdbackpack:​terminalsoldered.jpg}} {{  :​products:​i2cspilcdbackpack:​terminalsoldered_t.jpg ​ |:​products:​i2cspilcdbackpack:​terminalsoldered.jpg}}
  
-===== Attach ​LCD =====+===== Prepare ​LCD =====
  
 Next we will attach the backpack to the LCD. First we must put header onto the LCD, if you bought the LCD from us, it will come with a stick of header. Otherwise, pick up some [[http://​www.ladyada.net/​wiki/​partfinder/​header#​male_header|standard 0.1" male header]] Next we will attach the backpack to the LCD. First we must put header onto the LCD, if you bought the LCD from us, it will come with a stick of header. Otherwise, pick up some [[http://​www.ladyada.net/​wiki/​partfinder/​header#​male_header|standard 0.1" male header]]
Line 48: Line 61:
  
 {{  http://​www.ladyada.net/​images/​arduino/​lcdtut/​lcdbb_t.jpg ​ |http://​www.ladyada.net/​images/​arduino/​lcdtut/​lcdbb.jpg}} {{  http://​www.ladyada.net/​images/​arduino/​lcdtut/​lcdbb_t.jpg ​ |http://​www.ladyada.net/​images/​arduino/​lcdtut/​lcdbb.jpg}}
 +
 +===== Attach LCD =====
  
 Now we will attach the backpack. We will show how to do this in a permanent fashion. If you think you would like to remove and replace the LCD at some time, you can use [[http://​www.ladyada.net/​wiki/​partfinder/​header#​female_header|a piece of 16-pin long 0.1" female header]] as a socket but be aware it will stick out a lot. Now we will attach the backpack. We will show how to do this in a permanent fashion. If you think you would like to remove and replace the LCD at some time, you can use [[http://​www.ladyada.net/​wiki/​partfinder/​header#​female_header|a piece of 16-pin long 0.1" female header]] as a socket but be aware it will stick out a lot.
  
 +There are two options, you can tuck the backpack behind the LCD
 +
 +{{  :​products:​i2cspilcdbackpack:​option1_t.jpg ​ |:​products:​i2cspilcdbackpack:​option1.jpg}}
 +
 +Or solder it so it's to the side, this way it's thinner.
 +
 +{{  :​products:​i2cspilcdbackpack:​option2_t.jpg ​ |:​products:​i2cspilcdbackpack:​option2.jpg}}
 +
 +Solder the header to the backpack
 +
 +{{  :​products:​i2cspilcdbackpack:​assembled_t.jpg ​ |:​products:​i2cspilcdbackpack:​assembled.jpg}}
 +
 +Make sure that as you solder the first pin, the backpack PCB isn't leaning against the LCD, where the terminal blocks could short against some components. You can put some electrical tape or foam tape behind to avoid this if you think it could be an issue
 +
 +{{  :​products:​i2cspilcdbackpack:​assembledside_t.jpg ​ |:​products:​i2cspilcdbackpack:​assembledside.jpg}}
 +
 +That's it!
 +
 +====== Connect with I2C ======
 +
 +The first option we'll show is how to use the i2c interface on the backpack. We'll be showing how to connect with an Arduino, for other microcontrollers please see our MCP23008 library code for the commands to send to the i2c i/o expander. I2c is nice because it only uses two pins, and you can put multiple i2c devices on the same two pins. So for example, you could have up to 7 LCD backpacks+LCDs all on two pins! The bad news is that you have to use the '​hardware'​ i2c pins that are only on **Analog 4 & 5**. You can't change those pins and you can't use them for reading analog data. If you absolutely need those two pins, use SPI (see below)
 +
 +For this we'll need to connnect four wires: GND, 5V, CLK (clock) and DAT (data).
 +
 +{{  :​products:​i2cspilcdbackpack:​i2cwire_t.jpg ​ |:​products:​i2cspilcdbackpack:​i2cwire.jpg}}
 +
 +Connect ​ the **CLK** pin to **Analog 5** (i2c SCL pin) and **DAT** to **Analog 4** (i2c SDA pin). Connect the 5V and ground pins to respective power pins.
 +
 +Download and install the new LiquidCrystal library (scroll to the bottom of the page for download links and instructions) Load up the **HelloWorld_i2c** example sketch in the new LiquidCrystal library. If you don't see the **HelloWorld_i2c** example go through the process of installing the new library again, make sure you quit and restart. Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the **Contrast** trim potentiometer with a mini-screwdriver until you see the text clearly
 +
 +{{  :​products:​i2cspilcdbackpack:​i2cconnect_t.jpg ​ |:​products:​i2cspilcdbackpack:​i2cconnect.jpg}}
 +
 +If you want to have more than one MCP23008 device (like more than one backpack+LCD) each one needs to have a unique '​address'​. You can set the address by jumpering the **A0** **A1** and **A2** solder jumpers. By default, no jumpers are soldered, giving an address of **0**. If you want to have an address of **3** you would solder **A0** (bit 0) and **A1** (bit 1) for an address of "​011"​ = 3 in binary. Then in the code change
 +
 +  // Connect via i2c, default address #0 (A0-A2 not jumpered)
 +  LiquidCrystal lcd(0);
 +
 +to
 +
 +  // Connect via i2c, address #3 (A0&A1 jumpered)
 +  LiquidCrystal lcd(3);
 +
 +====== Connect with SPI ======
 +
 +Another option for connecting is to use **SPI**, which is a simpler protocol. The good news about SPI is that its very simple and you can use **any** 3 pins to connect. You can share the **data** and **clock** pins with another device as long as they remain outputs, the **latch** pin should only be used for the backpack. So if you wanted 3 LCDs, for example, they would all have the same **data** and **clock** pins, but the **latch** pin would be different, for 5 pins total.
 +
 +The first thing you will need to do is to enable SPI. To do this, solder the **SPI Enable** solder jumper by heating up the pads with a soldering iron and soldering a blob onto both pins
 +
 +{{  :​products:​i2cspilcdbackpack:​spiump.jpg ​ |}}
 +
 +This will switch the backpack over to SPI mode instead of i2c. If you want to go back to i2c, use wick or a solder sucker to remove the jumper
 +
 +Next we will connect 5 wires, **5V**, **GND**, **DAT**, **CLK**, and **LAT**. To match the example, **CLK** goes to to Digital 2, **DAT** to Digital 3, and **LAT** to Digital 4. Once we have the example sketch running you can of course change these to anything you'd like. Connect **5V** and **GND** to the 5v and Ground Arduino power pins 
 +
 +{{  :​products:​i2cspilcdbackpack:​spiwire_t.jpg ​ |:​products:​i2cspilcdbackpack:​spiwire.jpg}}
 +
 +Download and install the new LiquidCrystal library (scroll to the bottom of the page for download links and instructions) Load up the HelloWorld_SPI example sketch in the new LiquidCrystal library. If you don't see the HelloWorld_SPI example go through the process of installing the new library again, make sure you quit and restart. Upload the sketch. You should see the backlight turn on when the Arduino resets. If you don't see any characters, adjust the Contrast trim potentiometer with a mini-screwdriver until you see the text clearly ​
 +
 +{{  :​products:​i2cspilcdbackpack:​spiconnect_t.jpg ​ |:​products:​i2cspilcdbackpack:​spiconnect.jpg}}
  
-===== Download =====+====== Download ​======
  
-==== Arduino Library ====+===== Arduino Library ​=====
  
 We made a modification to the LiquidCrystal library so you can use it for i2c, spi or straight-up-6-pin connections. ​ [[http://​github.com/​adafruit/​LiquidCrystal|You can get the modified library that supports SPI/i2c from GitHub.]] We made a modification to the LiquidCrystal library so you can use it for i2c, spi or straight-up-6-pin connections. ​ [[http://​github.com/​adafruit/​LiquidCrystal|You can get the modified library that supports SPI/i2c from GitHub.]]
Line 67: Line 141:
 If you have a hankering to use the backpack as a general purpose i2c expander, you should use the plain [[http://​github.com/​adafruit/​MCP23008-library|MCP23008 library, also at github]]. Its for more advanced users, by the way. If you have a hankering to use the backpack as a general purpose i2c expander, you should use the plain [[http://​github.com/​adafruit/​MCP23008-library|MCP23008 library, also at github]]. Its for more advanced users, by the way.
  
 +==== Optimized i2c library ====
 +
 +**FalconFour** posted up a [[http://​forums.adafruit.com/​viewtopic.php?​f=19&​t=21586&​p=113177|ultra-optimized high-speed i2c library, check it out for better performance!]]
  
 +===== Hardware files =====
  
 +[[http://​github.com/​adafruit/​i2c-SPI-LCD-backpack|Eagle CAD format schematic and board layout file (as well as a PNG of the schematic) are all available in the GitHub repository]]
/home/ladyada/public_html/wiki/data/attic/products/i2cspilcdbackpack/index.html.1288659222.txt.gz · Last modified: 2016/01/28 18:05 (external edit)