Arduino Crystal Ball

This is the 11th project in the Arduino Starter Kit. Do note that I have skipped the 9th and 10th projects because my DC motor isn’t working.





Setup



Here’s what we need:





Arduino UNO + BreadboardJumper wiresLCD ScreenPotentiometerTilt Sensor1 x 10 kΩ Resistor1 x 220 Ω Resistor



Layout



Here’s our schematic, as per the Arduino Projects Book.





[image error]



[image error]



And here’s my incredibly messy build:





[image error]



Code



We will be using the LCD Display (Arduino) library to control our screen. While setting up, all we need to do is print out the initial message we want the user to see.





void setup() {
lcd.begin(16, 2);
pinMode(switchPin, INPUT);
lcd.print("Crystal Ball");
lcd.setCursor(0, 1);
lcd.print("At your service");
}



Then, using the random() method, we will give our output.





reply = random(8);
switch(reply) {
case 0:
lcd.print("Yes");
break;
case 1:
lcd.print("Probabale");
break;
case 2:
// ...



That’s all there is to it. You can see the full code here.






The post Arduino Crystal Ball appeared first on Mehul Jangir's blog.

 •  0 comments  •  flag
Share on Twitter
Published on September 08, 2019 03:46
No comments have been added yet.


Mehul Jangir's Blog

Mehul Jangir
Mehul Jangir isn't a Goodreads Author (yet), but they do have a blog, so here are some recent posts imported from their feed.
Follow Mehul Jangir's blog with rss.