Go Down

Topic: Tapping to control device? (Read 899 times) previous topic - next topic

smoothisfast

I was looking at this video of a Liquivision dive computer.

http://www.youtube.com/watch?v=LnylBjG9MUc

The electronics is potted with no exposed buttons. The device detects taps on its four sides to interface with its menu system.

I would like to do this on a project I'm working on.

MarkT

Probably using an accelerometer chip - that gives the ability to discriminate direction that a microphone wouldn't
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

cyclegadget


  I think an accelerometer chip would work. However, I wonder if 4 piezos and a modified "knock" example code would do the trick? You would measure all 4 sensors and the one with the highest reading would be the intended action/button.

Here is the example code found with no changes:
Code: [Select]
/* Knock Sensor
 
   This sketch reads a piezo element to detect a knocking sound.
   It reads an analog pin and compares the result to a set threshold.
   If the result is greater than the threshold, it writes
   "knock" to the serial port, and toggles the LED on pin 13.
 
   The circuit:
* + connection of the piezo attached to analog in 0
* - connection of the piezo attached to ground
* 1-megohm resistor attached from analog in 0 to ground

   http://www.arduino.cc/en/Tutorial/Knock
   
   created 25 Mar 2007
   by David Cuartielles <http://www.0j0.org>
   modified 4 Sep 2010
   by Tom Igoe
   
   This example code is in the public domain.

*/


// these constants won't change:
const int ledPin = 13;      // led connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100;  // threshold value to decide when the detected sound is a knock or not


// these variables will change:
int sensorReading = 0;      // variable to store the value read from the sensor pin
int ledState = LOW;         // variable used to store the last LED status, to toggle the light

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
Serial.begin(9600);       // use the serial port
}

void loop() {
  // read the sensor and store it in the variable sensorReading:
  sensorReading = analogRead(knockSensor);   
 
  // if the sensor reading is greater than the threshold:
  if (sensorReading >= threshold) {
    // toggle the status of the ledPin:
    ledState = !ledState;   
    // update the LED pin itself:       
    digitalWrite(ledPin, ledState);
    // send the string "Knock!" back to the computer, followed by newline
    Serial.println("Knock!");         
  }
  delay(100);  // delay to avoid overloading the serial port buffer
}
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

smoothisfast

Interesting, I will give both a try.

Go Up