151-0153 Rabbit Semiconductor, 151-0153 Datasheet - Page 83

no-image

151-0153

Manufacturer Part Number
151-0153
Description
ASSEMBLY - RABBITFLEX CABLES
Manufacturer
Rabbit Semiconductor
Series
RabbitFLEX™r
Datasheet

Specifications of 151-0153

Accessory Type
Cable Assembly
For Use With/related Products
BL300F
Lead Free Status / RoHS Status
Vendor undefined / Vendor undefined
Now we will go through each part of the while loop step-by-step.
Note that we are using a costate in this sample. The costate will allow us to more easily delay for imple-
menting switch debouncing. Also note that we set switch_pressed to NULL. Recall that
switch_pressed is of the type Flex_IOPin*. It will be used to point to a switch (or digital input)
that has been engaged. We initialize this to NULL, and will remain in the loop until a switch has been
pressed.
We have already seen that flexDigOut() manipulates digital outputs. Therefore, it is not surprising
that flexDigIn() manipulates digital inputs. In this case, flex_digin31 indicates the digital input
that the program is reading. Always remember that you must pass a pointer to the RabbitFLEX I/O struc-
tures, and not the structure itself.
If flexDigIn() indicates that flex_digin31 has been pressed, then we save off the switch that has
been pressed, the LED that we should turn on, and the number of the switch that has been pressed.
RabbitFLEX User’s Manual
} // end main while loop
while (1) {
} // end costate
costate {
} // end if statement
switch_pressed = NULL;
while (!switch_pressed) {
while (1) {
} // end while loop
if (flexDigIn(&flex_digin31)) {
}
else if (flexDigIn(&flex_digin33)) {
}
// Wait for the switch to be released
waitfor(flexDigIn(switch_pressed) == 0);
// Wait additional 200 ms
waitfor(DelayMs(200));
// If the switch is still released, then break out of the while loop
if (flexDigIn(switch_pressed) == 0) {
} // end if statement
switch_pressed = &flex_digin31;
led = &flex_digout32;
switchnum = 1;
switch_pressed = &flex_digin33;
led = &flex_digout34;
switchnum = 2;
// Turn the LED back off
flexDigOut(led, 1);
break;
www.rabbit.com
77

Related parts for 151-0153