The code isn't a function yet, but later on it's supposed to take blinking on/off time as inputs and let several LEDs blink independently of one another.
Here's the code:
int on=250; //the diode's on time
int off=250; //the diode's off time
int timer=1; //the timer counts milliseconds passed
int ifOn=1; //1 if the diode's lit, 0 if it isn't
void setup() {
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
}
void loop() {
delay(1);
if(ifOn=1){
if(timer>on){ //if the timer reached the on time, the diode turns off, and the timer resets
ifOn=0;
timer=1;
digitalWrite(9,LOW);
}
}
if(ifOn=0){ //and vice versa
if(timer>off){
ifOn=1;
timer=1;
digitalWrite(9,HIGH);
}
}
timer++;
}
I know it's neither my PC nor my circuit at fault here, because a standard, 4-line code for a single blinking LED works fine.
Thanks in advance!