|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Selecting bits from an analog input
Hey everyone, we are going to be using the USB chicklet and for buttons 5-8 it uses 4 bits from the AUX port on the joystick but I can't figure out how to select the bits from the actual output. Is there a simple way to do this or will I just have to do some math and figure out which output is being pressed by removing 128, 64, 32 and 16 from the output? Thanks in advance!
|
|
#2
|
||||
|
||||
|
Re: Selecting bits from an analog input
Quote:
Code:
void Buttons(void)
{
p1_sw_5=p1_sw_6=p1_sw_7=p1_sw_8=1;
p1_sw_5=(p1_aux&1<<7)?0:1;
p1_sw_6=(p1_aux&1<<6)?0:1;
p1_sw_7=(p1_aux&1<<5)?0:1;
p1_sw_8=(p1_aux&1<<4)?0:1;
}
(I wrote this to demonstrate the ?: operator to some students, you can also invert the logic test instead). |
|
#3
|
||||
|
||||
|
Re: Selecting bits from an analog input
Thanks so much!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Analog Input Errors... | Tach'ko | Electrical | 1 | 11-01-2008 11:37 |
| HELP: analog input | Tottanka | Programming | 19 | 18-02-2007 19:27 |
| Programming Analog Input from 2004 Controller | Danny Diaz | Programming | 8 | 30-01-2007 22:44 |
| Analog Input Trouble | Matt Krass | Programming | 10 | 20-01-2005 21:09 |
| DC Motor current to an Analog Input | junkyarddawg | Motors | 43 | 04-04-2002 15:53 |