Just copying the code together I'd say it should look like this:
//replace D0 const CS_PIN = D0; const CLK_PIN = D0; const MOSI_PIN = D0; var isActive = false; var d=1; var toPrint = "Got: "; //CS_PIN setWatch(function() { isActive = true; d=1; //cleanup at start },CS_PIN,{edge:"rising", repeat: true}); setWatch(function() { isActive = false; console.log(toPrint); toPrint = "Got: "; if (d!==1) { console.log("Bit error"); } },CS_PIN,{edge:"falling", repeat: true}); //CLK_PIN setWatch(function(e) { if (isActive) { d=(d<<1)|e.data; if (d>255) { toPrint = toPrint + (d&255); d=1; //cleanup after 8 bits } } },CLK_PIN,{edge:"rising", data:MOSI_PIN, repeat: true});
@maze1980 started
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.
Just copying the code together I'd say it should look like this: