Math Proof by LEDs

An elegant LED illustration of a mathematical identity

Step 1: Final Result

Here is the demo. The flashing LEDs are used to illustrate the mathematical identity visually.

Step 2: Math

For every two green dots on the bottom row, there is always a unique red dot in the triangle above that corresponds to them. That red dot is the tip of an equilateral triangle with the base specified by the green dots.

Therefore, the number of ways to choose 2 green dots out of n green dots is equal to the sum of the red dots, 1 +2 + 3 + … + (n-1).

This observation was originally made by Loren C. Larson in the following article : “A Discrete Look at 1+2+…+n.”

Step 3: Electronics

I think it is fun to make something physical to illustrate the math. So, I create this LED illustration.

I solder the LEDs on a board and connect the LEDs to Arduino output pins through 1k resistors.

Step 4: Code

While it is obvious to trace the red dot from the green dots visually, it is more fun and challenging to specify the relationship in code.

Here is the code.

https://gist.github.com/kakittwo/2dbe090583b8192ab...

The key observation is to label the red dots from bottom-up. An illustration of how to index the red dots using the indices of the green dots is shown.

led.ino

int n = 4;
int sum =0 ;
voidsetup() {
for (int i = 0; i < n; i++) {
pinMode(10+ i, OUTPUT);
}
for (int i = 1 ; i <= n-1 ; i++){
sum += i;
}
for (int i = 0; i < sum; i++) {
pinMode(i, OUTPUT);
}
for (int kk =0 ; kk < sum ; kk++){
digitalWrite(kk, LOW);
}
for (int kk =0 ; kk < n ; kk++){
digitalWrite(10 + kk, LOW);
}
}
voidloop() {
for (int i = 0; i < n-1; i++){
for (int j = i + 1 ; j < n; j++){
for (int k = 0 ; k < sum ; k++){
if (k != i + int( 0.5*(j-1-i)*(2*n-j +i) )) {
digitalWrite(k, LOW);
}else{
digitalWrite(k, HIGH);
}
}
for (int kk = 0 ; kk < n ; kk++){
if (kk != i && kk != j) {
digitalWrite(10+kk, LOW);
}else{
digitalWrite(10+kk, HIGH);
}
}
delay(1000);
}
}
delay(1000);
}
view rawled.ino hosted with ❤ by GitHub
Make it Glow Contest 2018

This is an entry in the
Make it Glow Contest 2018

Share

    Recommendations

    • Toys Contest

      Toys Contest
    • First Time Author

      First Time Author
    • Big and Small Contest

      Big and Small Contest

    Discussions