i using arduino bluetooth shield from seeedstudio. used example code , connected phone. on phone can read @ commands shield sends, when send , print in serial monitor not receive. bluetoothserial.available() stays 0.
is shield broken? or code below wrong?
is shield broken? or code below wrong?
code: [select]
#include <softwareserial.h> //software serial port
#define rxd 7
#define txd 6
#define debug_enabled 1
#define pin_temp a5
softwareserial bluetoothserial(rxd,txd);
int gettemp()
{
int = analogread(pin_temp);
int b=3975;
float resistance = (float)(1023-a)*10000/a;
float temperature = temperature=1/(log(resistance/10000)/b+1/298.15)-273.15;
return (int)temperature;
}
void setup()
{
serial.begin(9600);
pinmode(rxd, input);
pinmode(txd, output);
setupbluetoothconnection();
}
void loop()
{
char recvchar;
while(1)
{
if(bluetoothserial.available())
{//check if there's data sent remote bluetooth shield
recvchar = bluetoothserial.read();
serial.print(recvchar);
bluetoothserial.print(recvchar);
if(recvchar == 't' || recvchar == 't')
{
bluetoothserial.print("temperature: ");
bluetoothserial.println(gettemp());
}
}
if(serial.available())
{//check if there's data sent t local serial terminal, can add other applications here
recvchar = serial.read();
bluetoothserial.print(recvchar);
}
}
}
void setupbluetoothconnection()
{
bluetoothserial.begin(9600);
bluetoothserial.print("at");
delay(400);
bluetoothserial.print("at+default"); // restore setup value factory setup
delay(2000);
bluetoothserial.print("at+baud4");
delay(400);
bluetoothserial.print("at+nameseeedbtslave"); // set bluetooth name "seeedbtslave" ,the length of bluetooth name must less 12 characters.
delay(400);
bluetoothserial.print("at+pin0000"); // set pair code connect
delay(400);
bluetoothserial.print("at+auth1"); //
delay(400);
bluetoothserial.flush();
}
i thought code junk, saw this
http://forum.arduino.cc/index.php?topic=320606.new#new
i still think it's junk, might not be, , know isn't down you.
http://forum.arduino.cc/index.php?topic=320606.new#new
i still think it's junk, might not be, , know isn't down you.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Bluetooth Shield does not read, but can send
arduino
Comments
Post a Comment