/Magic-8-Ball

Arduino, Raspberry Pi, ESP32, ESP8266 Node MCU projects

Primary LanguageC++

This code is from the examples section in the Arduino IDE

Step 1: Gather Materials and Components Make sure you have all the necessary materials and components:

  • Arduino board (e.g., Arduino Uno)
  • Liquid Crystal Display (LCD)
  • Tilt switch
  • Jumper wires

Step 2: Connect Components Connect the components as follows:

  • Connect the LCD to the Arduino using jumper wires. Connect the LCD's VSS pin to GND, VDD pin to 5V, V0 pin to the middle pin of a 10k potentiometer (for contrast adjustment), RS pin to digital pin 12, RW pin to GND, E pin to digital pin 11, and D4, D5, D6, D7 pins to digital pins 5, 4, 3, 2 respectively.
  • Connect one leg of the tilt switch to digital pin 6 on the Arduino, and the other leg to GND.

Step 3: Install LiquidCrystal Library If you haven't already, install the LiquidCrystal library. In the Arduino IDE, go to Sketch > Include Library > Manage Libraries. Search for "LiquidCrystal" and install the one by Arduino.

Step 4: Upload the Original Code Copy and paste the original code into the Arduino IDE and upload it to your Arduino board. code is available in the .ino file, it is also available in the examples available in the Arduino IDE

Step 5: Test the Crystal Ball Power up your Arduino and tilt the tilt switch to see the crystal ball's responses on the LCD.

Step 6: Personalize the Responses Now, let's personalize the responses. Replace the switch statement in the loop() function with your own custom responses. You can modify the existing responses or add new ones. For example:

switch (reply) {
  case 0:
    lcd.print("Absolutely!");
    break;

  case 1:
    lcd.print("Go for it!");
    break;

  case 2:
    lcd.print("Not a chance");
    break;

  // Add more cases as needed
}

Step 7: Customize the LCD Display You can also personalize the LCD messages in the setup() function. Modify the lines:

lcd.print("Ask the");
lcd.setCursor(0, 1);
lcd.print("Crystal Ball!");

to something more personal or amusing.

Step 8: Upload and Test the Personalized Code Upload the modified code to your Arduino and test the crystal ball again to see your personalized responses.

That's it! You've successfully built and personalized the crystal ball project. Feel free to experiment with additional features or improvements as you see fit.