first commit
This commit is contained in:
parent
b77ae394b3
commit
13011ab45c
Binary file not shown.
|
|
@ -0,0 +1,51 @@
|
||||||
|
#include <Servo.h>
|
||||||
|
|
||||||
|
Servo serv;
|
||||||
|
|
||||||
|
int pin = A0; //input Velostat pin
|
||||||
|
int pinServo = 9; //servo pin
|
||||||
|
|
||||||
|
float sensorVal;
|
||||||
|
float voltage;
|
||||||
|
float voltageCal;
|
||||||
|
float voltageScale;
|
||||||
|
float angle;
|
||||||
|
float Weight;
|
||||||
|
|
||||||
|
//Calibration
|
||||||
|
float offset = 2.585;
|
||||||
|
float scale = -0.0008;
|
||||||
|
float bias = 11;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
serv.attach(pinServo); //attach servo pin
|
||||||
|
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;
|
||||||
|
|
||||||
|
angle = voltage*54.54;
|
||||||
|
//angle = map(voltage,0,3.3,0,180);
|
||||||
|
//Weight = (voltage-offset)/scale;
|
||||||
|
|
||||||
|
//Serial Printing
|
||||||
|
Serial.print(sensorVal);
|
||||||
|
Serial.print(" , ");
|
||||||
|
Serial.print(voltage);
|
||||||
|
Serial.print(" , ");
|
||||||
|
Serial.print(Weight);
|
||||||
|
Serial.print(" , ");
|
||||||
|
Serial.println(angle);
|
||||||
|
|
||||||
|
|
||||||
|
serv.write(angle);
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
[.ShellClassInfo]
|
||||||
|
IconResource=C:\Program Files\Google\Drive File Stream\74.0.3.0\GoogleDriveFS.exe,23
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
||||||
|
[.ShellClassInfo]
|
||||||
|
IconResource=C:\Program Files\Google\Drive File Stream\74.0.3.0\GoogleDriveFS.exe,23
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
[.ShellClassInfo]
|
||||||
|
IconResource=C:\Program Files\Google\Drive File Stream\74.0.3.0\GoogleDriveFS.exe,23
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
Loading…
Reference in New Issue