Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* AJ Alves (
#define SENSOR_PIN 2 // Arduino pin that will read the sensor state
void setup() {
Serial.begin(9600); // Setup Serial Port
pinMode(SENSOR_PIN, INPUT); // Set pin as INPUT
void loop() {
int state = digitalRead(SENSOR_PIN);
if (state == HIGH) {
Serial.println("The barrel is FULL");
} else {
Serial.println("No signal from sensor! It is emptying!");
delay(1000); // Wait 1 second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment