Olá pessoal!
Eu comprei esse modulo aqui na loja do lab e estou com uma dificuldade...
Eu baixei a biblioteca do modulo no site do fabricante (NewSoftSerial)
Porém quando eu faço o include dela no meu projeto para mandar e receber dados pelo bluetooth ele da esses erros de complilação:
C:\arduino\arduino-1.0.1\libraries\NewSoftSerial/NewSoftSerial.h:71: error: conflicting return type specified for 'virtual void NewSoftSerial::write(uint8_t)'
C:\arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
Eu segui os passos de um tutorial aqui do Lab mais sem sucesso...
Alguém pode me ajudar?
desde ja agradeço!!!
Tags:
para ajuda seria interessante ter o codigo fonte. veja o prototipo que desenvolvi, esta com codigo fonte.
Fala Marcos, obrigado pela resposta!
Coloquei o codigo, o erro, e a biblioteca
O meu modulo é diferente do seu(eu acho).
O meu é esse: http://www.labdegaragem.org/loja/index.php/38-comunicacao/bluetooth...
Então Camilo, eu dei uma olhada aqui e estou usando justamente essa versão (1.0.1)
Código fonte:
#include <NewSoftSerial.h> // Conexao Serial para bluetooth mate
int bluetoothTx = 0; // Pino TX-O of bluetooth mate para Arduino D2
int bluetoothRx = 1; // Pino RX-I of bluetooth mate para Arduino D3
NewSoftSerial bluetooth(bluetoothTx, bluetoothRx); //Cria as duas portas D2 e D3 em Serial para conectar o bluetooth
int counter = 0;
int incomingByte;
void setup()
{
Serial.begin(57600); //Inicializa a Serial do Arduino com 57600
bluetooth.begin(57600); // Inicializa a comunicacao com o Bluetooth Mate com 57600
delay(100); // atraso de 100 milisegundos
}
void loop()
{
if (Serial.available() > 0) { //Se a Serial estiver disponivel
incomingByte = Serial.read(); //Le o comando vindo da serial
if (incomingByte == '0') { //Se o comando for '0' (zero)
Serial.println("RESET");
bluetooth.println("RESET");
counter=0; // Reseta contador
}
}
Serial.println(counter); // Mostra o contador na serial do Arduino
bluetooth.println(counter); //Mostra o contador pela conexao bluetooth
counter++;
delay(250);
}
ERRO:
bluetooth:5: error: cannot declare variable 'bluetooth' to be of abstract type 'NewSoftSerial'
C:\arduino\arduino-1.0.1\libraries\NewSoftSerial/NewSoftSerial.h:45: note: because the following virtual functions are pure within 'NewSoftSerial':
C:\arduino\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: note: virtual size_t Print::write(uint8_t)
Biblioteca NewSerial:
/*
NewSoftSerial.h - Multi-instance software serial library
Copyright (c) 2006 David A. Mellis. All rights reserved.
-- Interrupt-driven receive and other improvements by ladyada
-- Tuning, circular buffer, derivation from class Print,
multi-instance support, porting to 8MHz processors,
various optimizations, PROGMEM delay tables, inverse logic and
direct port writing by Mikal Hart
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
The latest version of this library can always be found at
http://arduiniana.org.
*/
#ifndef NewSoftSerial_h
#define NewSoftSerial_h
#include <inttypes.h>
#include "Print.h"
/******************************************************************************
* Definitions
******************************************************************************/
#define _NewSS_MAX_RX_BUFF 64 // RX buffer size
#define _NewSS_VERSION 10 // software version of this library
#ifndef GCC_VERSION
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
class NewSoftSerial : public Print
{
private:
// per object data
uint8_t _receivePin;
uint8_t _receiveBitMask;
volatile uint8_t *_receivePortRegister;
uint8_t _transmitBitMask;
volatile uint8_t *_transmitPortRegister;
uint16_t _rx_delay_centering;
uint16_t _rx_delay_intrabit;
uint16_t _rx_delay_stopbit;
uint16_t _tx_delay;
uint16_t _buffer_overflow:1;
uint16_t _inverse_logic:1;
// static data
static char _receive_buffer[_NewSS_MAX_RX_BUFF];
static volatile uint8_t _receive_buffer_tail;
static volatile uint8_t _receive_buffer_head;
static NewSoftSerial *active_object;
// private methods
void recv();
bool activate();
virtual void write();
uint8_t rx_pin_read();
void tx_pin_write(uint8_t pin_state);
void setTX(uint8_t transmitPin);
void setRX(uint8_t receivePin);
// private static method for timing
static inline void tunedDelay(uint16_t delay);
public:
// public methods
NewSoftSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);
~NewSoftSerial();
void begin(long speed);
void end();
int read();
uint8_t available(void);
bool active() { return this == active_object; }
bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; }
static int library_version() { return _NewSS_VERSION; }
static void enable_timer0(bool enable);
void flush();
// public only for easy access by interrupt handlers
static inline void handle_interrupt();
};
// Arduino 0012 workaround
#undef int
#undef char
#undef long
#undef byte
#undef float
#undef abs
#undef round
#endif
Puts, vou conseguir fazer um teste amanhã, ai te falo em seguida! Muito obrigado pela atenção!!!
Amigo, qual o alcance de modulo bluetooth seu ? que classe é?
Então Eduardo, o meu eu comprei aqui na loja do Lab.
É esse aqui: http://www.labdegaragem.org/loja/index.php/38-comunicacao/bluetooth...
La você tem a descrição detalhada.
Abraço;
Oi Fernando,
A "NewSoftSerial" foi implementada na biblioteca padrão do Arduino como "SoftwareSerial" a partir da versão 1.0, portanto, não é necessário utilizá-la. Na parte de exemplos da IDE do Arduino você pode ver alguns exemplos de como utilizá-lo. Os pinos 0 e 1 são utilizados para o "HardwareSerial" e para passar a sua programação para o Arduino. Evite utilizá-los!
Equipe LdG
Pessoal, gostaria de agradecer aos que me ajudaram, deu certo!
Meu erro era um misto do que o Camilo falou com o que o pessoal da LdG orientou também.
Vamos lá:
Ao invés de usar a biblioteca NewSoftSerial.h eu usei a SoftwareSerial.h e ultilizei o os pinos 2 e 3.
Segue o código:
#include <SoftwareSerial.h> // Conexao Serial para bluetooth mate
int bluetoothTx = 2; // Pino TX-O of bluetooth mate para Arduino D2
int bluetoothRx = 3; // Pino RX-I of bluetooth mate para Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); //Cria as duas portas D2 e D3 em Serial para conectar o bluetooth
int counter = 0;
int incomingByte;
void setup(){
bluetooth.begin(57600); // Inicializa a comunicacao com o Bluetooth Mate com 57600
delay(100); // atraso de 100 milisegundos
}
void loop(){
if (bluetooth.available()) { //Se a Serial estiver disponivel
incomingByte = bluetooth.read(); //Le o comando vindo da serial
if (incomingByte == '0') { //Se o comando for '0' (zero)
bluetooth.println("RESET");
counter=0; // Reseta contador
}
}
Serial.println(counter); // Mostra o contador na serial do Arduino
bluetooth.println(counter); //Mostra o contador pela conexao bluetooth
counter++;
delay(250);
}
É um contador simples que fica aguardando eu mandar o caractere '0' para começar novamente a contagem. Com isso da para testar tanto o recebimento quanto o envio de informações do celular para o bluetooth.
Eu estou usando um aplicativo para o android para enviar e receber esses dados. Não sei se conhecem (vi em um tutorial) o nome é: S2 Bluetooth ele é gratuito e vc encontra no Google Play
Mais uma vez obrigado a todos e espero que isso ajude outras pessoas no futuro.
Vlw!!!
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por