Tweeting sensor data

I’ve done a blog post about tweeting sensor data using the Imp and COSM it’s HERE

This is the code, full description on the blog

`
hardware.pin8.configure(ANALOG_IN);
LDR<- OutputPort(“My ADC reading”,“number”);
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));

lastRawValue <- 0;

server.log(“Hardware Configured”);

local lastRawValue = 0;

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(format("Light val = %d",rawValue));
    LDR.set(lastRawValue );
}
imp.wakeup(300, checkLDR);

}

server.log(“measure LDR”);
imp.configure(“measure LDR”, [], [LDR]);

checkLDR();
`

I had to do an edit to this code because I realised I’d put the line

local lastRawValue = 0; in twice when the first instance should have been
lastRawValue <- 0; as advised by mjkuwp94.