|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#9
|
|||||
|
|||||
|
Re: Getting constant motor power with IR board
Quote:
Take a look at this example instead: http://team358.org/files/programming...or_example.zip It collects the inputs in Process_Data_From_Local_IO() and executes the related commands in Default_Routine(). Here's what the first example is doing... Code:
sensorReading = PORTJ>>4; // Combined digital inputs 15-18 Since we only want the last 4 bits of PORTJ, >>4 is used to shift them 4 bits to the right thereby eliminating the other bits in that byte. So sensorReading now has one of these possible (values)/states for the 4 signal pins from the IR sensor: (0) 0, 0, 0, 0 - no button (1) 0, 0, 0, 1 - button 3 (2) 0, 0, 1, 0 - button 2 (4) 0, 1, 0, 0 - button 4 (8) 1, 0, 0, 0 - button 1 This does depends on which signal pin got which wire from the IR sensor. Code:
if (latch == 1)
{
if (sensorReading == 0)
{
latch = 0; // Take only the 1st reading to avoid being caught by a half & half state of the IR sensor
}
}
Code:
else if (sensorReading != 0)
{
latch = 1;
if (sensorReading == 8) IR_cmd = 1;
else if (sensorReading == 4) IR_cmd = 4;
else if (sensorReading == 2) IR_cmd = 2;
else if (sensorReading == 1) IR_cmd = 3;
printf("IR_cmd = %d\r\n", IR_cmd);
}
Last edited by Mark McLeod : 15-01-2008 at 00:26. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Issues with non working victor constant orange led | dani190 | Control System | 10 | 21-12-2007 22:32 |
| Denso window motor, getting spares | caffel | Motors | 4 | 09-02-2006 11:47 |
| cim motor power question | Zippiot | Motors | 16 | 16-02-2005 20:40 |
| Getting the relays to stay constant | Lord Nerdlinger | Programming | 2 | 19-02-2004 10:17 |
| power of globe motor with gear box? | Ken Leung | Motors | 5 | 21-11-2001 13:43 |