Q. By modifying the Arduino code it is possible to blink all three LED's at once demonstrating parallel architecture. Then how is it different from FPGA? (Abhay Vinayak Mutalik Desai)



Solution:

The human eye's capabilities to see visible changes in brightness are often referred to as Flickers in Televisions. We cannot see changes happening at a rate above 60 Hz. So anything faster than that will simply appear continuous for us. Assume we see continuous images or video on TV but we know we turn on and off each pixel at a time. Similarly, Abhay what you are turning LED so fast that it simply appears to us that all are ON at a time. We can either add the oscilloscope to see the time difference between the turning on of the three LEDs to prove our hypothesis or we could just measure the time it takes to complete the turning on of each LED. Here we will use the second approach to prove our hypothesis.


Arduino Sketch:


void setup()
{
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  unsigned long time1,time2,time3;
  
  digitalWrite(13, HIGH);
  time1 = micros(); ///Calculate number of microseconds elapse
  digitalWrite(12, HIGH);
  time2 = micros(); ///Calculate number of microseconds elapse
  digitalWrite(11, HIGH);
  time3 = micros(); ///Calculate number of microseconds elapse
  Serial.println("Time1 : ");
  Serial.println(time1);
  Serial.println("Time2 : ");
  Serial.println(time2);
  Serial.println("Time3 : ");
  Serial.println(time3);
  
  delay(1000); // Wait for 1000 millisecond(s)
  
  digitalWrite(13, LOW);
  digitalWrite(12, LOW);
  digitalWrite(11, LOW);
  
  delay(1000);


  
}


Output on Console:



As we can observe First LED turns on at 188 uSec, while Second LED Turns on at 212 uSec, and the third LED turns on at 236 uSec. Hence from this, we can conclude that only a Single LED turns on at a time which is why we termed Arduino as having a Sequential nature.

The time difference between the lightning of each LED is only 24 uSec which is far beyond what eyes can actually see hence it appear all LEDs are ON at a time.

Give a try with the above code. You will understand more about this.