//Created by Barbu Vulc!
/*
* This project is based on an Arduino-Ardublock 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);
//'n' is the value multiplied by 2...
long n, m, k;
void setup(){
lcd.begin(16, 2);
//Prints "Multiplication by 2" for 3 seconds!
lcd.setCursor(0, 0);
lcd.print("Multiplication");
lcd.setCursor(0, 1);
lcd.print(" by 2!");
delay(3000);
lcd.clear();
//'n' initialization!
n = 1;
//We need 'm' for 'k' and 'k' for a bit later! ;)
m = 32768; k = (m*m)*-2;
}
void loop(){
//Multiplication begin with '1'.
do{
lcd.setCursor(0, 0);
lcd.print(n);
delay(1000);
//Prints 'Operation done!', 1 second after n = k!
//'k' is a huge number, but is an error!
if(n == k){
lcd.setCursor(1, 1);
lcd.print("Error!");
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Operation done!");
delay(2000);
lcd.clear();
}
}while(n = n * 2);
//Repeat the whole process => Infinite loop! :))
lcd.setCursor(0, 0);
lcd.print(n); n = 1;
}