Last active
January 2, 2016 11:39
-
-
Save allfake/8297899 to your computer and use it in GitHub Desktop.
load cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int minVal = -999; | |
int threshold = 20; | |
int calibrate = 300; | |
int val = 0; | |
void setup() | |
{ | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
int i = 0; | |
if (minVal == -999) { | |
minVal = analogRead(A0); | |
for(i = 0; i < calibrate; i++) { | |
int tempVal = analogRead(A0); | |
minVal = (tempVal + minVal) / 2; | |
} | |
} | |
val = analogRead(A0); | |
Serial.println(val); | |
if (val > minVal - (threshold / 2) && val < minVal + (threshold / 2)) { | |
// minVal = analogRead(A0); | |
// for(i = 0; i < medium; i++) { | |
// int tempVal = analogRead(A0); | |
// minVal = (tempVal + minVal) / 2; | |
// } | |
Serial.println(0); | |
} else { | |
if (val - minVal > 0) { | |
Serial.println(val - minVal); | |
} else { | |
Serial.println(0); | |
} | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment