You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,51 +167,81 @@ BT TX - D2
167
167
BT RX - D3
168
168
169
169
// Basic Bluetooth sketch HC-06_01
170
+
171
+
170
172
// Connect the Hc-06 module and communicate using the serial monitor
171
-
//
173
+
172
174
// The HC-06 defaults to AT mode when first powered on.
175
+
173
176
// The default baud rate is 9600
177
+
174
178
// The Hc-06 requires all AT commands to be in uppercase. NL+CR should not be added to the command string
179
+
175
180
// Use no line ending in serial monitor
181
+
176
182
/*Command Reply Comment
183
+
177
184
The HC-06 zs-040 expects commands to be in upper case and does not require carriage return and new line (\r\n) characters.
178
185
Open the serial monitor and select a baud rate of 9600 and ensure “No line ending” is selected from the drop down list at the bottom of the window.
186
+
179
187
Enter “AT” (no quotes) into the top text box and hit Send. If the HC-06 likes you it will say OK. AT is a basic communications test command that allows you to check the HC-06 is connected and communicating.
180
188
181
189
AT OK Communications test
190
+
182
191
AT+VERSION OKlinvorV1.8 Firmware version.
192
+
183
193
AT+NAMEPanda OKsetname Sets the modules name to “Panda”
194
+
184
195
AT+PIN1234 OKsetPIN Set the PIN to 1234
196
+
185
197
*/
186
198
187
199
#include <SoftwareSerial.h>
200
+
188
201
SoftwareSerial BTserial(2, 3); // BT_TX | BT_RX
202
+
189
203
// Connect the HC-06 TX to the Arduino RX on pin 2.
204
+
190
205
// Connect the HC-06 RX to the Arduino TX on pin 3.
191
206
192
207
208
+
193
209
void setup()
210
+
194
211
{
212
+
195
213
Serial.begin(9600);
214
+
196
215
Serial.println("Enter AT commands:");
197
216
198
217
// HC-06 default serial speed is 9600
218
+
199
219
BTserial.begin(9600);
220
+
200
221
}
201
222
202
223
void loop()
224
+
203
225
{
204
226
205
227
// Keep reading from HC-06 and send to Arduino Serial Monitor
228
+
206
229
if (BTserial.available())
230
+
207
231
{
232
+
208
233
Serial.write(BTserial.read());
234
+
209
235
}
210
236
211
237
// Keep reading from Arduino Serial Monitor and send to HC-06
0 commit comments