Go Down

Topic: Bluetooth Communication Code Problem.  (Read 229 times) previous topic - next topic

TheKeywing

Hello,
In the below we are trying to use a force sensing resistor(FSR) to measure jump height, but it give me an error.

Code: [Select]


 #include <SoftwareSerial.h>
SoftwareSerial BTserial(10, 11);

int pressurePin = A0;
int force;
int LEDpin = 2;
long previousMillis = 0;            // variable to store last time LED was updated
long startTime ;                    // start time for stop watch
long lastTime;
float flight;
long elapsedTime ;                  // elapsed time for stop watch
int fractional;                     // variable used to store fractional part of time
int lastforce;                      // variable to store last button state

void setup() {
BTserial.begin(9600);
Serial.begin(9600);
pinMode(pressurePin, INPUT);
pinMode(LEDpin, OUTPUT);
}

void loop() {

force = analogRead(pressurePin);
if(force > 10)
{
  digitalWrite(LEDpin, HIGH);
  startTime = millis();                                   // store the start time
  delay(5);                                               // short delay to debounce switch
  lastforce = force;                                      //
  BTserial.print( (int)(startTime/1000L));
  lastTime = startTime;
}

else if (force > 10 && elapsedTime > lastTime && lastTime != 0)
{
  elapsedTime =   millis() - startTime;              // store elapsed time
  BTserial.print( (int)(elapsedTime/1000L));
  flight = (((elapsedTime / 2)(9.8))/2)(elapsedTime/2));    // i
  Serial.print((float)flight);
  }

delay(500);
}


Thank You

ieee488


Go Up