![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
transmitter
Diff: transmit.cpp
- Revision:
- 0:ac2d5fad3f21
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/transmit.cpp Mon May 18 13:41:04 2015 +0000 @@ -0,0 +1,48 @@ +//Caes Jonathan & Bram Van Reusel +//Wireless +//Library's declareren +#include "mbed.h" + +//seriële poorten declareren +Serial pc(USBTX,USBRX); +Serial uart(p9, p10); //tx, rx + +//Pinaansluiting declareren +DigitalOut myled1(LED1); +DigitalOut PDN(p26); +AnalogIn LDR(p20); + +//variabelen om sensoren in te lezen +float ldr = 0; + +//variabelen om te sturen +int sturen; +char adres; +char data; +char crc; + +//main programma +int main() +{ + //instellingen voor de zender + PDN = 1; + uart.baud(1200); //snelheid van communiceren + //instelling voor communicatie met pc + pc.baud(9600); + + //begin programma + while(1) + { + adres = 74; + ldr = LDR; + data = ldr * 255; + crc = (adres xor data); + + myled1 = 1; + uart.printf("%c%c%c", adres, data, crc); + pc.printf("adres: %c\n", adres); + pc.printf("data: %c\n", data); + pc.printf("crc: %c\n", crc); + myled1 = 0; + } +}