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

Κουμπί και ηχείο buzzer

Available Languages
Picture
Picture

Εισαγωγή

Picture
Grove - Το κουμπί έχει ένα πλήκτρο το οποίο εκπέμπει σήμα HIGH όταν πιέζεται και LOW όταν απελευθερώνεται. Σε αυτόν τον οδηγό θα δείτε πως μπορείτε να ενεργοποιήσετε ένα ηχείο buzzer πατώντας το κουμπί

Τα υλικά που θα χρειαστείτε και η σύνδεση

Για το tutorial αυτό θα χρειαστείτε:
  • Arduino UNO
  • Grove Base Shield
  • Button
  • Buzzer (Συνδέστε το Grove-Buzzer στην A3 είσοδο του Grove-Base Shield)
Picture

Ο κώδικας

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const int buttonPin = 2; 
const int buzzer = A3; 

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
    // initialize the LED pin as an output:
    pinMode(buzzer, OUTPUT);
    // initialize the pushbutton pin as an input:
    pinMode(buttonPin, INPUT);
}

void loop(){
    // read the state of the pushbutton value:
    buttonState = digitalRead(buttonPin);
    if (buttonState == HIGH) {
        tone(buzzer, 1000);
    }
    else {
        noTone(buzzer);
    }
}
Κατεβάστε τον κώδικα απ' εδώ και ανοίξτε το αρχείο με το Arduino IDE.
grove-button.zip
File Size: 0 kb
File Type: zip
Download File

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

Picture
Μόλις ολοκλήρωσες άλλο ένα tutorial με το Grove !

Αν το έκανες και εσύ και σου φάνηκε εύκολο γράψε την άποψη σου κάτω στα σχόλια !
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