Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Wednesday, April 13, 2016

I2C LCD Display Problems

I hope this post can be a rescue ring for anyone struggling with this problem. I purchased several lcd displays on eBay from a seller named 'Frentaly.' Now the seller was fantastic, located in the US so shipping was fast and the build quality was very good, however, I couldn't find a library that would work with it. I contacted Frentaly and they didn't know what the problem was, but offered me a refund, which I declined because I was certain I was doing something wrong (how could three lcds be defective?!).

I became an expert on these lcd screens. I used every library and sketch I from every how-to video and blog out there, but nothing seemed to get the display to show text. I could flash the back light, read the device's address, but I couldn't see the text I was sending it. I gave up for a week in frustration, and finally reproached it yesterday at work when I found a page on i2c lcd displays (not the solution, but still a great resource). I thought maybe I had found the right library, because that page says some lcds have different wiring. I got home, ran it, and it wasn't fixed. Undeterred I scoured the net looking for customer reviews, hopeful someone else would share this problem. I finally found a useful review on amazon (no link because I can't find it again, but thank you amazon reviewer!).

The lcd I bought came with a pre-soldered 'backpack' on it, which would make it possible to use only I2C wiring, instead of several i/o pins. On this backpack is a small blue box with an adjustment knob on it, can you guess what that knob does?


Contrast, Bingo! Turn it until you can see the text on your screen, and voila! Miraculously, my screen works now. If your display doesn't have one of these backpacks you can pick one up on ebay for 99 cents, and it'll make your life a whole lot easier!


Thanks for reading, and as always, check your wiring!

Friday, April 1, 2016

4 Digit 7 Segment Clock with DS3231



Earlier this weekend I found out what a shift register was and managed to get a 4 digit 7 segment display (4D7SD) to show counting milliseconds using Kristian BlĂ„sol's videos here: Shift Register, 4D7SD. These two videos are fantastic and really show you how to work with these concepts, please watch them if you are interested in getting this wired up, I will only be covering my modifications to his setup. In my code you'll notice I used a cheat at the end instead of figuring out how the cathode call numbers worked.

Now I really wanted to take this a step further. My goal was to build a display that would show the current time (hh:mm) with the 4D7SD. Naturally, to do this I would need a clock (and not the millis like I used in my last post). Enter the DS3231. This is a nifty little device, I bought several on ebay (about 1.5$ for 2). They have a battery to keep time even when the board is turned off.

I used this instructable for wiring. The library linked in this will get you going with pretty much all you need with the DS3231. However, the functions in the library use pointers which, for the uninitiated, are a *****. I am not qualified to explain a pointer, but my understanding is it basically is a variable that 'points' to somewhere else. My guess in this application would be the pointer runs a functions to grab the time from the DS3231.

Anyway, the problem with the pointers is, you can't convert them to a different value. What this means for you is that the value your library takes from the DS is a 'char' not an 'int'. The end result is you have to jump through a bunch of hoops (as you'll see in my code) to get it to do what you want. You can't compare characters to integers, and a bunch of other things I can't think of right now.