Reusing pins
#1
Posted 14 May 2011 - 07:17 AM
As a next step, I tried combining the 2 programs, completely forgetting the hardware side of things - both programs were using the same pin (D12)!
Of course, I found it the hard way, getting an exception thrown somewhere in the MicroLiquidCrystal code. I'm using a bread board, and thought I could just plug in the LED to a row connected to the pin, but the pin is already in use by the LCD.
Clearly, I'm missing a key piece in electronics, or hardware programming. The LCD, as wired now, uses almost all of the digital pins (2-12 - see post for list). I want to move forward and start wiring sensors, some LEDs, maybe a button or two. But if I can only have one leg connected to one pin - I'm out.
What do I need to do to be able to use the LCD as it is wired right now, but continue to add components? Do I have to use the analog pins? And what happens when they run out?
Thanks,
Guy
#2
Posted 14 May 2011 - 07:48 AM
Using the analog pins would certainly get you going for now. If you are keeping the LCD in this configuration then you will need to start looking at multiplexing. This should allow you to add more digital outputs.What do I need to do to be able to use the LCD as it is wired right now, but continue to add components? Do I have to use the analog pins? And what happens when they run out?
It may be worth looking at using 74595 shift registers to control the LCD as this will reduce the number of pins you require. Szymon Kobalczyk has a blog post with some code.
You could also use the shift registers to give you more digital outputs (see Stefan's project) or use dedicated multiplexing chips.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#3
Posted 14 May 2011 - 08:47 AM
#4
Posted 14 May 2011 - 08:30 PM
Thanks Mark and Mario - I'll start diving into the 74HC595 shift-register right away. Found t on SparkFun already. Any other component I need to get to use it, just off the top of your head?Hello Guy.
Mark is absolutely right.
Driving a LCD in a parallel fashion is a waste of pins, and they are precious indeed!
That's not all: consider seriously the tip of using the 74HC595 shift-register. By using it, you will take advantage of the SPI interface, having a dramatic increase of speed.
Cheers
#5
Posted 15 May 2011 - 06:46 AM
Nothing else really needed to use them as multiplexing chips. The switches and LEDs Stefan used were to demonstrate the output from the Netduino. Szymon used a few other components to add some control for a backlight - the component list is in the blog entry.Any other component I need to get to use it, just off the top of your head?
Glad to be of help,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users