Fibonacci Sequence
int led = 13;
int num1 = 0;
int num2 = 1;
int fibonacci;
void setup(){
pinMode(led, OUTPUT);
}
delay(1000+2000); //delay for no blinking and regular delay time
//blink once
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500);
delay(2000); //delay
//blink fibonacci
void loop(){
fibonacci = num1 + num2;
for (int i= 0; i < fibonacci; i++){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
delay(2000);
num1 = num2;
num2 = fibonacci;
}
No comments:
Post a Comment