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.
main.cpp
- Committer:
- allansolvertecnologi
- Date:
- 2020-04-02
- Revision:
- 107:1f8f680bc11a
- Parent:
- 105:ed03c03b353e
File content as of revision 107:1f8f680bc11a:
#include "mbed.h"
#include "platform/mbed_thread.h"
// Configurando LEDs
DigitalOut ledGreen(D12);
DigitalOut ledRed(D11);
DigitalOut Dout(D1);
//Configurações SPI
Serial xbee(D1, D0, 9600); //Pinos seriais (Tx/Rx)
DigitalOut rst1(D6); //Digital reset
char a = 'A';
void xbee_send(int send) //envia byte
{
Dout = 0;
xbee.putc(send);
Dout = 1;
}
int xbee_receive() //Retorna byte lido ou 0 se não tiver leitura pronta
{
if(xbee.readable()){
int a = xbee.getc();
}
else
a= 0;
return a; //XBee read
}
int main()
{
rst1 = 0; //Set reset pin to 0
Dout = 0;
ledGreen = 0;
ledRed = 0;
wait_ms(1);
rst1 = 1; //Set reset pin to 1
wait_ms(1); // Configura como UART com 9600 de baud rate
while (1)
{
xbee_send('+');
xbee_send('+');
xbee_send('+');
//xbee_send('R');
ledRed = !ledRed;
while(!xbee.readable());
if(xbee.getc() == 'O')
{
if(xbee.getc() == 'K')
ledGreen = !ledGreen;
}
wait_ms(2000);
}
}