How to write a C Program to Ardunio LCD Display: Create a crystal ball to tell you the future C Programming Language ?
Solution:
//Create a crystal ball to tell you the future! #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); const int switchPin = 6; int switchState = 0; int prevSwitchState = 0; int reply; void setup(){ lcd.begin(16, 2); pinMode(switchPin, INPUT); lcd.print("Ask the"); lcd.setCursor(0,1); lcd.print("Crystal Ball!"); } void loop(){ switchState = digitalRead(switchPin); if(switchState!= prevSwitchState){ if(switchState == LOW){ reply = random(8); lcd.clear(); lcd.setCursor(0, 0); lcd.print("The ball says: "); lcd.setCursor(0, 1); switch(reply){ case 0: lcd.print("YES"); break; case 1: lcd.print("Most likely"); break; case 2: lcd.print("Certainly"); break; case 3: lcd.print("Outlook good"); break; case 4: lcd.print("Unsure"); break; case 5: lcd.print("Ask again"); break; case 6: lcd.print("Doubtful"); break; case 7: lcd.print("NO"); break; } } } prevSwitchState = switchState; }
Learn More :
Future
Ball
Crystal
Create
- How To Write a C program that creates customers' bills for a carpet company when the following is given ?
- C Program to Create VIRUS
- Creates new main.c with empty main boilerplate template
- C Program to create a solution to the Towers of Hanoi game
- C Program to Create a copy of an image
- C Program to Creating pico device
- Add x and y coordinates to create a new struct in C Program
- C program allocates new nodes and creates a four element list with fixed values
- C Program To Create Two Singly Linked List and Perform Following Operation
- Create Two Singly Linked List Perform Differences Display It C Program
- C Program Implement Binary Search Tree And Its Traversals
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
- Calculator Using IF-ELSE in C Program