Hello all,
I would like to create a device, using FLORA, a PIR sensor, and LEDs, that lights up LEDS when motion is sensed. However, I want to use the FLORA as the programmable device and NOT the Uno or Raspberry Pi. I have a background in Computer Science, but I am not as familiar with hardware at the level of connecting wires.
Does anyone know how I would connect the Adafruit PIR sensor to the Adafruit FLORA? There are plenty of tutorials on connecting LEDs to the FLORA, so I have that working already.
PIR Sensor: PIR (motion) sensor : ID 189 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits
FLORA: FLORA - Wearable electronic platform: Arduino-compatible [v3] : ID 659 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Edit: Here's what I have so far.
GND to GND. Power to power (not sure if that is correct or if I need an external power source aside from the FLORA). D6 to Out.
I want to make the entire project wearable, as a belt or in a jacket, so I don't want to use a bread board. I have conductive thread, just no clue on the proper wiring.
I am attempting to use this code, found on the forums here to test out the PIR. No luck getting it working yet. I would appreciate any help! Thank you!
/*
Motion sensor for Arduino, example code
Tutorial: http://www.hacktronics.com/Tutorials/arduino-motion-sensor.html
Copyright: Mark McComb, hacktronics LLC
License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
*/
const byte ledPin = 13; // LED pin
const byte motionPin = 2; // motion detector input pin
byte senseMotion = 0; // variable to hold current state of motion detector
void setup() {
// set the digital pin directions
pinMode(ledPin, OUTPUT);
pinMode(motionPin, INPUT);
}
void loop()
{
// Now watch for burglers
senseMotion = digitalRead(motionPin);
if (senseMotion == HIGH) { // burgler found!
digitalWrite(ledPin, HIGH);
} else { // no burgler, yet...
digitalWrite(ledPin, LOW);
}
}
Solution:
Got the PIR working with an answer from the Adafruit Forums! http://forums.adafruit.com/viewtopic.php?f=51&t=40973
Now, I just need to get the LEDs working when motion is detected.
Here is my Arduino code:
int pirPin = 9; // use pin 9 on the Flora
void setup()
{
pinMode(pirPin, INPUT);
Serial.begin(9600);
}
void loop()
{
long now = millis();
if (digitalRead(pirPin) == HIGH)
{
Serial.println("MOVEMENT");
}
delay(500);
}
And my Python code:
import time
import serial
import smtplib
ser = serial.Serial('/dev/tty.usbmodem3a21', 9600)
while True:
message = ser.readline()
print(message)
if message[0] == 'M' :
print 'Motion Detected'
time.sleep(0.5)