My project is about game "Truth or Dare". I decided to make it because i want this game to get better, easy and funny. It's very easy to play. this project did not got any switch button only one tilt switch (ball switch). you need just move the box. it's got arrow and spins. it's choose player and give him question.
//Truth or Dare v1.2
//Nozma production
#include <LiquidCrystal.h>
int time = 0;
int b;
long randOn = 0;
long randOff = 0;
float pressLength_milliSeconds = 0;
long x; //Truth
long y; //Dare
const int button = 8;
int relay = 9;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup()
{
randomSeed(1000);
lcd.begin(16, 2);
lcd.print("Truth or Dare");
delay(3000);
lcd.clear();
lcd.print("Nozma Production");
lcd.setCursor(0,2);
lcd.print("presents");
delay(3000);
lcd.clear();
pinMode(button, INPUT_PULLUP);
pinMode(relay, OUTPUT);
Serial.begin(9600);
}
void loop()
{
time++;
lcd.setCursor(0,0);
lcd.print("Truth or Dare");
lcd.setCursor(0,1);
lcd.print("Play time=");
lcd.setCursor(10,1);
lcd.print(time);
delay(1000);
randOn = random(1000, 5000);
randOff = random(100, 500);
digitalWrite(relay, HIGH);
delay(randOn);
digitalWrite(relay, LOW);
delay(randOff);
lcd.setCursor(14,0);
lcd.blink();
while (digitalRead(button) == LOW ){
if (digitalRead(button) == LOW){
delay(100);
pressLength_milliSeconds = 0;
Serial.print("ms = ");
Serial.println(pressLength_milliSeconds);
}
}
while(digitalRead(button) == HIGH){
if (digitalRead(button) == HIGH) {
delay(100);
pressLength_milliSeconds = pressLength_milliSeconds + 100;
Serial.print("ms = ");
Serial.println(pressLength_milliSeconds);
x = random(1, 2);
y = random(1, 21);
}
}
if (pressLength_milliSeconds >= 100 && pressLength_milliSeconds <= 500 ){
while (digitalRead(button) == HIGH ){
delay(100);
}
lcd.clear();
lcd.setCursor(7,1);
lcd.blink();
delay(3000);
lcd.noBlink();
lcd.setCursor(0,0);
truth();
}
if (pressLength_milliSeconds >500 ){
while (digitalRead(button) == HIGH ){
delay(100);
}
lcd.clear();
lcd.setCursor(7,1);
lcd.blink();
delay(3000);
lcd.noBlink();
lcd.setCursor(0,0);
dare();
}
for (int positionCounter = 0; positionCounter < b; positionCounter++)
{
lcd.scrollDisplayLeft();
delay(400);
}
lcd.clear();
while(digitalRead(button) == LOW){
lcd.setCursor(0,0);
lcd.print("continue--?!");
}
if (digitalRead(button) == HIGH){
lcd.clear();
lcd.setCursor(7,1);
lcd.blink();
delay(3000);
lcd.noBlink();
}
pressLength_milliSeconds = 0;
}
//in lcd.print write question and in b write number of words
void truth(){
if(x <=2){
lcd.print("t1");
delay(3000);
b = 4;
}
if(x > 2 && x <=3){
lcd.print("t2");
delay(3000);
b = 4;
}
if(x > 3 && x <=4){
lcd.print(" t3");
delay(3000);
b = 4;
}
if(x > 4 && x <=5){
lcd.print("t4");
delay(3000);
b = 4;
}
if(x >5 && x <=6){
lcd.print("t5");
delay(3000);
b = 4;
}
if(x >6 && x <=7){
lcd.print("t6");
delay(3000);
b = 4;
}
if(x > 7 && x <=8){
lcd.print("t7");
delay(3000);
b = 4;
}
if(x > 8 && x <=9){
lcd.print("t8");
delay(3000);
b = 4;
}
if(x > 9 && x <=10){
lcd.print("t9");
delay(3000);
b = 4;
}
if(x > 10 && x <=11){
lcd.print("t10");
delay(3000);
b = 4;
}
if(x > 11 && x <=12){
lcd.print("t11");
delay(3000);
b = 4;
}
if(x > 12 && x <=13){
lcd.print("t12");
delay(3000);
b = 4;
}
if(x > 13 && x <=14){
lcd.print("t13");
delay(3000);
b = 4;
}
if(x > 14 && x <=15){
lcd.print("t14");
delay(3000);
b = 4;
}
if(x > 15 && x <=16){
lcd.print("t15");
delay(3000);
b = 4;
}
if(x > 16 && x <=17){
lcd.print("t16");
delay(3000);
b = 4;
}
if(x > 17 && x <=18){
lcd.print("t17");
delay(3000);
b = 4;
}
if(x > 18 && x <=19){
lcd.print("t18");
delay(3000);
b = 4;
}
if(x > 19 && x <=20){
lcd.print("t19");
delay(3000);
b = 4;
}
if(x > 20 && x <=21){
lcd.print("t20");
delay(3000);
b = 4;
}
if(x > 21 && x <=22){
lcd.print("t21");
delay(3000);
b = 4;
}
}
void dare(){
if(y <=2){
lcd.print("d1");
delay(3000);
b = 4;
}
if(y > 2 && y <=3){
lcd.print("d2");
delay(3000);
b = 4;
}
if(y > 3 && y <=4){
lcd.print("d3");
delay(3000);
b = 4;
}
if(y > 4 && y <=5){
lcd.print("d4");
delay(3000);
b = 4;
}
if(y > 5 && y <=6){
lcd.print("d5");
delay(3000);
b = 4;
}
if(y > 6 && y <=7){
lcd.print("d6");
delay(3000);
b = 4;
}
if(y > 7 && y <=8){
lcd.print("d7");
delay(3000);
b = 4;
}
if(y > 8 && y <=9){
lcd.print("d8");
delay(3000);
b = 4;
}
if(y > 9 && y <=10){
lcd.print("d9");
delay(3000);
b = 4;
}
if(y > 10 && y <=11){
lcd.print("d10");
delay(3000);
b = 4;
}
if(y > 11 && y <=12){
lcd.print("d11");
delay(3000);
b = 4;
}
if(y > 12 && y <=13){
lcd.print("d12");
delay(3000);
b = 4;
}
if(y > 13 && y <=14){
lcd.print("d13");
delay(3000);
b = 4;
}
if(y > 14 && y <=15){
lcd.print("d14");
delay(3000);
b = 4;
}
if(y > 15 && y <=16){
lcd.print("d15");
delay(3000);
b = 4;
}
if(y > 16 && y <=17){
lcd.print("d16");
delay(3000);
b = 4;
}
if(y > 17 && y <=18){
lcd.print("d17");
delay(3000);
b = 4;
}
if(y > 18 && y <=19){
lcd.print("d18");
delay(3000);
b = 4;
}
if(y > 19 && y <=20){
lcd.print("d19");
delay(3000);
b = 4;
}
}
Comments
Please log in or sign up to comment.