Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
project:arduino-kickstarter-wheewhee [19.03.2011 22:22] – angelegt gonium | project:arduino-kickstarter-wheewhee [14.01.2013 15:56] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | {{: | ||
+ | < | ||
+ | int sensorPin = A0; // select the input pin for the potentiometer | ||
+ | int ledPin = 13; // select the pin for the LED | ||
+ | int sensorValue = 0; // variable to store the value coming from the sensor | ||
+ | int buzzerPin=8; | ||
+ | int keyPin = 9; | ||
+ | int frequency, oldfrequency = 0; | ||
- | <code> | + | boolean isOn = false; |
- | foo | + | |
+ | void setup() { | ||
+ | // declare the ledPin as an OUTPUT: | ||
+ | pinMode(ledPin, | ||
+ | pinMode(keyPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (!digitalRead(keyPin)) { | ||
+ | // read the value from the sensor: | ||
+ | |||
+ | sensorValue = 0; | ||
+ | for (int i=0; i<=9; i++) { | ||
+ | sensorValue += analogRead(sensorPin); | ||
+ | } | ||
+ | frequency=(sensorValue/ | ||
+ | if (frequency != oldfrequency) { | ||
+ | tone(buzzerPin, | ||
+ | oldfrequency = frequency; | ||
+ | } | ||
+ | } else { | ||
+ | noTone(buzzerPin); | ||
+ | oldfrequency=0; | ||
+ | } | ||
+ | } | ||
</ | </ |