Final Project 4180

Dependencies:   mbed

Fork of IR_demo by jim hamblen

Committer:
sarvagyavaish
Date:
Wed Nov 13 17:28:04 2013 +0000
Revision:
3:9a9b4025a38b
Parent:
2:a03faf6130cb
Child:
4:831f9780f38b
what??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:e0bef6b1aa57 1 #include "mbed.h"
4180_1 0:e0bef6b1aa57 2
4180_1 0:e0bef6b1aa57 3 Serial pc(USBTX, USBRX); // tx, rx
4180_1 0:e0bef6b1aa57 4 Serial device(p13, p14); // tx, rx
4180_1 0:e0bef6b1aa57 5 DigitalOut myled1(LED1);
4180_1 0:e0bef6b1aa57 6 DigitalOut myled2(LED2);
4180_1 0:e0bef6b1aa57 7 PwmOut IRLED(p21);
4180_1 0:e0bef6b1aa57 8 //IR send and receive demo
4180_1 0:e0bef6b1aa57 9 //LED1 and LED2 indicate TX/RX activity
4180_1 0:e0bef6b1aa57 10 //Character typed in PC terminal application sent out and returned back using IR transmitter and receiver
4180_1 0:e0bef6b1aa57 11
4180_1 0:e0bef6b1aa57 12 int main() {
4180_1 0:e0bef6b1aa57 13 //IR Transmit code
4180_1 0:e0bef6b1aa57 14 IRLED.period(1.0/38000.0);
4180_1 0:e0bef6b1aa57 15 IRLED = 0.5;
4180_1 0:e0bef6b1aa57 16 //Drive IR LED data pin with 38Khz PWM Carrier
4180_1 0:e0bef6b1aa57 17 //Drive IR LED gnd pin with serial TX
4180_1 0:e0bef6b1aa57 18 device.baud(2400);
4180_1 0:e0bef6b1aa57 19 while(1) {
4180_1 0:e0bef6b1aa57 20 if(pc.readable()) {
4180_1 0:e0bef6b1aa57 21 myled1 = 1;
4180_1 0:e0bef6b1aa57 22 device.putc(pc.getc());
4180_1 0:e0bef6b1aa57 23 myled1 = 0;
4180_1 0:e0bef6b1aa57 24 }
4180_1 0:e0bef6b1aa57 25 //IR Receive code
4180_1 0:e0bef6b1aa57 26 if(device.readable()) {
4180_1 0:e0bef6b1aa57 27 myled2 = 1;
4180_1 0:e0bef6b1aa57 28 pc.putc(device.getc());
sarvagyavaish 1:e135358e96ed 29 myled2 = 0;
4180_1 0:e0bef6b1aa57 30 }
4180_1 0:e0bef6b1aa57 31 }
4180_1 0:e0bef6b1aa57 32 }
sammacjunkie 2:a03faf6130cb 33
sammacjunkie 2:a03faf6130cb 34
sarvagyavaish 3:9a9b4025a38b 35 // sam was here
sarvagyavaish 3:9a9b4025a38b 36 // survy was here too