Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« on: July 07, 2012, 06:17:17 pm » |
Hi again folks.
I have an UNO (equivalent) , a PHI-2 shield, and 20x4 LCD display.
I've read about the BACK LIGHTING resistor and went for the higher value, as it was for a bedside clock.
Anyway, new questions/problems have come to light - no pun intended.
I am about to put an MCP on the setup so I will have more than enough I/O pins to spare, and so pins 16 and 17 have become vacant.
As they are ANALOGUE pins, could I use one of them to adjust the backlight brightness?
My reasoning is this: (and it gets weird) For general use the display is ok, and I can read the digits, but:
Lying in bed I can't make out the exact time, and I was thinking: As the night goes on, the display gets darker; to a point. Then as morning starts to come, it gets brighter.
That way if I "wake up" and look at the display, depending on how bright/dark it is, I can get an estimate on the time.
Possible?
I know it will take a fair bit of code, but I am just looking at the idea for now. I have read that you use the PWM pins, and adjust the duty cycle, but a resistor is analogue. So as I have a "spare" analogue pin, I am biased that way.
|
|
|
|
« Last Edit: July 07, 2012, 06:19:14 pm by lost_and_confused »
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 9
Posts: 1003
|
 |
« Reply #1 on: July 08, 2012, 04:17:10 am » |
What is an MCP ? An analag input pin of the Arduino can be used as a digital pin. A digital pin can be used with PWM using a software PWM. Search for SoftPWM. I know this one: http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentationBut I haven't used that myself. I used an other one (but I can't find it anymore). Instead of using an internal timer in PWM mode, the SoftPWM uses a timer to generate an interrupt. And in that interrupt the pin (any pin) is toggled. It's like the tone() function, which can generate a tone on any pin this way.
|
|
|
|
|
Logged
|
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #2 on: July 08, 2012, 04:08:07 pm » |
Ok, sorry.
An MCP is a chip:
MCP 23017 I think.
It is an I2C bus I/O expander.
So with 2 wires from the Arduino to the chip I can get 16 (digital) I/O lines. Suffice to say enough for what I need for most of my stuff.
That will really help me free up some Arduino pins.
I shall read the rest of your post now.
|
|
|
|
« Last Edit: July 08, 2012, 04:09:59 pm by lost_and_confused »
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 71
Posts: 3486
|
 |
« Reply #3 on: July 09, 2012, 05:51:29 am » |
Don't you have a PWM pin free to use? It's much easier to handle than to use SoftPWM. What pins are still available?
The analog pins are analog inputs. The Arduino has no analog outputs but have several pins that have hardware support for PWM which is, in some applications, an alternative to analog output. If you don't have a PWM pin free to use, you can use SoftPWM to emulate the hardware functionality in software but that uses a timer which might posing other problems depending on the software used.
|
|
|
|
|
Logged
|
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #4 on: July 09, 2012, 03:59:25 pm » |
Alas, no.
There are only 2 pins usable:
16 and 17.
Though the SPI bus pins are also free. So I guess that is 4. Though the SPI bus may be a good idea to keep free in the weird off chance I need it.
That is why I am putting this MCP (I/O expander) on/in the system.
Though I don't need THAT MANY pins, it is the best solution to the problem I can see.
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 71
Posts: 3486
|
 |
« Reply #5 on: July 09, 2012, 06:36:54 pm » |
Pin 11 has hardware PWM support. If you don't really need it, I would choose that one.
|
|
|
|
|
Logged
|
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #6 on: July 09, 2012, 07:03:36 pm » |
Pylon,
I don't have the sketch in front of me now, but I seem to remember it is used for the LCD.
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 71
Posts: 3486
|
 |
« Reply #7 on: July 10, 2012, 02:52:49 am » |
Do you use the LCD in 4 or 8 data wire configuration? If you use 8 data wires it's easy to free 4 of them.
|
|
|
|
|
Logged
|
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #8 on: July 10, 2012, 03:21:19 am » |
Yeah, ok, it is used by the buttons on the SHIELD.
#define total_buttons 6 #define btn_u 5 #define btn_d 10 #define btn_l 11 #define btn_r 4 #define btn_b 14 #define btn_a 15
It is too much trouble moving the buttons now.
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 34
Posts: 2404
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #9 on: July 10, 2012, 06:24:58 pm » |
Liudrs Phi Shield has a settable backlight as part of his software but there are several pages of stuff to read to find it. I own 3 or 4 of his LCD backpacks and for the lcd control according to john (Liudr) he used the software for the shield to make his serial backpacks. Impressive little things, control a 20 X 4 and read a keypad as well I think he said the ports could also be used for other control stuff as well. Great product but Extremely poorly documented.
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #10 on: July 10, 2012, 06:37:16 pm » |
Liudrs Phi Shield has a settable backlight as part of his software but there are several pages of stuff to read to find it. I own 3 or 4 of his LCD backpacks and for the lcd control according to john (Liudr) he used the software for the shield to make his serial backpacks. Impressive little things, control a 20 X 4 and read a keypad as well I think he said the ports could also be used for other control stuff as well. Great product but Extremely poorly documented.
Doc
I wish I could agree. I am having head ache after head ache. The back lighting is now done with a resistor. I can't see any software control available. The shield is badly (to say the least) designed for where the buttons are and use of pins. But I am getting there. Slowly.If you can find where the software control for the display lighting is, please let me know.
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 34
Posts: 2404
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #11 on: July 11, 2012, 03:38:37 am » |
Yes it can I think be found in the PHI big panel display... Here is what I did, you can I think how to use it mySerial.print("\e[26;255m~"); // set lcd @ 100 % backlight I used this code with one of his backpacks it is my understanding that your lcd is controlled by a processor on the the board that the switches are and I think a 3 X 4 or 4 X 4 can be used instead of the switches on an 8 pin sip header I don't know My backpacks do and beyond several conversations with the man that is all I really know, read all the sketches, that's all the documentation on a complex program. That is where I found the information I sent you but I had to learn somehow... so I read them well enough to understand about 25%... and an idea of where to look. there are lcd cursor controls to blink underline solid... and I am sure he implemented some kind of cursor placement for printing to the lcd in various places as well as the ability to deal with the 8 programmable characters the LCD can display.
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Oz
Offline
God Member
Karma: 2
Posts: 564
|
 |
« Reply #12 on: July 11, 2012, 05:26:12 am » |
Thanks.
I am trying to read that big block of text.
Suggestion: A few line breaks would help.
So what do I need to send to the display to set the different levels of light?
mySerial.print("\e[26;255m~"); // set lcd @ 100 % backlight
What is the value which sets the brightness?
How do I take it from 1% to 100%?
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 34
Posts: 2404
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #13 on: July 11, 2012, 11:57:44 pm » |
The big number 255 is full and 0 would be none. Out of habit I set that value to 128 or half bright... Looks ok with one of white on blue 4X20 displays.
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
|