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:
Microsoft Visual Studio 2015 Community Update 3 to work on the Universal Application:
Windows IoT Dashboard NOTE: Your OS must be at least Windows 10 version 1511
Step 2: Step 2: Prepare Nessecary Hardwares
- 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
Step 4: Step 4: Code Section
- You will need to install "Universal Windows App Development Tool".
- After finished the installation, start up the Visual Studio.
- Create a new project > Blank Universal Apps.
- You will need to install the NuGet package for the RadialGauge. In this case, we recommend " Microsoft.Uwp.Toolkit.UI.Controls" NuGet package.
- Right click on the Project. Add reference: "Windows IoT Extensions for the UWP" for the deployment to the Raspberry Pi purposes.
- Start design MainPage.xaml for the UI and the MainPage.xaml.cs for the code behind.
- Remember to get the reading data from the Arduino to the Raspberry Pi. This code is done in the MainPage.xaml.cs.
- Finally, you can debug your project by remote machine in the Visual Studio.
Step 5: Step 5: Deploy Project
Good Luck and Have Fun deploying your project! :)
We have a be nice policy.
Please be positive and constructive.