Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:25542223771f, committed 2017-09-30
- Comitter:
- Frankqg
- Date:
- Sat Sep 30 21:26:05 2017 +0000
- Parent:
- 0:803792acd19e
- Commit message:
- Comunicaci?n Bluetooth por medio de App Android
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Sep 23 21:37:22 2017 +0000
+++ b/main.cpp Sat Sep 30 21:26:05 2017 +0000
@@ -1,42 +1,31 @@
#include "mbed.h"
#include "SoftSerial.h"
-SoftSerial nucleo (D8,D9);
-Serial pc(SERIAL_TX, SERIAL_RX);
-char sent,rec;
-int i =0;
-int k =0;
-int main()
-{
- char msm[25]= {};
- char led[25]= {};
- char com[3] = {'o','f','f'};
-
- while(1) {
-
- if (pc.readable()>0) {
- sent=pc.getc();
- if(sent == 13) {
- for (int j = 0; j<i; j++) {
- nucleo.printf("%c",msm[j]);
- pc.printf("%c",msm[j]);
- wait(0.01);}
- nucleo.printf("\n\r");
- pc.printf("\n\r");
- i=0;
- } else {
- msm[i]=sent;
- i++;
+Serial pc (USBTX,USBRX);
+SoftSerial bt(D2,D3);
+DigitalOut der(D9);
+DigitalOut izq(D8);
+int estado ;
+int main(){
+ while(1){
+
+ if(bt.readable()>0)
+ {estado = bt.getc();
}
+ if(estado == 1){
+ der = 0;
+ izq = 1;
+ pc.printf("Izquierda; %d\n\r ",estado);
+ }
+ if(estado == 0){
+ izq = 0;
+ der = 1;
+ pc.printf("Derecha;%d\n\r",estado);
}
- if(nucleo.readable()>0) {
- rec=nucleo.getc();
- pc.printf("%c",rec);
- wait(0.01);
- led[k]=rec;
- k++;
-
- }
-
+ if(estado == 2){
+ izq = 0;
+ der = 0;
+ pc.printf("Stop;%d\n\r",estado);
+ }
}
-}
+ }
\ No newline at end of file