Microduino BLE Android-202KIT
From Microduino Wiki
Language: | English • 中文 |
---|
ContentsOutlineProject: Microduino-BT communicates with Android devices. Objective: Android phones can send character strings to Microduino-Core and Microduino-BT via phone App, and display character data via the serial monitor. Difficulty: Primary Time-consuming: 30mins Maker: Microduino Studio-YLB | ||||||||||||
Bill of Materials
| ||||||||||||
Arduino IDE(Version 1.0 and higher)
DocumentTest program and App download:File:BT—APP.zip | ||||||||||||
Debugging | ||||||||||||
Step 1: Stack Microduino-Core and Microduino-USBTTL together, connect them to a computer with a USB cable, start Arduino IDE, open test program M_ble_Serial.ino, select Microduino Core (Atmega328P@16M,5V) from (tools)-> (Board) and choose the corresponding serial port from(tools)-> (Serial) . After that, please click the button "√" on the top left of IDE, compile the program, and then click "√" to burn the program into the board; | ||||||||||||
Step 2: Stack all modules after the download, connect them to the computer with a USB cable and install after power-off. | ||||||||||||
Step 3: Start to set IOS device, get the Bluetooth function activated, install and open ".apk " file, then open the serial monitor in the IDE side of the computer. Step 4: Click the SCAN button on the top right of the App and you'll see peripheral Bluetooth devices as follows: Click the correpsonding Bluetooth number and enter the following interface: Wait for 203 seconds until you see "ready" on the screen, meaning the phone has established connection with the Bluetooth; By clicking the button " Sync RTC With Phone " in the middle of the screen and watch the change of the serial monitor as well as "RTC TIME" on the top of the button. You can see RTC content change on the phone and receive the corresponding data on the serial monitor side, which means the bidirectional communication function of Bluetooth. Analysis of Test Code#include <SoftwareSerial.h>
// RX, TX ; Use default Bluetooth communication serial 4 and 5.
SoftwareSerial mySerial(4, 5);
#define my_Serial mySerial
String msg = "";
void setup()
{
// Initialize the baud rate of the serial communication.
my_Serial.begin(9600);
Serial.begin(9600);
}
void loop()
{
//Every time it receives signal, it'll give feedback once to the other communication side.
if (my_Serial.available() > 0) //If there is serial data input
{
msg = my_Serial.readStringUntil('\n'); //Acquire all content before a line break.
Serial.println(msg); //Display character strings on "msg" in the serial monitor.
my_Serial.println("bluetooth respond"); //Send data to the other side of the Bluetooth communication.
}
} ResultBy Microduino-BT, Microduino core can communicate with an Android phone. Caution
|