For the screen and the touch sensor:
#include <Wire.h>
#include <LiquidCrystal.h>
const int rs = 15;
const int en = 13;
const int d4 = 32;
const int d5 = 33;
const int d6 = 25;
const int d7 = 26;
const int touchPin = 17;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(8, 2);
pinMode(touchPin, INPUT);
Serial.begin(115200);
lcd.clear();
}
void loop() {
if (digitalRead(touchPin) == HIGH) {
Serial.println("touch detected");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(getRandomMessage());
lcd.setCursor(0, 1);
lcd.print("UwU");
delay(3,000);
lcd.clear();
}
}
bool screenOn = false;
String getRandomMessage() {
String messages[] = {
"Go ahead",
"fuck it.",
"WTF?!",
"OOPS",
"Possibly",
"Fate.",
"Nauwr",
"Shut up",
"RIP",
"Nope"
};
int index = random(10);
return messages[index];
}
For the LEDs:
const int redPin = 13;
const int bluePin = 12;
const int greenPin = 15;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(greenPin, OUTPUT);
digitalWrite(redPin, LOW);
digitalWrite(bluePin, LOW);
digitalWrite(greenPin, LOW);
Serial.begin(115200);
}
void loop() {
sequentialLEDs();
}
void sequentialLEDs() {
// Red LED on
digitalWrite(redPin, HIGH);
delay(500);
digitalWrite(redPin, LOW);
// Blue LED on
digitalWrite(bluePin, HIGH);
delay(500);
digitalWrite(bluePin, LOW);
// Green LED on
digitalWrite(greenPin, HIGH);
delay(500);
digitalWrite(greenPin, LOW);
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.