#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 the led light. But now i wanna get resistance 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??