Дек 082012
 

Код для mbed NXP LPC11U24

WIKI: OR-BWSENSE

DigitalInOut QTRA(p6); //connected to digital P6
DigitalInOut QTRB(p5); //connected to digital P5

DigitalOut led1(LED1);
DigitalOut led4(LED4);

Timer t;

Serial pc(USBTX, USBRX); // tx, rx

int bw=0,aw=0,k;

int main()
{

while(1) {

QTRA.output();
QTRA.mode(PullUp);
wait_us(2500);
QTRA.mode(PullNone);
QTRA = 1;
t.start();
QTRA.input();
while (QTRA == 1 || t.read_us() < 3000);
bw = t.read_us();
t.stop();
t.reset();

QTRB.output();
QTRB.mode(PullUp);
wait_us(2500);
QTRB.mode(PullNone);
QTRB = 1;
t.start();
QTRB.input();
while (QTRB == 1 || t.read_us() < 3000); aw = t.read_us(); t.stop(); t.reset(); // pc.printf("%d %d\n",bw,aw); if (bw > 3100) { led1 = 1; } else { led1=0; } // Black
if (aw > 3100) { led4 = 1; } else { led4=0; } // Black

}
}
 Posted by at 12:33
Сен 032012
 

Documents:

Sparkfun electronics

Pinout configuration for the 1.x and 2.x OpenServo connector.

 

 Posted by at 13:15