Hey folks, new here
Project needs: please advise this newbie
I need a device that detects pressure in the form of something pressing down on it
The device starts a continuous ringing noise when it is pressed down on, doesn't turn off till you hit the off button.
Im working with an Arduino Uno
thank you kindly for the response, YES that is what I was looking for.
My next question would be how pressing down on the sensor would set off an alarm that beeps until you turn it off. minimal user interface.
You would write a program to read the sensor and act accordingly.
Start with the examples that come with the Arduino, and the example that is provided for the force sensitive resistor.
//Assume the pressure sensor is wired to A1
//and connected to ground and IOREF power pins
//so that increasing pressure gives an increasing voltage
//and a corresponding increase in analog reading
const int PressureInputPin = A1;
//connect the 'off button' between ground and pin 2
const int PinOffButton = 2;
//connect the beeper to pin 3 (and ground)
const int PinBeeper = 3;
const unsigned int AnnoyingBeepFrequency = 2000; //not tested - you may need to change this to your liking
const int PressureThreshold = 512; //between 0 and 1023 - select this by testing with your actual sensor
int PressureReading=0; //create a variable to store the pressure result
void setup() {
pinMode(PinOffButton, INPUT_PULLUP);
//note that analog reads from analog pins don't require the pin to be set as an input
Serial.begin(9600); //Serial only for monitoring/testing pressure. Not required for actual operation
While(!Serial); //If using Arduino Micro, make it wait for the serial monitor to connect
Serial.prinltn("Starting...");
}
void loop() {
do {
PressureReading = analogRead(PressureInputPin);
Serial.print("Pressure=");
Serial.prinltn(PressureReading);
} while(PressureReading < PressureThreshold);
Serial.println("THRESHOLD EXCEEDED - BEEPING!");
tone(PinBeeper, AnnoyingBeepFrequency);
while(digitalRead(PinOffButton) == HIGH) {
PressureReading = analogRead(PressureInputPin);
Serial.print("Pressure=");
Serial.prinltn(PressureReading);
}
Serial.println("BUTTON WAS PUSHED!");
noTone(PinBeeper);
}
This uses the do{}while(); loop, which is not very common in C code. It's necessary to be able to measure the pressure before testing it in the while condition.
wow this forum is the bomb. Will try the code thanks for the specifications .
Would I use a piezo buzzer or do you all have a favorite noise maker for the Arduino?
I was thinking of using a mini breadboard and an Arduino Trinket if possible.
For the buzzer, whatever Adafruit or Sparkfun sells is usually good enough.
The Trinket does not seem appropriate due to the lack of serial. If you have another Arduino to do the initial calibration of PressureThreshold then you could use a Trinket.