element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Andy Clark's Blog Gnomes Workshop - Sensors and Motors
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 5 May 2016 11:46 AM Date Created
  • Views 503 views
  • Likes 4 likes
  • Comments 2 comments
Related
Recommended

Gnomes Workshop - Sensors and Motors

Workshopshed
Workshopshed
5 May 2016

Once the headless Raspberry Pi had been set-up we got started with Node-Red, sensors, LEDs and Servos.

image

For the sensors I selected 3 different kinds, light, touch and motion.

 

imageimageimage

The light sensor is based around a simple LM393 comparator with a preset to do the comparison. This is powered from 3.3v and the output is a digital signal. There is a power and output LED so that it can be tested independently.

The touch sensor is based around a TTP223B chip, this is also powered from 3.3v and the output should be digital.

The motion sensor is a passive infra-red detector based on the HC-SR501C, this is powered from 5v but has a 3.3v output. There are two adjustments, one for sensitivity and the other controls how long the output stays high once an event is triggered.

 

I did not have a chance to try out the LDR and my intial experiments with the touch sensor were unsuccessful too. However the PIR was what was needed for the first project and that worked well so we stuck with that.

 

The LEDs were pre-wired with a series resistor and sockets to connect to the GPIO on the Pi, this worked really well.

 

The Servos were cheap micro-servos, I also brought along a few servo testers which we used to make sure the servos were working correctly.

 

Cat Scarer

Charlie's project was to stop the neighbour's cats from spending time on his lawn. One of our main challenges was getting the voice recording off an IPad and onto the Pi. We eventually got help from the sound guy and re-recorded it onto an SDCard and used WinSCP to copy the file onto the Pi.

 

This project used a PIR sensor and a powered headphone speaker connected to the 3.5mm audio jack on the Pi.

 

The flow works as follows:

     The sensor goes high when motion is detected.

     To avoid multiple triggers we limit the flow to one message every 2s.

     This is then wired to the LED so we can see that the sensor has triggered an event.

     A random node creates values 1 or 2 and this passes to the switch to select one of the two outputs.

     Finally the EXEC nodes run the command line "aplay" with one of two values for a police siren or a recorded message.

image

Trouble with servos

We tried to get the servos to work but they simply refused to co-operate. I've since followed up on this and we should have used the GPIO 2 pin as that has hardware PWM, there's also a limited range of values that can be used. If we'd have had time I also had a Picon Zero which we could have used to control lots of servos.

image

 

Mouse Toggle

David used a blue tooth mouse to remote control his Pi's LED. This was one area where we could not work out how to complete the flow without code. Each mouse click turned the LED on or off.

image

Toggle Code

var state = context.get('state')||0;
if (state == 0) {
    state = 1;
}
else {
    state = 0;
}
context.set('state',state)
msg.payload = state;
return msg;

 

 

Reference

Node Red

Playing Audio on the Pi

  • Sign in to reply
  • Workshopshed
    Workshopshed over 9 years ago in reply to dougw

    Yes, I believe that Charlie is planning a battery powered Pi, located inside a gnome

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 9 years ago

    Cool - but is this going to reside inside a gnome?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube