NP... I'll take it easy... you being experienced with Arduino: you will find out Espruino is like vacation and fun!
But in deed: thinking in Espruino IS (a bit - to say at least) different... loop versus event. And because it is event driven, you can do all the things you plan to do.
To get you going, I suggest you start with the wall device and the part of it that controls your ac... and for development - and teaching - purposes, assume, you are running it for an initial period on connected via USB... and then later, adding the Web server / wifi onto it so you can control it via internet.
What kind of key pad are you thinking about? How many key are there? Is it multiplexed or is every key (button) just connected to a pin and can operate independent of each other?
I assume - for simplicity - you have a two buttons - call them tmpUpBtn and tmpDownBtn hat work as their names imply: pressing them once will increase / decrease the desired temperature. The buttons are plain push buttons that on press connect a pin with ground. I also assume, you are using a Pico, some bread board, etc. But let me know what you have and where you plan to go.
I will start very simple, and over time the things will evolve into more elaborate consturcts and objects that are easy to handle and pass on to any processing you nead, including creating a response to a http request from your browser over your planned wifi access.
var dbg = true;
var log = function() { console.log(arguments.join("")); };
var tmpTarget = 21; // Celsius
var tmpTargetMax = 30;
var tmpTargetMin = 18;
var tmpAdj = 0.5;
var tmpUpBtn = A6; // PIN A6
var tmpDownBtn = A5; // PIN A5
var tmpTargetAdj = function(adj) {
tmpTarget = (
((tmpTarget += adj) > tmpTargetMax)
? tmpTargetMax
: (tmpTarget < tmpTargetMin)
? tmpTargetMin
: tmpTarget
);
if (dbg) log("target Temp (tmpTarget): ",tmpTarget);
};
var initPins = function() {
pinMode(tmpUpBtn,"input_pullup");
pinMode(tmpDownBtn,"input_pullup");
};
var tmpBtnsWatch = function() {
setWatch( function(){ tmpTargetAdj(+tmpAdj); }, tmpUpBtn
, {repeat: true, edge:"falling", debounce:50 } );
setWatch( function(){ tmpTargetAdj(-tmpAdj); }, tmpDownBtn
, {repeat: true, edge:"falling", debounce:50 } );
};
function onInit() {
console.log("onInit");
initPins();
tmpBtnsWatch();
if (dbg) log("target Temp (tmpTarget): ",tmpTarget);
}
Wire your buttons, connect Espruino, copy, past and upload this script (attached as AC09.js file), and operate your buttons... - I hope not having made typos.
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.
NP... I'll take it easy... you being experienced with Arduino: you will find out Espruino is like vacation and fun!
But in deed: thinking in Espruino IS (a bit - to say at least) different... loop versus event. And because it is event driven, you can do all the things you plan to do.
To get you going, I suggest you start with the wall device and the part of it that controls your ac... and for development - and teaching - purposes, assume, you are running it for an initial period on connected via USB... and then later, adding the Web server / wifi onto it so you can control it via internet.
What kind of key pad are you thinking about? How many key are there? Is it multiplexed or is every key (button) just connected to a pin and can operate independent of each other?
I assume - for simplicity - you have a two buttons - call them tmpUpBtn and tmpDownBtn hat work as their names imply: pressing them once will increase / decrease the desired temperature. The buttons are plain push buttons that on press connect a pin with ground. I also assume, you are using a Pico, some bread board, etc. But let me know what you have and where you plan to go.
I will start very simple, and over time the things will evolve into more elaborate consturcts and objects that are easy to handle and pass on to any processing you nead, including creating a response to a http request from your browser over your planned wifi access.
Wire your buttons, connect Espruino, copy, past and upload this script (attached as AC09.js file), and operate your buttons... - I hope not having made typos.
Your output should show the (adjusted) tmpTarget.
1 Attachment