Funktionen


Inhaltsübersicht      

Die startProgram Funktion
async function startProgram() {
while (true) {

// Dein Code

// Bei einer leeren Schleife wirst du ohne delay einen runtime Error bekommen
await delay(0.033);
}
}
Funktionen Definieren

async function blink() {
playSound(Sound.Effects.Click);
setMainLed({ r: 255, g: 0, b: 0 });
await delay(0.5);
setMainLed({ r: 0, g: 255, b: 0 });
await delay(0.5);
}

async function startProgram() {
await blink();
}
Parameter

async function blinkParams(time, loops) {
for (var count_1 = 0; count_1 < loops; count_1++) {
playSound(Sound.Effects.Click);
setMainLed({ r: 255, g: 0, b: 0 });
await delay(time);
setMainLed({ r: 0, g: 255, b: 0 });
await delay(time);
await delay(0.025);
}
}

async function startProgram() {
await blinkParams(0.5, 5);
await blinkParams(0.15, 10);
}