Things used in this project

Hardware components:
Img 9622 copy 300x420
O Watch Base Kit
×1
Software apps and online services:
Ide web
Arduino IDE

Code

Leibniz Pi on O WatchArduino
/*
 * This is a simple program that uses the 
 * Leibniz algorithm to calculate the value of Pi
 * http://en.wikipedia.org/wiki/Leibniz_formula_for_
 * 
 * This is writted for the O Watch http://theowatch.com
 * by O Watch on 14 Mar 2016
 * 
 */


#include <TinyScreen.h>; //Add TinyScreen Libraries

TinyScreen display = TinyScreen(TinyScreenPlus); //Create the TinyScreen object
 
// Initialize the variables
float Pi=0;
float  n=1.0;
unsigned long i=0L;
 
void setup(void)
{
  display.begin();
  display.setFlip(1);
  display.setFont(liberationSansNarrow_12ptFontInfo);
  display.setCursor(5,1);
  display.setCursor(5,2);
  display.print("Happy Pi Day");
  display.setCursor(15,20);
  display.print("Leibniz Pi");  
  display.setFont(liberationSansNarrow_8ptFontInfo);

}
 
void loop()
{
 // the recurring calculations of Leibniz formula
 Pi=Pi+(4.0/n);
 n=n+2.0; // Increment the denominator by 2
 Pi=Pi-(4.0/n);
 n=n+2.0;
 
 // Print the values
 display.setCursor(1,40);
 display.print("Pi=");
 display.print(Pi,14);
 display.setCursor(5,1);
 display.setCursor(22,55);
 display.print("Count=");
 display.print(i);
 i=i+1; // Increment the counter
 delay(50);
}

Credits

Owatchlogofebsmall
O Watch
9 projects • 13 followers
Make your own smartwatch. Learn 3D design and Arduino coding.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog