//Created by Barbu Vulc!
/*
* This project is based on an Ardublock (Arduino IDE) sketch
* for Sparkfun Digital Sandbox board called 'Serial Calculator'!
*/
//LCD library...
#include <LiquidCrystal.h>
//LCD set on digital pins from 7 to 12!
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
//'x' is the value divided by 2...
long x, m;
void setup(){
lcd.begin(16, 2);
//Prints "Division by 2" for 3 seconds!
lcd.setCursor(0, 0);
lcd.print("Division by 2!");
delay(3000);
lcd.clear();
//'x' initialization!
x = 32768;
//m = 32768^2
m = x*x;
}
void loop(){
//Division begin with 'm'! :))
do{
lcd.setCursor(0, 0);
lcd.print(m);
delay(1000);
lcd.clear();
}while(m = m >> 1); //The equivalent of 'x=x/2'!
//Prints 'Operation done!' at the end of calculation.
lcd.setCursor(0, 1);
lcd.print("Operation done!");
//Repeat the process => Infinite loop! :))
lcd.setCursor(0, 0);
lcd.print(m);
delay(2000);
lcd.clear();
m = x*x;
}