Go ahead and create this circuit for Arduino:
The connections are as follows:
PIR → Arduino
GND → GND
OUT → D02
VCC → 5V
HC-06 → Arduino
VCC → 3.3V
GND → GND
TXD → D10
RXD → D11
Don't get mad, but there is one last library that you need to install in order to allow Arduino to communicate with Python: pySerial
. Go to https://pypi.python.org/pypi/pyserial, download pyserial-2.7.win32.exe
, and install it just like you install any other software. Then, we are ready.
Open Arduino and load the alarm_bluetooth.ino
file that came with this chapter. It is recommended that you have the most up-to-date Arduino software before proceeding:
#include <SoftwareSerial.h> // serial library used for communication SoftwareSerial burg_alarm(10, 11); // communicates via TX, RX at 10, 11 respectively int ledPin = 13; // in built LED to show status changes int pirPIN = 2; // signal of the PIR sensor goes to pin 2 int pirState = LOW; // initiate the PIR status to LOW (no motion) int pirVal...