esp and pc

Dependencies:   mbed

Committer:
asha_ndf
Date:
Tue Dec 07 09:24:37 2021 +0000
Revision:
1:1a5cc6ebc608
Parent:
0:7634421e8e46
20211207;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
asha_ndf 0:7634421e8e46 1 #include "mbed.h"
asha_ndf 0:7634421e8e46 2
asha_ndf 0:7634421e8e46 3
asha_ndf 1:1a5cc6ebc608 4 Serial pc(USBTX, USBRX); // tx,rx
asha_ndf 1:1a5cc6ebc608 5 Serial esp(D1, D0);
asha_ndf 0:7634421e8e46 6
asha_ndf 0:7634421e8e46 7 int main()
asha_ndf 0:7634421e8e46 8 {
asha_ndf 1:1a5cc6ebc608 9 pc.baud(19200);
asha_ndf 0:7634421e8e46 10 pc.printf("\nConnected to PC\n");
asha_ndf 0:7634421e8e46 11 while(1) {
asha_ndf 0:7634421e8e46 12 if (esp.readable()){
asha_ndf 0:7634421e8e46 13 pc.printf("%c",esp.getc());
asha_ndf 0:7634421e8e46 14 }
asha_ndf 0:7634421e8e46 15 if (pc.readable()){
asha_ndf 0:7634421e8e46 16 esp.printf("c",pc.getc());
asha_ndf 0:7634421e8e46 17 }
asha_ndf 0:7634421e8e46 18 }
asha_ndf 0:7634421e8e46 19 }