#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <string.h>
//defining the Pins
#define LeftButton 10
#define RightButton 8
#define EnterButton 9
#define RGB_R 5
#define RGB_G 6
#define RGB_B 7
//defining the variables for necesary calculation
int timemovedRight = 0;
int timemovedLeft = 0;
int RightButVal;
int LeftButVal;
int EnterButVal;
int Previousmove ;
LiquidCrystal_I2C lcd(0x27,16,2);
//Making a sub program because of an error in my LCD Library Remove this if you want to
void lcdPrintln1(char *str)
{
int i = 0;
for(i=0;i<16;i++)
{
lcd.setCursor(i,0);
lcd.print(str[i]);
}
}
//Making a sub program because of an error in my LCD Library Remove this if you want to
void lcdPrintln2(char *str)
{
int i = 0;
for(i=0;i<16;i++)
{
lcd.setCursor(i,1);
lcd.print(str[i]);
}
}
//Making a custom arrow poiner charachter
byte ArrowMark[8] = {
0b00000,
0b01100,
0b01110,
0b01111,
0b01111,
0b01110,
0b01100,
0b00000
};
//Making a custom charachter to turn off all the respective LEDS at a ceratin point
byte Deletion[8] ={
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000
};
void setup()
{
Serial.begin(9600);
lcd.init(); // initialize the lcd
lcd.createChar(0,ArrowMark); //Defining the Char
lcd.createChar(1,Deletion);
lcd.backlight();
lcdPrintln1("Like This Video?");//Make this into 'lcd.print("Like This Video?");' if you want to
lcdPrintln2(" Yes No ");//Make this into 'lcd.print(" Yes No ");' if you want to
lcd.home();
lcd.setCursor(1,1);
lcd.write(0);
}
//Making a Sub program for my RGB
void RGBCol(int R,int G,int B){
analogWrite(RGB_R,R);
analogWrite(RGB_G,G);
analogWrite(RGB_B,B);
}
//all of the calculations happens below
void loop()
{
RightButVal = digitalRead(RightButton);
LeftButVal = digitalRead(LeftButton);
EnterButVal = digitalRead(EnterButton);
if(RightButVal == 0 && Previousmove != 1){
lcd.home();
lcd.setCursor(1,1);
lcd. write(1);
lcd.setCursor(10,1);
lcd.write(0);
timemovedRight +=1;
Previousmove = 1;
}
if(LeftButVal == 0 && Previousmove != 0){
lcd.home();
lcd.setCursor(10,1);
lcd. write(1);
lcd.setCursor(1,1);
lcd.write(0);
timemovedLeft +=1;
Previousmove = 0;
}
if(EnterButVal == 0){
if(timemovedRight - timemovedLeft == 0){
Serial.println("Yes");
RGBCol(0,100,0);
}
else{
Serial.println("No");
RGBCol(100,0,0);
}
}
}
Comments