Oay, this is going to be a bit of a novel, but please bear with me. I've been working on this for a while, and have tried a lot to get it working.
I've been in the process of building a powder trickler system for the past 3 months based around a Mega 2560 clone. The plan is to have the motor driver, load cell, keypad and LCD screen all controlled by the Arduino in a way that allows for standalone use.
My project consists of:
- Storm Interface 720BLK 16 key matrix keypad
- Sparkfun HX711 breakout
- Sparkfun Serial-enabled 16x2 LCD screen
- NEMA17 stepper motor
- Big Easy Driver
- Generic 100g load cell (I also have 50g and 500g cells on hand)
The hardware is all assembled (at least as far as the first prototype is concerned), and I have been able to get each of the individual components working on their own (though I haven't written the motor portion yet, I've been able to use sample code), and it's a pretty trivial matter to get the LCD working with the right libs (I even got bored and wrote out code to vary the backlight brightness). The trouble comes in when I try to add the scale functionality in on top of the keypad code.
I didn't write the keypad code; I actually pulled it from an older post on this site, where someone needed to input multi-digit sequences (I think they were building a lock or something). However, it was pretty easy to adapt it to my needs (or so I thought). The way it's written, the keypad keeps waiting for input until the # key is pressed, then it returns the integer value of whatever key combination the user presses - pretty straightforward.
Except when I add the scale code, the load cell doesn't update unless I press #, in which case it updates once, until I press it again. That's not practical, and it has a nasty habit of zeroing out the variable in the loop() function that's set to catch the readings. If I remove the call to GetNumber(), the load cell fires right up, and behaves properly.
I thought I might be able to use interrupts, so in looking over those in hopes of finding some sample code around which I could write a replacement for the GetNumber() function, I came across this blog post detailing a pseudo-interrupt event built into the keypad library. I gave it a go, and my limited test seemed to work - the load cell measured unimpeded, and I was able to put some digits up on the LCD screen (and moved my backlight code over as part of my test, which also worked). However, I don't think I'm remotely close to where the code needs to be to do what I want. I tried expanding it to look more like GetNumber(), and I even tried using the event to call GetNumber().
Anyway, this is the part where I ask for guidance. Please, any ideas you might have, I'd be grateful. I'm so close to getting it working I can taste it. And that is a frustrating feeling.