diff --git a/Lab3_Report_LY_MINH.docx b/Lab3_Report_LY_MINH.docx index 34c7501..ba3ae9a 100644 Binary files a/Lab3_Report_LY_MINH.docx and b/Lab3_Report_LY_MINH.docx differ diff --git a/SensorCode/SensorCode.ino b/SensorCode/SensorCode.ino index 8ea7fb1..c91d83c 100644 --- a/SensorCode/SensorCode.ino +++ b/SensorCode/SensorCode.ino @@ -2,48 +2,43 @@ Servo serv; +//Global variable int pin = A0; //input Velostat pin int pinServo = 9; //servo pin float sensorVal; float voltage; -float voltageCal; -float voltageScale; float angle; -float Weight; +float weight; //Calibration -float offset = 2.585; -float scale = -0.0008; -float bias = 11; +//float scale = 54.54; void setup() { Serial.begin(9600); serv.attach(pinServo); //attach servo pin - pinMode(pin,INPUT_PULLUP); + + pinMode(pin,INPUT_PULLUP); digitalWrite(pin, HIGH); } void loop() { sensorVal = analogRead(pin); - voltage = sensorVal * (5.0 / 1023.0); - - //voltageCal = voltage - bias; - //voltageScale = abs(voltageCal / scale); - //voltageScale = (scale*voltageCal)-offset; + voltage = sensorVal * (5.0 / 1023.0); //Convert the sensor value to output voltage - angle = voltage*54.54; - //angle = map(voltage,0,3.3,0,180); - //Weight = (voltage-offset)/scale; + angle = map(voltage, 0, 3.3, 0, 180); + //angle = voltage*scale; //calculating the angular value + + weight = 3.304-voltage/0.436; //calculating weight using calibration curve equation //Serial Printing Serial.print(sensorVal); Serial.print(" , "); Serial.print(voltage); Serial.print(" , "); - Serial.print(Weight); + Serial.print(angle); Serial.print(" , "); - Serial.println(angle); + Serial.println(weight); serv.write(angle); diff --git a/~WRL1986.tmp b/~WRL1986.tmp new file mode 100644 index 0000000..34c7501 Binary files /dev/null and b/~WRL1986.tmp differ