Ardumotive Arduino Greek Playground
  • Home
    • About us
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Αισθητήρας δόνησης​

Available Languages
Picture
Picture

Introduction 

Picture
Στο σημερινό tutorial θα δούμε πως μπορούμε με την χρήση ενός συγκεκριμένου αισθητήριου να ανιχνεύσουμε κάποια απότομη κίνηση ή δόνηση. Το συγκεκριμένο εξάρτημα ονομάζεται Vibration sensor ή shake Switch.

​Σκοπός αυτού του tutorial είναι να το συνδέσουμε με το Arduino και στην περίπτωση που υπάρχει δόνηση να ακούγεται ένας ήχος απ' ένα μικρό buzzer.

Τι θα χρειαστούμε

  • Arduino uno
  • Breadboard και μερικά καλώδια
  • Vibration/Shake switch
  • Buzzer

Το κύκλωμα

Ardumotive Tutorial - Arduino Shake Vibration Sensor

​Οι συνδέσεις είναι αρκετά απλές, ακολουθήστε το παραπάνω σχηματικό.



Ο κώδικας

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Vibration Sensor (Shake Switch) - Testing with buzzer

   In this tutorial we will use one vibration sensor (or shake switch) 
   to make a beep sound from a buzzer while we shake our breadboard.
   
   Find more info and video here: http://bit.ly/1iDbc2Q
   
   Dev: Michalis Vasilakis - Date: 9/9/2015 - www.ardumotive.com       */
   
const int buzzer = 8; //Buzzer connected to pin 8 of Arduino uno / mega
int sensor;           //Variable to store analog value (0-1023)

void setup()
{
	Serial.begin(9600);      //Only for debugging
	pinMode(buzzer, OUTPUT);
}

void loop()
{
	sensor = analogRead(A0);
	//While sensor is not moving, analog pin receive 1023~1024 value
	if (sensor<1022){
		tone(buzzer, 500);
		Serial.print("Sensor Value: ");
		Serial.println(sensor);
	}
	else{ 
		noTone(buzzer);
		Serial.print("Sensor Value: ");
		Serial.println(sensor);
	}
	delay(100); //Small delay
}
​Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE. Ανοίξτε την σειριακή οθόνη απ' το μενού εργαλεία του Arduino IDE.
vibrationsensor_tutorial.zip
File Size: 0 kb
File Type: zip
Download File

Συγχαρητήρια 

Picture
Ολοκληρώσατε με επιτυχία άλλο ένα Arduino Tutorial της σελίδας μας.

Εύκολο, δύσκολο? Πείτε μου πως σας φάνηκε στα σχόλια παρακάτω!
​
Picture
Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates