|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Re: heres the code. y this not working
ya uh we need more help then that
thz anymore |
|
#17
|
|||
|
|||
|
Re: heres the code. y this not working
/* Add your own autonomous code here. */
Navigate(); if(rc_dig_in01 ==1 ) { pwm13 = 137; pwm14=100; } else { pwm13 = pwm14 = 140; } if(rc_dig_in02 == 1) { pwm13 = 100; pwm14 = 137; } else { pwm13 = pwm14 = 140; } This code will ignore the rc_dig_in01 as the if(rc_dig_in02 == 1) overwrites the values. You need to create 4 states for this or at least determine what you want to happen for each of the 4 states that can happen with two digital inputs: rc_dig_in01 == 0, rc_dig_in02 == 0 rc_dig_in01 == 0, rc_dig_in02 == 1 rc_dig_in01 == 1, rc_dig_in02 == 0 rc_dig_in01 == 1, rc_dig_in02 == 1 I assume here that these are the inputs from a light sensor that indicates which light is seeing the tape, depending on how far away each sensor is it may not be possible to get both on at the same time. Then you are down to only 3 states. For simplicity lets define Left == (rc_dig_in01 == 1); Right == (rc_dig_in02 ==1); Now: if (Left) { turn right } else if (right) { turn left } else { go straight } if both left and right can be on at the same time then check for that first if (Left && Right) { } else if (Left) { } else if (Right) { } else { } Hope this helps, Dave SBotz |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is your most prefered programming language? | Hailfire | Programming | 156 | 19-01-2005 21:42 |
| Speed limiting code from last year in C? | Josh Siegel | Programming | 6 | 01-04-2004 22:27 |
| Interrupt timer, executing code asap? | SeanCassidy | Programming | 10 | 07-03-2004 01:47 |
| Inserting Naviagation code into Default code? | actorindp | Programming | 3 | 28-01-2004 18:12 |
| Does your team use the Default code. | Jeff McCune | General Forum | 2 | 09-01-2003 14:46 |