Am currently trying to get my head around Node and JS. I am currently using Google Coder....
http://googlecreativelab.github.io/code ... ky_lights/
Have completed the 'Blinky Lights' demo project and works perfectly. Then swapped out breadboard for 4-relay board and hooked this up. Also works perfectly, the on-screen button displayed in the 'Blinky Lights' app switches the 1 connected relay on & off as expected.
Also then added following code to the so I can turn the relay on / off by holding down / releasing the up arrow key..
Code: Select all
$(document).bind('keydown',function(e){
if(e.keyCode == 38) {
$(this).addClass('press');
ledOff();
}
});
$(document).bind('keyup',function(e){
if(e.keyCode == 38) {
$(this).addClass('press');
ledOn();
}
});I now want to add further key press controls to control other relays and have tried to duplicate within the code anything that obviously refers to LED1 as this is what is being controlled. I have very carefully copied all classes / functions etc and created everything I believe that 'LED2' would logically require but unfortunately it doesn't work and does not seem to be a simple syntax error.
I was going to paste the code then realised that to show original and my hashed version would be nearly 1000 lines of code (my additions to the original are only about 20-30 lines!
Essentially I am trying to build a control interface that will have 3 'turn on relay x whilst key n is pressed' controls and I have zero experience with either node or js - I was rather hoping it would be relatively straightforward but am now completely stumped.
If anyone is able / happy to help I can send the code - or if anyone can point me in the right direction that would be very much appreciated.