Hi,
I stumbled upon THIS webpage for the electric imp. Github link to the code
It has implemented the read function using :
function read_weight(){
//This is bit banged so we
//bind calls to local variables
//to speed things up.
//Takes about 2.2mS to do the read
local sw = spi.write.bindenv(spi);
local dr = data.read.bindenv(data);
local val = 0;
for(local i = 24; i >= 0; i--){
sw(PULSE);
val += dr() ? math.pow(2, i) : 0;
}
return (val-ZERO_OFFSET)/GAIN; //Value in grams
}
It does point out that I should have typed >0 in the for statement not 1...
I will test my code again with the refinements suggested by Gordon later tonight hopefully and will report back.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
I stumbled upon THIS webpage for the electric imp.
Github link to the code
It has implemented the read function using :
It does point out that I should have typed >0 in the for statement not 1...
I will test my code again with the refinements suggested by Gordon later tonight hopefully and will report back.
Many thanks,
Aaron