Nuances of shetch Code


i have sample piece of code built 1 of embedded sketches
yes simple code , new @ arduino programming have coded in other languages c before , far can tell should working have tried different iterations different forms of if condition no success

here sketch , want flash between line 13 onboard led , external led on line 7 switch occur faster , faster until delay 0 starts slowing down until delay hits 1000 , loops again continuously


/*
 blink
 turns on led on 1 second, off 1 second, repeatedly.

 this example code in public domain.
*/

// pin 13 has led connected on arduino boards.
// give name:
int led = 7;
int obled = 13;
int dlay = 100;
int val = 1;

// setup routine runs once when press reset:
void setup() {                
 // initialize digital pin output.
 pinmode(led, output);    
 pinmode(obled, output);    
}

// loop routine runs on , on again forever:
void loop() {
 digitalwrite(led, high);   // turn led on (high voltage level)
 delay(dlay);               // wait time
 digitalwrite(led, low);    // turn led off making voltage low
 digitalwrite(obled, high);   // turn obled on (high voltage level)
 delay(dlay);               // wait time
 digitalwrite(obled, low);    // turn obled off making voltage low

 if ((dlay <= 0) || (dlay >=1000)) {
   val= val * -1;
 }
 dlay = dlay + (val * 100);  
}

it seems simple enough , should want cycles fast slow never goes fast again how stuck on high end of delay value. there nuance of sketch code missing.

ok seems working fine nuance


Arduino Forum > Using Arduino > Programming Questions > Nuances of shetch Code


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62