Дек 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

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*