-1
 #include <SoftwareSerial.h>

int blueTx=2;
int blueRx=3;
SoftwareSerial mySerial(blueTx,blueRx);

const int ledpin=8;
const int ledpin1=9;
const int ledpin2=10;
const int sensorpin=A0;

void setup()
{
Serial.begin(9600);
MySerial.begin(9600);
pinMode(ledpin, OUTPUT);
pinMode(ledpin1, OUTPUT);
pinMode(ledpin2, OUTPUT);
}
/*red가 8, yellow가 9, green이 10 이거 알고 코드짜기*/
void loop()
{
 int rate = analogRead(sensorpin);
 Serial.println(rate);

  if(rate<100)
  {
  digitalWrite(ledpin, HIGH);
  digitalWrite(ledpin1, LOW);
  digitalWrite(ledpin2, LOW);
  }
  else if(rate<300)
  {
  digitalWrite(ledpin, LOW);
  digitalWrite(ledpin1, HIGH);
  digitalWrite(ledpin2, LOW);
  }
  else if(rate<500)
  {
  digitalWrite(ledpin, LOW);
  digitalWrite(ledpin1, LOW);
  digitalWrite(ledpin2, HIGH);
  }
  else
  {
  digitalWrite(ledpin, HIGH);
  delay(100);
  digitalWrite(ledpin, LOW);
  delay(100);
 digitalWrite(ledpin1, HIGH);
 delay(100);
 digitalWrite(ledpin1, LOW);
 delay(100);
 digitalWrite(ledpin2, HIGH);
 delay(100);
 digitalWrite(ledpin2, LOW);
 delay(100); 
  }
 if(mySerial.available()){
  Serial.write(mySerial.read());
  }
 if(Serial.available()){
 mySerial.write(Serial.read());
 }
 }
 }

I wrote the code to just change led light. But now I wanna get the resistacne result in a phone so I added HC-06 code to get the result. But I can't see anything when I connected HC-06 module. How can I see the result in my phone??

I wrote the code to just change led light. But now I wanna get the resistacne result in a phone so I added HC-06 code to get the result. But I can't see anything when I connected HC-06 module. How can I see the result in my phone??

I wrote the code to just change led light. But now I wanna get the resistacne result in a phone so I added HC-06 code to get the result. But I can't see anything when I connected HC-06 module. How can I see the result in my phone??

C.P.O
  • 1

1 Answers1

0

I think this is the error

MySerial.begin(9600);

Try replacing with:

mySerial.begin(9600);

as you declared in the top of code

Paul
  • 26
  • 1
  • 5