Go to Post Wow, that is awfully impressive! How can a guy in the WWF be so smart? Oh, it's LIKE the WWF...:p - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 19-03-2008, 21:49
Aerex Aerex is offline
Registered User
FRC #1369 (Minotaur)
Team Role: Programmer
 
Join Date: Mar 2008
Rookie Year: 2004
Location: Tampa
Posts: 9
Aerex is an unknown quantity at this point
Vex Light Sensor on FRC Bot

We tried to use a vex sensor onto our FRC robot to be used to count revolutions by counting a series of alternating black and white tape on a motor. However there is something wrong with my code.

Code:
#include "Main.h"

void Autonomous ( void )
{
      int c = 1; 
      unsigned char light; 
      int a = 0; 
      int b = 0; 
      int value = 0; 

      while ( value <= 5 ) //the transition of White to Black five times
      {
            SetPWM ( 10 , 190 ) ; //
            SetPWM ( 11 , 190 ) ;
            light = GetAnalogInput ( 1 ) ;
            if ( light >= 0 && light <= 99 ) //interval of white (Bright)
            {
                  a = 1 ;
                  PrintToScreen ( "a: %d\n" , (int)a ) ;
                  PrintToScreen ( "Light: %d\n" , (int)light ) ;
            }
            if ( light > 99 ) //interval of black (Dark)
            {
                  b = 1 ;
            }
            if ( a == 1 && b == 1 )
            {
                  value++ ; //problem starts here
                  a =0 ;
                  b = 0 ;
            }
      }
      SetPWM ( 10 , 127 ) ;
      SetPWM ( 11 , 127 ) ;
}
At the incremental of the variable value the RC begins to count continously up to five at the first instance and then it stops. I want it to only increment the variable value one at a time so that I can see a smooth transition. I started to believe that the vex light sensor is not capable to be used for FRC. Anyone know the problem or should I just use at gear tooth sensor. I appreciate the response.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Light Sensor Filter dasmoenator Programming 2 21-11-2007 23:49
Moving bot once targeted on the light bronxbomber92 Programming 10 30-01-2007 12:33
Vex Light Sensor Robots_R_Us Technical Discussion 2 11-08-2006 18:24
Light Sensor Type, Please Help! Alexander McGee Electrical 7 20-11-2004 21:48
How do light sensor(Banner) work? roberthan Programming 9 25-02-2004 14:05


All times are GMT -5. The time now is 09:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi