Introduction: Distance, Tilt and Buzzer Sensors

How does this Distance, Tilt and Buzzer Sensors work?

The Sharp 2Y0A21 sensor will detect the distance between the sensor and the object (E.g. hand, card, etc.) and the data between distance and object will be shown on the touch screen in radial gauge chart. As the distance increases, the ADC value will decrease such that they are a push-pull relationship.

As for the tilt sensor, we are using SW-520D ball bearing tilt sensor. We create a integer (int) variable for the reading, when mounted on breadboard upright the signal output is 0 and tilted is 1 (see code for better understanding). When tilt sensor reading is at 1, buzzer will sound with the red LED lighted up. When it's at original state (0) the buzzer will stop and green LED lighted up.

Step 1: Step 1: Download Essential Softwares

Arduino Software (IDE) to deploy the Arduino code to the Arduino:

https://www.arduino.cc/en/Main/Software

Microsoft Visual Studio 2015 Community Update 3 to work on the Universal Application:

https://go.microsoft.com/fwlink/?LinkId=691129

Windows IoT Dashboard NOTE: Your OS must be at least Windows 10 version 1511

http://tinyurl.com/jmnfz73

Step 2: Step 2: Prepare Nessecary Hardwares

You will need:
  • Raspberry Pi 3 Model BRaspberry Pi 7 inch touch screen LCD
  • Arduino UnoSharp 2Y0A21
  • Buzzer sensor
  • Red & Green LED
  • Tilt Sensor

Step 3: Step 3: Setup

Credit to:

MCM Electronics

Wouter Pieper

Step 4: Step 4: Code Section

Step:

  1. You will need to install "Universal Windows App Development Tool".
  2. After finished the installation, start up the Visual Studio.
  3. Create a new project > Blank Universal Apps.
  4. You will need to install the NuGet package for the RadialGauge. In this case, we recommend " Microsoft.Uwp.Toolkit.UI.Controls" NuGet package.
  5. Right click on the Project. Add reference: "Windows IoT Extensions for the UWP" for the deployment to the Raspberry Pi purposes.
  6. Start design MainPage.xaml for the UI and the MainPage.xaml.cs for the code behind.
  7. Remember to get the reading data from the Arduino to the Raspberry Pi. This code is done in the MainPage.xaml.cs.
  8. Finally, you can debug your project by remote machine in the Visual Studio.
Further information: For the reference to create RadialGauge, you can refer to below link:

Step 5: Step 5: Deploy Project

Good Luck and Have Fun deploying your project! :)

Comments

author
Swansong made it!(author)2016-11-30

Good instructable :) Welcome to the community!