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

Make your own smartwatch. Learn 3D design and Arduino coding.

Replications

Did you replicate this project? Share it!

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

Give feedback

Comments

Similar projects you might like

Word Clock on the O-Watch
Easy
  • 523
  • 9

Protip

We'll build on the Simple RTC Watch to turn our O-Watch into a Mini Word Clock, which uses an 8 x 8 grid of letters to spell out the time.

Animated Word Clock on the O-Watch
Easy
  • 424
  • 6

A modified version of J Koger's Mini Word Clock for O-Watch, now with an animated digital rain effect.

Googly Eye O-Watch
Easy
  • 110
  • 3

Protip

Inspired by Mike Mak's Eye Clock, now the O-Watch can show the time with two googly eyes: hours (left eye) and minutes (right eye).

2048 Sliding Tile Game for the O Watch
Easy
  • 258
  • 5

Full instructions

This is a sliding tile game for the O Watch based on the simple and addicting game 2048 by Gabriele Cirulli.

Getting Started with O Watch
Easy
  • 520
  • 8

Full instructions

Assemble the O Watch, configure the Arduino IDE and load your first program.

Simple Watch Using RTC
Easy
  • 1,077
  • 4

Full instructions

The O-Watch Simple Watch code tweaked to use the Arduino Zero's built-in RTC, plus a couple other tweaks.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback