Você está na página 1de 17

Studuino

Bluetooth Module
HC-05
Manual

This manual explains the Studuino Programming Environment and how to use it.
As the Studuino Programming Environment develops, this manual may be edited or
revised. You can find the full manual below.
■ Installing Studuino Software
http://artec-kk.co.jp/studuino/docs/en/Studuino_setup_software.pdf
Index
1. About your Bluetooth Module ................................................................................. 1
1.1. Overview ................................................................................................................. 1
1.2. Specifications .......................................................................................................... 1
2. Connecting to Studuino .......................................................................................... 1
3. Pairing with a PC, Smartphone, or Other Device .................................................... 3
4. In the Studuino Icon Programming Environment .................................................... 3
4.1. Sample Program ..................................................................................................... 6
5. In the Studuino Block Programming Environment ................................................ 10
5.1. Sample Program Using a Bluetooth Module......................................................... 11
5.1.1. Sample Program Using Basic Bluetooth Blocks ........................................... 11
5.1.2. Sample Program Using the Control Application ............................................ 14
5.2. A Note on Bluetooth Blocks .................................................................................. 15
1. About your Bluetooth Module

1.1. Overview

Your Bluetooth Module uses the V2.0 + EDR Bluetooth standard and supports SPP (Serial
Port Profile) for serial connection (UART) with your Studuino.

1.2. Specifications
Module HC-05
Operating Voltage 3.3-5V
Version V2.0+EDR
Profile SPP
Interface UART
Communication Range Approx. 10 m
※ ★ Insufficient battery power may result in inaccurate measurements. Try changing your batteries if this
happens.
※ ★ This product is not radio frequency or wireless certified.
Use in an open space to prevent interference.
Unauthorized radio and wireless broadcasting may be in violation of federal and state law.

2. Connecting to Studuino

① Use the four-wire 15 cm Bluetooth Module connecting cable (product 086883, sold
separately).
② The white wire of the 4-pin cable connects to the RXD pin of your Bluetooth Module,
while the black wire connects to the VCC pin.
③ The gray wire of the 2-pin cable connects to 0RX and the white wire connects to 1TX on
your Studuino.
④ The two black wires of the 3-pin cable connect to the V and G pins of any connector
from A0 to A7 on your Studuino.

1
4-pin
2-pin
White Gray White Gray
Bluetooth Module
Black Black

TX D
RXD

GND
VCC Blac
Blac
3-pin k lac
B
k
k

Make sure the cables are inserted correctly!

2
3. Pairing with a PC, Smartphone, or Other Device

Your module needs to be paired with a PC, smartphone, or other device in order to
communicate. If you're prompted to enter a PIN, use 1234.

4. In the Studuino Icon Programming Environment

Familiarize yourself with the basics of the Studuino Programming Environment by reading
the Studuino Programming Environment Manual and the Icon Programming Environment
Guide. Using your Bluetooth Module with insufficient battery power may cause sudden
interruptions in communication. Always use batteries with enough power.

From the Edit menu click Optional Parts. A check will appear beside this option when
enabled.

Enabled when checked

Bluetooth modules can be used with connectors A0-A7. Bluetooth modules use any
connector from A0 to A7. Port Settings are made for the black wire of the cable. Make sure
the gray and white wires are connected to 0RX and 1TX. (See エラー! 参照元が見つかりま
せん。.エラー! 参照元が見つかりません。.)

3
Shown connected to A6

Drag and drop the icons shown below and choose one of the four Bluetooth: [***] conditions.
Selecting Bluetooth: ID as a condition allows you to choose from a number of IDs, while the
Bluetooth: Accelerometer X, Y, and Z options allow you to use the values from an
Accelerometer as conditions.

4
Bluetooth accelerometer values are the values from the accelerometer of the device you are
using. These values can be checked in the application Accelerometer Settings screen rather
than the Sensor Viewer. Acceleration values have a range of ±2 g (g = gravitational
acceleration = 9.8[m/s^2]) shown as 11 steps from -5 to 5. See the Bluetooth Application
Guide for details.

5
4.1. Sample Program
Familiarize yourself with the basics of the Studuino Programming Environment by reading
the Studuino Programming Environment Manual and the Icon Programming Environment
Guide.
See the Bluetooth Application Guide for details on using the application.

Make a DC Motor run using the accelerometer of your device and turn LEDs on or off by using
the buttons of the application.
① Set the Port Settings as shown below.

② Check the Repeat Indefinitely box, place icons, and set them as shown below.

6
No. 1

Action: Forward, Speed: 6, Time: 0.1 sec, Brake: OFF


Condition: Bluetooth: Accelerometer X < 0

No. 2

Action: Backward, Speed: 6, Time: 0.1 sec, Brake: OFF


Condition: Bluetooth: Accelerometer X > 0

7
No. 3

Action: Right Turn, Speed: 6, Time: 0.1 sec, Brake: OFF


Condition: Bluetooth: Accelerometer Y > 0

No. 4

Action: Left Turn, Speed: 6, Time: 0.1 sec, Brake: OFF


Condition: Bluetooth: Accelerometer Y < 0

8
No. 5

Action: LED, Switch ON, Connector A0


Condition: Bluetooth: ID01

No. 6

Action: LED, Switch OFF, Connector A0


Condition: Bluetooth: ID02

9
5. In the Studuino Block Programming Environment

To use your Bluetooth Module in the Block Programming Environment you will need to make
sure the Bluetooth block is available and active. Follow the steps below to do this:

① From the Edit menu, choose Show Optional Parts to display the new sensor blocks.

Click the Edit menu


and select Show
Optional Parts.

The new
sensor blocks
will appear
here.

② Click the Edit menu and choose Port Settings... to open the Port Settings dialog.

Click the Edit menu


and select Port
Settings...

The Port
Settings dialog
will appear

10
③ Your Bluetooth Module can use any connector from A0-A7. Under the Sensor / Buzzer /
LED section of the Port Settings dialog, check any box from A0 to A7 and use the
combo box to select Bluetooth. Click OK. The following sections assume the Bluetooth
Module is connected to A0.

Only one port at a


time from A0 to A7
can be used with a
Bluetooth Module

④ The Bluetooth block will become active.

Bluetooth blocks
will appear here

, , and
are basic blocks used to send and receive 1 byte packets of data via Bluetooth. The
, , and blocks
are used to receive data from Artec's controller application.

5.1. Sample Program Using a Bluetooth Module

5.1.1. Sample Program Using Basic Bluetooth Blocks


This section shows a program from the perspective of both the Android application and
Studuino. The Android device sends LED ON/OFF commands and Servomotor angles to
Studuino, while the Studuino sends Gyroscope values to the Android device.

11
[Android]

Sends LED ON/OFF


command and
Servomotor angles to
Studuino

Receives Gyroscope
values from Studuino

[Studuino]

Sends Gyroscope
values to Android
device

Receives LED and


Servomotor data from
Android device

12
Let's take a look at the processes
of a Studuino program. In this
example, the Android device
sends data to your Studuino in 2
byte packets. The 1st byte is the
command ID and the 2nd byte is
the command data. Your
Studuino sends 1 byte packets to
your Android device.
The sendGyroValue function first
sends a gyroID(150) indicating the
gyroscope sensor value before
sending acceleration and angle
values (from 0-100) for the X, Y,
and Z axes in 1 byte packets.
The getBluetoothCommand
function will save any data
received from an Android device
to a command list, dividing
processes by command ID for any
2 byte packet it receives. In this
example, the command IDs are
determined to be the following:
・200: Servomotor action
・201: Action for LED on A1
・202: Action for LED on A2
・203: Action for LED on A3
The command list is cleared after
processing the command data in
the 2nd byte.

13
5.1.2. Sample Program Using the Control Application

The picture below shows a sample program using the control application. The picture below
shows a program using a Bluetooth block. The Bluetooth block is meant to be used with
Artec's control application on Android devices. The block
receives different types of data from the application and uses that data to control your robot.
The block retrieves values of 0-100 from the Accelerometer of your
Android device, and the block checks whether or not the icons of the
control application are currently being pressed.

See the Bluetooth Application Guide for details on using the application.

14
5.2. A Note on Bluetooth Blocks

The Bluetooth block will not be able to retrieve the values from the control application when
in Test mode. This is due to Blueooth using serial communication between your Android
device and PC. While in Test mode your PC has sole use of the Studuino serial port, which
disables communication between Studuino and your Android device. In Test mode, the

, , and
blocks always return Yes, the , , and
block does nothing.

15

Você também pode gostar