如何通过蓝牙将HC05(arduino)的信息发送到Android?

时间:2016-11-29 05:36:40

标签: android bluetooth arduino

我只需要发送一个值来触发Android应用程序上的功能,但我无法弄清楚如何使用HC05来发送值。 这就是我的主意。在此先感谢您的任何帮助

const int analogInPin = A0;  
// Analog input pin that the potentiometer is attached to

const int analogOutPin = 13; 
// Analog output pin that the LED is attached to

int sensorValue = 0;
// value read from the pot
int outputValue = 0;        
// value output to the PWM (analog out)

void setup() {
 // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  if(sensorValue < 30 ) {Serial.println("TRIGGERED");
  Serial.end();
  };

  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 100 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(100);`enter code here`
}

0 个答案:

没有答案