ARDUINO2
ARDUINO2
ARDUINO2
h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
const int relayInductivePin = 4; // Pin for the relay controlled by inductive sensor
const int relayCapacitivePin = 5; // Pin for the relay controlled by capacitive sensor
const int relayUltrasonicPin = 10; // Pin for the relay controlled by ultrasonic sensor
void setup() {
pinMode(inductiveSensorPin, INPUT);
pinMode(capacitiveSensorPin, INPUT);
pinMode(relayInductivePin, OUTPUT);
pinMode(relayCapacitivePin, OUTPUT);
pinMode(relayUltrasonicPin, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
for (;;);
display.display();
if (displayMainScreen) {
displayMain();
} else {
displaySecond();
void loop() {
inductiveCount++;
updateDisplay();
prevInductiveState = inductiveDetected;
capacitiveCount++;
updateDisplay();
prevCapacitiveState = capacitiveDetected;
// Check if the reset button is pressed
if (resetButtonPressed) {
inductiveCount = 0;
capacitiveCount = 0;
updateDisplay();
if (screenSwitchPressed) {
if (displayMainScreen) {
displayMain();
} else {
displaySecond();
long duration;
int distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the echo pin
digitalWrite(relayUltrasonicPin, LOW);
digitalWrite(relayUltrasonicPin, HIGH);
void updateDisplay() {
if (displayMainScreen) {
displayMain();
} else {
displaySecond();
void displayMain() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 10);
display.print("PLASTIC: ");
display.print(inductiveCount);
display.setCursor(0, 50);
display.print("CAN: ");
display.print(capacitiveCount);
display.display();
void displaySecond() {
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.println("THE");
display.setCursor(0, 16);
display.println("THINKERS");
display.setTextSize(1);
display.setCursor(0, 40);
display.println("LUASSKAN AURAMU");
display.display();