#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
int pot = A0 ;
int pot_value ;
int button = 2 ;
int button_state ;
int button_switcher ;
String skin_type ;
String real_skin_type ;
String skin_feature ;
String real_skin_feature ;
String product_code ;
String real_product_code ;
String suitable_care ;
long message ;
int result ;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(3, 0);
lcd.print("Hello, world!");
Serial.begin(9600);
pinMode ( button , INPUT_PULLUP ) ;
}
void loop() {
/*if (Serial1.available() > 0 ){
message = Serial1.read () ;
Serial.println( message ) ;
}*/
button_state = digitalRead( button ) ;
pot_value = analogRead( pot ) ;
if ( button_state == LOW) {
button_switcher += 1 ;
delay (250);
//Serial.print( button_switcher ) ;
}
if ( button_switcher == 1 ) {
Serial.println( "Inter Your Skin Type : " ) ;
lcd.setCursor(0, 0);
lcd.print("Inter Your Skin Type : ");
if ( pot_value > 255 && pot_value < 512 ) {
skin_type = "Oily" ;
Serial.print( "skin type : " ) ;
Serial.println( skin_type ) ;
}
else if ( pot_value > 512 && pot_value < 767 ) {
skin_type = "Comination" ;
Serial.print( "skin type : " ) ;
Serial.println( skin_type ) ;
}
else if ( pot_value > 767 && pot_value < 1023 ) {
skin_type = "Normal" ;
Serial.print( "skin type : " ) ;
Serial.println( skin_type ) ;
}
delay(750);
}
else if ( button_switcher == 2 ) {
Serial.println( "Inter Your Skin feature : " ) ;
real_skin_type = skin_type ;
if ( pot_value > 200 && pot_value < 400 ) {
skin_feature = "Acne" ;
Serial.print( "skin feature : " ) ;
Serial.println( skin_feature ) ;
}
else if ( pot_value > 400 && pot_value < 600 ) {
skin_feature = "Dark Spots" ;
Serial.print( "skin feature : " ) ;
Serial.println( skin_feature ) ;
}
else if ( pot_value > 600 && pot_value < 800 ) {
skin_feature = "Senstive" ;
Serial.print( "skin feature : " ) ;
Serial.println( skin_feature ) ;
}
else if ( pot_value > 800 && pot_value < 1000 ) {
skin_feature = "Dryness" ;
Serial.print( "skin feature : " ) ;
Serial.println( skin_feature ) ;
}
delay(750);
}
else if ( button_switcher == 3 ) {
Serial.println( "Scan Your Product : " ) ;
real_skin_type = skin_type ;
real_skin_feature = skin_feature ;
if ( pot_value > 200 && pot_value < 400 ) {
product_code = "product 1" ;
Serial.print( "Product code : " ) ;
Serial.println( product_code ) ;
}
else if ( pot_value > 400 && pot_value < 600 ) {
skin_feature = "product 2" ;
Serial.print( "Product code : " ) ;
Serial.println( product_code ) ;
}
else if ( pot_value > 600 && pot_value < 800 ) {
skin_feature = "product 3" ;
Serial.print( "Product code : " ) ;
Serial.println( product_code ) ;
}
else if ( pot_value > 800 && pot_value < 1000 ) {
skin_feature = "product 4" ;
Serial.print( "Product code : " ) ;
Serial.println( product_code ) ;
}
delay(750);
}
else if (button_switcher == 4 ) {
real_skin_type = skin_type ;
real_skin_feature = skin_feature ;
real_product_code = product_code ;
choose () ;
}
else if ( button_switcher == 5 ) {
Serial.print( "skin type : " ) ;
Serial.println( skin_type ) ;
Serial.print( "skin feature : " ) ;
Serial.println( skin_feature ) ;
delay(250);
button_switcher = 0 ;
real_skin_feature = skin_feature ;
delay(250);
}
if ( real_skin_type == "Oily" && real_skin_feature == "Acne" ) {
suitable_care = "AA" ;
}
else if ( real_skin_type == "Oily" && real_skin_feature == "Dark Spots" ) {
suitable_care = "AB" ;
}
else if ( real_skin_type == "Oily" && real_skin_feature == "Senstive" ) {
suitable_care = "AC" ;
}
else if ( real_skin_type == "Oily" && real_skin_feature == "Dryness" ) {
suitable_care = "AD" ;
}
else if ( real_skin_type == "Combination" && real_skin_feature == "Acne" ) {
suitable_care = "BA" ;
}
else if ( real_skin_type == "Comination" && real_skin_feature == "Dark Spots" ) {
suitable_care = "BB" ;
}
else if ( real_skin_type == "Comination" && real_skin_feature == "Senstive" ) {
suitable_care = "BC" ;
}
else if ( real_skin_type == "Combination" && real_skin_feature == "Dryness" ) {
suitable_care = "BD" ;
}
else if ( real_skin_type == "Normal" && real_skin_feature == "Acne" ) {
suitable_care = "CA" ;
}
else if ( real_skin_type == "Normal" && real_skin_feature == "Dark Spots" ) {
suitable_care = "CB" ;
}
else if ( real_skin_type == "Normal" && real_skin_feature == "Senstive" ) {
suitable_care = "CC" ;
}
else if ( real_skin_type == "Normal" && real_skin_feature == "Dryness" ) {
suitable_care = "CD" ;
}
}
void choose () {
if ( suitable_care == "AA" && real_product_code == "product 1" ) {
result = 1 ;
}
if ( suitable_care == "AB" && real_product_code == "product 1" ) {
result = 0 ;
}
if ( result == 1 ) {
Serial.print( "Your choosen Product is : " ) ;
Serial.println( "Suitable" ) ;
}
else if ( result == 0 ) {
Serial.print( "Your choosen Product is : " ) ;
Serial.println( "Unsuitable" ) ;
}
}