View Single Post
  #2   Spotlight this post!  
Unread 22-11-2015, 15:45
dubiousSwain's Avatar
dubiousSwain dubiousSwain is offline
The ride never ends
AKA: Christian Steward
FRC #5420 (Velocity)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2011
Location: USA
Posts: 304
dubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond reputedubiousSwain has a reputation beyond repute
Re: Timing an LDR in C++

Hmm...
I don't know much about C++, but I would start by triggering a timer function when the sensor reads black, then when the sensor reads white, write the timer function's time to a variable then use that in an elif statement (excuse my python)

something like:
Code:
void main() {
      if (sensor<black){
            startTimer();
      }
      if (sensor == white && timerStarted == true){
                if (timerValue<12600){
                        doSomething();
                }
                if (timerValue>12600){
                         doSomethingElse();
                }
         }
 }
PM me if you need anything else
__________________
2015 MAR District Champions