mbed_bot

Dependencies:   mbed

main.cpp

Committer:
jasonberry
Date:
2021-03-22
Revision:
1:dfc4375f3eb5
Parent:
0:d44946656cbe
Child:
2:1fd9d55f66e0

File content as of revision 1:dfc4375f3eb5:

#include "mbed.h"

Serial pc(USBTX, USBRX);
Serial blue(p9, p10);          // TX, RX

DigitalOut myled(LED1);
DigitalOut myled2(LED2);
DigitalOut myled4(LED4);


int main() 
{
char receive_buffer[30];



    blue.baud(9600);
    pc.baud(115200);
    pc.printf("Bluetooth Start\r\n");
    blue.printf("Bluetooth Start\r\n");
    
    // echo back characters and toggle the LED
    while (1) 
    {
        myled2 = !myled2;
        if (blue.readable()) 
        {
            pc.gets(receive_buffer,30); // read all ascii chars (string) into buffer
            
            long int slider = strtol(receive_buffer,NULL,10); // convert string to a long integer
            pc.printf("%ld ",slider);//printf long int slider
            myled = !myled;
                        
            //pc.putc(blue.getc()); 

            
        }
        if (pc.readable()) 
        {
            blue.putc(pc.getc());
            myled4 = !myled4;
        }
        
    }
}