Author Topic: Motion Sensor [Completed Project]  (Read 5635 times)

willscott

  • Newbie
  • *
  • Posts: 10
Motion Sensor [Completed Project]
« on: January 02, 2013, 11:21:34 pm »
I hooked a PIR SE-10 motion sensor up to the digispark, to detect motion near my computer.
(Sparkfun link to the sensor)

There's a good guide for making the sensor work with an Arduino, and the same wiring works for the digispark.

Here's simple code for reporting read values to the computer.

Pictures
« Last Edit: January 03, 2013, 12:52:34 pm by willscott »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Motion Sensor [Completed Project]
« Reply #1 on: January 03, 2013, 12:57:46 pm »
@willscott - awesome the first full documented complete project - hope you don\'t mind I bumped you to the top for now and added to your subject line.

Once the wiki is open to all I hope you will consider adding a page for this, while this may be a relatively simple project, these are exactly the types of projects I envisioned the Digispark would be perfect for when I created it.

We\'ll be announcing some rewards in the near future for people who consistently post complete projects like this - so keep it up and we\'ll send you more stuff!

Thanks - from a fellow Washingtonian!

willscott

  • Newbie
  • *
  • Posts: 10
Motion Sensor [Completed Project]
« Reply #2 on: January 03, 2013, 11:07:22 pm »
Cool!

My computer side code is hackier, so I haven\'t posted it quite yet.  I think the most relevant part is that I modified the digiusb/digiterm example to directly write received data to STDOUT, so that I could consume it in python.  The modified digiterm looks like:
#!/usr/bin/env ruby
require \'digiusb\'

sleep 0.25 until DigiUSB.sparks.length > 0
spark = DigiUSB.sparks.last

begin
  loop do
    print spark.getc
    begin
      char = $stdin.read_nonblock(1)
      spark.putc char
    rescue Errno::EAGAIN
    end
  end
rescue LIBUSB::ERROR_PIPE
  puts \"!\"
rescue Interrupt
  puts \"\"
end


digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Motion Sensor [Completed Project]
« Reply #3 on: January 03, 2013, 11:26:16 pm »
Python and compiled executables for dealing with DigiUSB are uploading in about 15 minutes and should be up in an hour or so - should make that all much simpler!

It will even come with an example of hooking a LCD to the computer via USB and sending data to the screen from a command line app.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Motion Sensor [Completed Project]
« Reply #4 on: January 04, 2013, 02:35:03 am »
Would it help if digiterm had a raw option?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Motion Sensor [Completed Project]
« Reply #5 on: January 05, 2013, 12:55:45 am »
Checkout the latest update for plenty of examples of how to talk to DigiUSB - some raw output options are in there

willscott

  • Newbie
  • *
  • Posts: 10
Re: Motion Sensor [Completed Project]
« Reply #6 on: January 21, 2013, 07:36:25 pm »
I switched to my program to grab data from the digispark using the read.py included in the example programs.  Worked great!