Robert Appel
Created July 20, 2017

Honey Supply Detector

This project will detect the supply of honey, and if the supply runs out, it will send an email.

26
Honey Supply Detector

Things used in this project

Hardware components

Omega2 Plus
Onion Corporation Omega2 Plus
×1
Arduino Dock R2
×1
Ethernet Expansion
Onion Corporation Ethernet Expansion
×1
Macro SD card
×1
Male/Male Jumper Wires
×3
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Pushbutton Schematics

Wiring for the pushbutton.

Code

Pushbutton Code on Arduino

Arduino
const int buttonPin = 7;     // the number of the pushbutton pin
const int ledPin =  LED_BUILTIN ;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int inByte = 0;

void setup() {
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}
void myResponse(int myValue)
{
    if (Serial.available() > 0) {
    // read the input
    inByte = Serial.read();
    delay(500); // small delay before responding

    // respond only if correct command is received
    if ((char)inByte == 'r') {
      // respond with analog measurement
      Serial.println(myValue);
    }
    }
}
void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
    myResponse(123);
    
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
    myResponse(345);
  }
    
}

Credits

Robert Appel

Robert Appel

0 projects • 0 followers

Comments