Skip to content

Instantly share code, notes, and snippets.

@matthiaslindholm
Created January 13, 2013 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiaslindholm/2078d66b28f1c6cd72a8 to your computer and use it in GitHub Desktop.
Save matthiaslindholm/2078d66b28f1c6cd72a8 to your computer and use it in GitHub Desktop.
Arduino-Programm zum Paketzustellungsdetektor
/*
Paketzustellungsdetektor
MobileGeeks DIY
Matthias Lindholm
http://mobilegeeks.de/diy
*/
#define FSR_GRENZWERT 15
#define ONBOARD_LED 13
#define FORCE_SENSOR 0
int force_value = 0;
byte force_state = 0;
void setup() {
Serial.begin(9600);
pinMode(ONBOARD_LED, OUTPUT);
}
void loop() {
delay(1000);
force_value = analogRead(FORCE_SENSOR);
switch (force_state){
case 0:
if (force_value >= FSR_GRENZWERT)
{
force_state = 1;
digitalWrite(ONBOARD_LED, HIGH);
Serial.print("Paket abgelegt");
}
break;
case 1:
if (force_value < FSR_GRENZWERT)
{
force_state = 0;
digitalWrite(ONBOARD_LED, LOW);
Serial.print("Paket aufgenommen");
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment