Hi
I’m just beginning with the Imp.
I’ve managed to send text to an LCD and read from a sensor (LDR) and get the value in the planner. Now I want to put the sensor value to the LCD, however, I can’t get it to display, all I’m getting is random single characters instead of the numerical values. I’ve tried various ways like making a separate function for the text part both inside and after the checkLDR function and various curly bracket combinations but it always gives the same result.
I’m using a Sparkfun shield which is fine when it’s text only and the value is OK in the planner at all times. The LCD is a Textstar serial LCD, it’s set up for TTL and the correct baud rate (I’ve tried different rates, it looked like a baud rate issue!)
I’ve used some of the code from the analog pot sketch on the Wiki (btw, a line in that code ‘out_pot.set(potValue);’ gives an error and it runs fine without it.) and I’m adding in text code to that modified sketch.
Any help appreciated
Dougie
`hardware.pin8.configure(ANALOG_IN);
hardware.uart12.configure(38400, 8, PARITY_NONE, 1, NO_CTSRTS);
CharactersInLCD <- 16;
// you can read the imp’s input voltage at any time with:
local voltage = hardware.voltage();
server.log(format(“Running at %.2f V”, voltage));
local lastRawValue = 0;
server.log(“Hardware Configured”);
function checkLDR() {
local rawValue = hardware.pin8.read();
if (math.abs(rawValue - lastRawValue) > 150) {
lastRawValue = rawValue;
server.show(rawValue);
hardware.uart12.write(12); //sets the cursor to line 1 column 1
hardware.uart12.write(rawValue);
}
imp.wakeup(0.5, checkLDR);
}
server.log(“measure LDR”);
imp.configure(“read LDR”, [], []);
checkLDR();
`