Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <Wire.h>
#include "SSD1306.h"
int asap = 2;
int sensorThres = 400;
SSD1306 display(0x3c, 21, 22);
void setup() {
Serial.begin(9600);
display.init();
pinMode(asap, INPUT);
}
void loop() {
display.clear();
int analogSensor = analogRead(asap);
Serial.print("Pin 2 : ");
Serial.println(analogSensor);
if (analogSensor > sensorThres)
{
display.drawString(0, 0, "Asap terdeteksi");
}
else
{
display.drawString(0, 0, "Asap tidak terdeteksi");
}
display.display();
delay(200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment