Monil Chheta
/
speech
to grant access
Diff: main.cpp
- Revision:
- 0:af6c8778c6ed
diff -r 000000000000 -r af6c8778c6ed main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Dec 07 19:40:06 2017 +0000 @@ -0,0 +1,50 @@ +#include "mbed.h" +#include <stdio.h> +#include <string.h> +DigitalOut red(LED1); +DigitalOut blue(LED3); +Serial pc(USBTX, USBRX); +Serial device(PTC15, PTC14); +unsigned char recivedchar[255]; +int i=0; + +int main() +{ + red=1; + blue=1; + unsigned char rx; + int sum=0; + device.baud(9600); + while(1) + { + if(device.readable()) + { + for(i=0;i<255;i++) + { + rx = device.getc(); + recivedchar[i] =rx; + sum=sum+rx; + pc.printf("%c",rx); + + + break; + } + pc.printf("%d",sum); + } + if(sum==73 || sum==110 || sum==97) + { + red=1; + blue=0; + pc.printf("Access Granted!"); + + } + else + { + red=0; + blue=1; + + } + sum=0; + } + + } \ No newline at end of file