Fibonacci on Intel Galileo Gen 2

Fibonacci, I got to know about thing in a programming class back in 2004 when I was learning Turbo Pascal. Since that this is the next program I write after hello world when ever I try a new device, a new compiler or a new platform. The same story continues with the Intel Galileo Gen 2 also.
https://vine.co/v/epWdAvOaPK2/embed/simple
And this the the code…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  int i = 1;
  int a = 0;
  int b = 1;
  int c = 0;
  while (i<=1000)
  {
    f_blink(a);
    c = a + b;
    a = b;
    b = c;
    i++;
  }
   
}

void f_blink(int x)
{
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(x*500);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(x*500); 
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s