Voxer
New Coder
I´ve been trying to run this function with delays to turn on some LED's
could someone please tell me what im doing wrong
Am using a Raspbery Pi B+
JavaScript:
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function functiontest() {
GPIO26value = 1;
LED26 = 1;
await sleep(3000);
GPIO26value = 0;
LED26 = 0;
await sleep(3000);
GPIO20value = 1;
LED20 = 1;
await sleep(3000);
GPIO20value = 0;
LED20 = 0;
await sleep(3000);
GPIO15value = 1;
LED15 = 1;
await sleep(3000);
GPIO15value = 0;
LED15 = 0;
await sleep(3000);
GPIO21value = 1
LED21 = 1;
await sleep(3000);
GPIO21value = 0;
LED21 = 0;
await sleep(3000);
GPIO16value = 1;
LED16 = 1;
await sleep(3000);
GPIO16value = 0;
LED16 = 0;
await sleep(3000);
GPIO19value = 1;
LED19 = 1;
await sleep(3000);
GPIO19value = 0;
LED19 = 0;
await sleep(3000);
GPIO13value = 1;
LED13 = 1;
await sleep(3000);
GPIO13value = 0;
LED13 = 0;
await sleep(3000);
GPIO6value = 1;
LED6 = 1;
await sleep(3000);
GPIO6value = 0;
LED6 = 0;
await sleep(3000);
GPIO5value = 1;
LED5 = 1;
await sleep(3000);
GPIO5value = 0;
LED5 = 0;
await sleep(3000);
GPIO12value = 1;
LED12 = 1;
await sleep(3000);
GPIO12value = 0;
LED12 = 0;
await sleep(3000);
GPIO25value = 1;
LED25 = 1;
await sleep(3000);
GPIO25value = 0;
LED25 = 0;
await sleep(3000);
GPIO24value = 1;
LED24 = 1;
await sleep(3000);
GPIO24value = 0;
LED24 = 0;
await sleep(3000);
GPIO23value = 1;
LED23 = 1;
await sleep(3000);
GPIO23value = 0;
LED23 = 0;
await sleep(3000);
GPIO22value = 1;
LED22 = 1;
await sleep(3000);
GPIO22value = 0;
LED22 = 0;
await sleep(3000);
GPIO27value = 1;
LED27 = 1;
await sleep(3000);
GPIO27value = 0;
LED27 = 0;
await sleep(3000);
GPIO17value = 1;
LED17 = 1;
await sleep(3000);
GPIO17value = 0;
LED17 = 0;
await sleep(3000);
GPIO18value = 1;
LED18 = 1;
await sleep(3000);
GPIO18value = 0;
LED18 = 0;
await sleep(3000);
GPIO4value = 1;
LED4 = 1;
await sleep(3000);
GPIO4value = 0;
LED4 = 0;
await sleep(3000);
GPIO14value = 1;
LED14 = 1;
await sleep(3000);
GPIO14value = 0;
LED14 = 0;
}
if(GPIO2value == 1){
functiontest();
}
Am using a Raspbery Pi B+
Last edited by a moderator: