본문 바로가기

메이커 이야기/아두이노

[Blynk] 아두이노 Blynk HC-06 연결

반응형

아두이노와 Blynk HC_06을 연결하기 위해서 다양한 예제를 찾아 보았으나...

작동이 되지 않아 직접 Blynk 사이트에 찾아가서 연동하는 방법을 알아보았습니다.


HC_06과 통신을 하기 위해서는 BLYNK_WIRTE()함수에 앱에서 지정한 Virtual 값과 동일한 매개변수를 넣어주고

확인을 하면 값을 알아 볼 수 있습니다~!


/************************************************************* Download latest Blynk library here: https://github.com/blynkkk/blynk-library/releases/latest Blynk is a platform with iOS and Android apps to control Arduino, Raspberry Pi and the likes over the Internet. You can easily build graphic interfaces for all your projects by simply dragging and dropping widgets. Downloads, docs, tutorials: http://www.blynk.cc Sketch generator: http://examples.blynk.cc Blynk community: http://community.blynk.cc Follow us: http://www.fb.com/blynkapp http://twitter.com/blynk_app Blynk library is licensed under MIT license This example code is in public domain. ************************************************************* Note: This only works on Android! iOS does not support Bluetooth 2.0 Serial Port Profile You may need to pair the module with your smartphone via Bluetooth settings. Default pairing password is 1234 Feel free to apply it to any other example. It's simple! NOTE: Bluetooth support is in beta! You can use this sketch as a debug tool that prints all incoming values sent by a widget connected to a Virtual Pin 1 in the Blynk App. App project setup: Slider widget (0...100) on V1 *************************************************************/ /* Comment this out to disable prints and save space */ #define BLYNK_PRINT Serial #include <SoftwareSerial.h> SoftwareSerial SwSerial(10, 11); // RX, TX #include <BlynkSimpleSerialBLE.h> #include <SoftwareSerial.h> // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = " YOUR KEY"; SoftwareSerial SerialBLE(2, 3); // RX, TX // This function will be called every time Slider Widget // in Blynk app writes values to the Virtual Pin 1 BLYNK_WRITE(V1) { int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable // You can also use: // String i = param.asStr(); // double d = param.asDouble(); Serial.print("V1 Slider value is: "); Serial.println(pinValue); } void setup() { // Debug console Serial.begin(9600); SerialBLE.begin(9600); Blynk.begin(SerialBLE, auth); Serial.println("Waiting for connections..."); } void loop() { Blynk.run(); }


반응형