Go Down

Topic: Does the LCD need PWM? (Read 7035 times) previous topic - next topic

akaJag

As I am going through the starter kit guide one of the example projects uses a LCD screen (datasheet), and when you hook it up you use the pins 12, 11, 5, 4, 3, and 2 in that order during the initialization. But is there a reason to this?

The example code tells me to use this order
Code: [Select]
LiquidCrystal lcd(12,11,5,4,3,2);
But can I just use this order (if I also change up the pins)?
Code: [Select]
LiquidCrystal lcd(2,3,4,5,6,7);

I am using the Arduino UNO, and the pins are all digital and pins 3, 5, and 11 of those pins are PWM.

MAS3

No, it doesn't need PWM.
You could use PWM for backlight control, but that has nothing to do with the LCD itself, nor with its library.
There might be other reasons not to choose those pins you put in your example like some specific function a pin might have and you'd need.
But you can use any pin you like.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

akaJag


No, it doesn't need PWM.
You could use PWM for backlight control, but that has nothing to do with the LCD itself, nor with its library.
There might be other reasons not to choose those pins you put in your example like some specific function a pin might have and you'd need.
But you can use any pin you like.


Alright sweet! Should I add [solved] or whatev to the name of the topic?

cmiyc


Alright sweet! Should I add [solved] or whatev to the name of the topic?

Optional.  Nobody is graded on how many threads get closed.  ;)

The etiquette we all appreciate is not deleting the thread once you get an answer.   That's more important than marking as solved.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

akaJag


Optional.  Nobody is graded on how many threads get closed.  ;)

The etiquette we all appreciate is not deleting the thread once you get an answer.   That's more important than marking as solved.


So you're saying I should not and let the topic get deleted?

GoForSmoke

Topics don't normally self-delete. The lessons stay up where people can find them.

Do you know that every I/O pin can be used as a digital pin?
But some pins have special capabilities that you can do insanely neat tricks with?
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

akaJag


Topics don't normally self-delete. The lessons stay up where people can find them.

Do you know that every I/O pin can be used as a digital pin?
But some pins have special capabilities that you can do insanely neat tricks with?



So the analog pins, can they also be used for example digital output?
And what are those insanely awesome trocks? :o
I have been staying away from pin 1 and 2 because the guide book does it

GoForSmoke

So the analog pins, can they also be used for example digital output?
And what are those insanely awesome trocks? :o
I have been staying away from pin 1 and 2 because the guide book does it
[/quote]

1) Yes, the pins that are connected to the ADC (there is one Analog/Digital Converter) are also digital pins.

2) The ones I know best involve switching pin mode and/or direction to make the same wired circuit behave in different ways. The speed of the Arduino to do this plays a major part, switching or reading a digital a pin generally takes less than half a millionth of a second.

3) examples of awesome tricks that can save you parts/code (ie money and work) which IIRC is almost as awesome as catching on to how FAST these things work:

a) So you can go from lighting a led through a resistor using two pins to, with no change in wiring, using the same led as a light sensor and back so fast that human eyes can't see it was ever off. That trick lets you make a code+circuit that self-adjusts its own brightness when background light changes. It is used in some TV remotes, phones, etc.

b) You can use two pins, a few cheap parts and some foil or other conductive surfaces to make proximity/touch sensors with similar tricks as light-sensing with a led. Really, from switches that have no moving parts and can work from under cover material to sections of wall or floor that sense if someone is standing within a meter or so, capacitive sensing can do the job at low cost.

c) If you have more switches than pins the first trick you do is multiplexing by putting the switches on a grid of wires from X pins by Y pins, a 3x4 is good for 12 switches. If you want to be able to read many switches pressed at the same time then you turn all the pins off and quickly read just 1 pin on each side of the grid at once (to read only one switch) and go through 12 switches in a few miroseconds and know which ones are pressed or not though caveat, most switches need "debouncing" so it can take a few milliseconds to be SURE the switch is pressed.  :smiley-mr-green:

d) If you need even more switches for the same number of pins then there is a trick called charlieplexing. I have no simple explanation of it, look it up if you need as the full explanation is a page or so. The wiring is hard and so is the code, I haven't needed to do it beyond experiment that convinced me it's only for when you really need it!

e) If you don't have enough analog pins or you want to sense analog values quicker than analog read (can take 105 microseconds to do a 10 bit read, less to do "fast" analog read) at lower resolution (say I only want 16 value-steps instead of 1024 or you want to be able to errrr, say that your device reads fifty shades of gray in less than a tenth of a millisecond) then you can set up a charge holder (capacitor or even just a length of wire or else) that you charge (make HIGH) with the same pin that you turn around and read until it goes LOW. How long that took tells you the charge. The same "time the discharge" technique can let you measure higher resolution than 10-bit ADC but it takes longer, way longer.
I cheat a bit here. This is behind examples a and b. It is also how cheap PC joystick adapters work.

f) You can adjust PWM rates to do neat stuff but I have yet to need to so save that for looking up.

That's all I've got off the top of my head and my typing fingers.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

akaJag


That's all I've got off the top of my head and my typing fingers.


Haha that's a lot of text. Now for a lot of input/output I've heard of shift registers. I guess you excluded them because they are a separate component...? Are shift registers a form of multiplexing?

GoForSmoke

They get called "pin multipliers" here. I have some that are 8 bit bi-directional, they're not just parallel in or out.

I lean towards the Arduino is a dev board philosophy. The goal is to make stand-alone AVR's with whatever you hang on them, components, chips, modules, power, whatever, the sky is the limit and with the Arduino satellite even the sky is not though I doubt that I'll be paying to have my code run in orbit.

One thing you might see about learning is how to turn a micro-SD adapter (the full SD size "sleeve" that usually comes with a micro-SD card) into an Arduino SD adapter. You can save a few bucks right there and make something more reliable than the ultra-cheap eBay modules.

Many shift registers, SD adapters, serial RAM chips and other devices run on the SPI bus. It's fast and you can hang a lot of devices on it, definitely worth learning. A few pins goes a long way with SPI. Also note that every AVR serial port is capable of full speed master mode (only) SPI. The UNO's 328P chip has only 1 but the 1284P has 2 and the 2560 has 3.

I2C bus is good for a lot of devices too but it's slow by comparison (still beats humans!). OTOH you can run long I2C cables (SPI must be short) out to sensors, etc.
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Go Up