Hi guys,i have some problem on this project.i want to use hc-05 bluetooth module,hc-sr501 and lm 35.bot arduino cant supply these with enough current.so i used a external 5v-2a supply to feed them.but problem is here:when i used external supply,bluetooth module can
t sync with arduino and so arduino can`t execute command.but when i use command bar at serial monitor,it works.i donno what to do.please helllllllllllllp....
#include <IRLibAll.h>
#include <SoftwareSerial.h>
SoftwareSerial BTserial(4, 5); // RX | TX
const int sensor=A5; // Assigning analog pin A1 to variable 'sensor'
float tempc; //variable to store temperature in degree Celsius
float vout; //temporary variable to hold sensor reading
IRsend mySender;
int led = 11;
int sensor1 = 2; // the pin that the sensor is atteched to
int state = LOW; // by default, no motion detected
int val = 0; // variable to store the sensor status (value)
char junk;
String inputString="";
String inText;
char c = ' ';
void setup()// run once, when the sketch starts
{
Serial.println("Enter AT commands:");
pinMode(sensor,INPUT);
Serial.begin(9600); // set the baud rate to 9600, same should be of your Serial Monitor
pinMode(13, OUTPUT);
pinMode(led, OUTPUT); // initalize LED as an output
pinMode(sensor1, INPUT); // initialize sensor as an input
}
void loop()
{
vout=analogRead(sensor);
vout=(vout*500)/1024;
tempc=vout; // Storing value in Degree Celsius
if(Serial.available()){
while(Serial.available())
{
char inChar = (char)Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}
Serial.println(inputString);
while (Serial.available() > 0)
{ junk = Serial.read() ; } // clear the serial buffer
if(inputString == "o"){ //in case of 'a' turn the LED on
delay(4000);
mySender.send(NEC,0xFF08F7, 32);
}else if(inputString == "s"){ //incase of 'b' turn the LED off
digitalWrite(13,HIGH);
delay(2000);
digitalWrite(13,LOW);
}
else if(inputString == "t"){
Serial.print("in DegreeC=");
Serial.print("\t");
Serial.print(tempc);
delay(1500);
}
inputString = "";
}
}
blue2.ino (1.75 KB)