|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
R2D2 Programming
I have a problem with some coding.
I need to add Remote functions to my coding to override my Ultras and being a NEWBIE, I can't get it right. I'm using Vex 2.0 and heres what I have so far: #include "Main.h" void main ( void ) { int Loop = 1; int UltraLeft; int BumperLeft; int BumperFront; int UltraRight; int BumperRight; int UltraFront; // Ultras will be mounted in the Legs (1 Left/1 Right) // Remote must Override Ultras/Bumper Switches // Inside Dome are 3- Bumpers (Front-Left-Right) while ( Loop == 1 ) // When Power is Turned on, This will set Dome to Home Position { BumperFront = GetDigitalInput ( 11 ) ; SetMotor ( 1 , 255 ) ; if ( BumperFront == 0 ) { SetMotor ( 1 , 127 ) ; break ; // At this Point, It will leave this area of Code until Total Vex Restart } } Wait ( 4000 ) ; // Sits in Home Position before Activating Ultras while ( Loop == 1 ) { BumperFront = GetDigitalInput ( 11 ) ; // Home Position Bumper Switch (Dome facing Foward) if ( BumperFront == 0 ) { SetMotor ( 1 , 127 ) ; // Had to add a Stop here for the return of the dome to stop StartUltrasonic ( 1 , 6 ) ; // Left Ultra for dome Rotation (Left) UltraLeft = GetUltrasonic ( 1 , 6 ) ; // Detects if someone is near Leftside StartUltrasonic ( 2 , 7 ) ; // Right Ultra for Dome movement UltraRight = GetUltrasonic ( 2 , 7 ) ; // Detects if Someone is near the Rightside if ( UltraLeft < 35 ) { SetMotor ( 1 , 255 ) ; // Turns Dome to the Left } if ( UltraRight < 35 ) { SetMotor ( 1 , 0 ) ; } } BumperLeft = GetDigitalInput ( 10 ) ; // Left Bumper Stop Switch if ( BumperLeft == 0 ) { SetMotor ( 1 , 127 ) ; Wait ( 3000 ) ; // Dome will pause then Return to Home Position SetMotor ( 1 , 0 ) ; } BumperRight = GetDigitalInput ( 12 ) ; if ( BumperRight == 0 ) { SetMotor ( 1 , 127 ) ; Wait ( 3000 ) ; // Same as above SetMotor ( 1 , 255 ) ; } // Perfect up to here, But the Ultras are not pausing } } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| programming motors with programming kit | BorisTheBlade | FIRST Tech Challenge | 4 | 01-11-2005 19:03 |
| Programming | newgrl101 | Programming | 3 | 05-02-2005 13:05 |
| Programming | randomperson | FIRST-related Organizations | 24 | 08-06-2003 19:13 |
| Programming | Gusman1188 | Programming | 5 | 17-02-2003 11:23 |
| Programming | archiver | 2001 | 10 | 23-06-2002 23:01 |