This is the code I use when Espruino stop working.
There is some error as console log after first "wake up" print console value twice, then every next wake up it increase the number of console.log prints
function OLED(){
pinMode(A7,'output'); //A7 Mosfet Gate PIN for OLED
digitalWrite(A7,1);
I2C1.setup({scl:B6,sda:B7});
var g = require("SSD1306").connect(I2C1);
g.clear();
g.flip();
pinMode(B14, 'input_pulldown');
pinMode(B15, 'input_pulldown');
//variables
var BTN22 = B15;
var BTN11 = B14;
var screen = 0;
var battery = analogRead(A0)*2*3.3;
var i = true;
function screens(){
g.clear();
g.setFontVector(15);
g.drawString("MOTOR ON",20,20);g.flip();
}
function screens2(){
g.clear();
g.setFontVector(15);
g.drawString("OLED OFF?");g.flip();
}
function screens3(){
g.clear();
g.setFontVector(20);
g.drawString("" + battery.toFixed(2));
g.flip();
}
setWatch(function(e) {
if(screen === 0) screens();
if(screen === 1) screens2();
if(screen === 2) screens3();
screen++;
console.log(screen);
if(screen > 2) screen = 0;
},BTN22, {repeat: true, edge: 'rising', debounce:150});
setWatch(function(e) {
i = !i;
if(screen === 0) OLED();
if(screen === 2) digitalWrite(A7,i); screen =0;
console.log(screen);
},BTN11, {repeat: true, edge: 'rising', debounce:150});
screens();
}
OLED();
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.
This is the code I use when Espruino stop working.
There is some error as console log after first "wake up" print console value twice, then every next wake up it increase the number of console.log prints
about reset
do you mean about this pin?
1 Attachment