Skip to content

Instantly share code, notes, and snippets.

@eroeber
Created October 25, 2018 23:40
Show Gist options
  • Save eroeber/8d8a08f8ca4c14cc3b4f069df90a7a4b to your computer and use it in GitHub Desktop.
Save eroeber/8d8a08f8ca4c14cc3b4f069df90a7a4b to your computer and use it in GitHub Desktop.
/*
Here is the code for project 1! We built a to-go coffee cup sleeve that gives the user conversation starters. The messages were prompted by capacitive touch sensors, and printed onto an LCD screen.
I got the original LCD screen 'hello world' code from this url: http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
*/
// include the library code:
#include <LiquidCrystal.h>
#include <CapacitiveSensor.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
//const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int button1 = 0;
int button2 = 1;
int button3 = 0;
int buttonState = 0;
// message arrays
String convos[6] = {"What do you like to do in your free time? ","Are you more of an indoors or outdoors person? ","Favorite movies? ","Where have you traveled? ","What is your favorite food? ","What was the last show you binged? "};
String secondDate[10] = {"Cook something easy together","Go to an amusement park","Get your fortunes told","Find a public swimming pool that’s open at night","Pack a picnic, and go for a hike","Go to drinks with a view","Visit an old-fashioned ice cream parlor","Hit the local farmers market","Make chocolate martinis together","Hit up a jazz club"};
String help[8] = {"You got this!","Hi hot stuff","Don't panic!","Great smile","10 / 10","You're cute","You're like a sharpie - super fine","Drinking hot tea? You hottie"};
// initialize capacitive touch sensors
CapacitiveSensor cs_2 = CapacitiveSensor(5,4);
CapacitiveSensor cs_3 = CapacitiveSensor(3,2);
CapacitiveSensor cs_4 = CapacitiveSensor(6, 13);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
//lcd.print("this is my nightmare");
pinMode(2, INPUT);
Serial.begin(9600);
}
void loop() {
long sensor1 = cs_2.capacitiveSensor(30);
long sensor2 = cs_3.capacitiveSensor(30);
long sensor3 = cs_4.capacitiveSensor(30);
// if the first sensor is pressed, display an ice breaker message
if(sensor1 > 400){
int number1 = random(0,5);
String message1 = convos[number1];
//Serial.println(message1);
lcd.clear();
lcd.print(message1);
delay(1000);
//to move it offscreen left:
for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(250);
}
}
// if the second sensor is pressed, display a second date idea
if(sensor2 > 400){
int number2 = random(0,9);
String message2 = secondDate[number2];
//Serial.println(message2);
lcd.clear();
lcd.print(message2);
delay(1000);
//to move it offscreen left:
for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(250);
}
}
// if the third sensor is pressed, display an encouraging message
if(sensor3 > 400){
int number3 = random(0,7);
String message3 = help[number3];
//Serial.println(message3);
lcd.clear();
lcd.print(message3);
delay(1000);
//to move it offscreen left:
for (int positionCounter = 0; positionCounter < 20; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(250);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment