Tilt Sensor & Buzzer: Varying Angle

I have currently a working tilt-sensor, piezo circuit, in which that when the tilt sensor is tilted, the piezo alarms, creating a constant noise.

However, the buzzer only alarms when the tilt sensor surpasses angles greater than 90 degrees, which for my particular project, is too large; how can I vary the angle limit, more specifically, i'd like to change the angle to anything greater than 25 degrees.

Here is the code

int inPin = 2; // the number of the input pin
int reading; // the current reading from the input pin
int GreenLedPin = 13; // the number of the Green LED output pin
int RedLedPin = 12; // the number of the Red LED output pin
const int SpeakerPin = 11; // the number of the Speaker/Buzzer pin

void setup(){
pinMode (inPin, INPUT);
pinMode (GreenLedPin, OUTPUT);
pinMode (RedLedPin, OUTPUT);
Serial.begin(9600);
}

void loop () {
reading = digitalRead(inPin);
if (reading == 1) {
digitalWrite(RedLedPin, HIGH); // if tilted, turn the red LED ON
digitalWrite(GreenLedPin, LOW);
tone(SpeakerPin, 494, 500); // if tilted, turn the Speaker ON
delay(500);

} else {
digitalWrite(RedLedPin, LOW);
digitalWrite(GreenLedPin, HIGH); // if not tilted, turn the green LED ON
}
Serial.println(reading); // not really needed

delay(200); // pause 200 milliseconds between readings
}

note: i also have an LED system, however that isn't important for this question

Thanks!

My simple mind would say mount the tilt switch on some adjustable mechanical thingie. Maybe hot glue it to the edge of a fender washer then adjust the angle by rotating the washer and tightening it with a screw. :grinning:

Delta_G:
What type of tilt sensor do you have? Common sense would seem to dictate that it would be a good idea to tell us what you have if you want someone to be able to tell you how to use it. Nothing in your code indicates the reading of an angle so I'm left thinking that the angle may not be something you can change. It may just be part of how your tilt sensor works.

The normal tilt sensor provided in the Arduino Starter kit

Delta_G:
There are lots of starter kits and I've never bought one. I guess if you can't be more specific then you can wait until someone who can identify your switch by that description comes along. Best of luck to you.

I really don't like the way you articulate yourself and speak to me in such patronising manner, "I guess if you can't be more specific", "common sense would seem to dictate..." What's wrong with you?

What's wrong with you?

Delta_G objects to the fact that given your pathetic description of the problem, you still expect people to be able to help and even get indignant when they suggest you could improve your communications skills.

i'd like to change the angle to anything greater than 25 degrees.

There is NOTHING in your code, or your post, about a sensor that can measure an angle.

Please read the "How to use this forum" post and follow the directions. Use code tags when posting code.

jremington:
Delta_G objects to the fact that given your pathetic description of the problem, you still expect people to be able to help and even get indignant when they suggest you could improve your communications skills.
There is NOTHING in your code, or your post, about a sensor that can measure an angle.

Please read the "How to use this forum" post and follow the directions. Use code tags when posting code.

Okay my apologies for coming to the forums for help, one could simply ask me to elaborate more, or ask me to explain and give certain information; instead of acting as if you know everything and patronising another member on the site.

My fault for expecting a more friendly atmosphere on an Arduino forum loooooool

Delta_G:
You came in here, thumbed your nose at the rules, expected folks to just magically read your mind, and now you're mad because it wasn't friendly enough for you?

Yes I said "common sense would dictate" because that really is the case. I think any idiot should be able to know that in order for someone to tell you how to use a thing they'd need to know what the thing is. If that concept really is over your head then coding probably isn't for you. This is a thinking mans game.

So it looks to me like you either really don't understand that and are therefore the biggest idiot I've met, OR you just didn't put much thought into your request. And I think showing up here and thumbing your nose at the rules, expecting someone to read your m ind for you, and just generally refusing to put in any effort on the subject make you the one who is being unfriendly.

looool and calling me an idiot frequently makes you the friendly one. I'm not even gonna respond to that because I really don't need to justify my knowledge to you
You must be really bitter inside to get worked up over something like this; sorry if my description was too vague for you, really didn't mean to cause so much stress to you loooool.
I'm genuinely sorry for you.

Delta_G:
Where did I call you an idiot? I said if you can't understand that someone can't tell you how to use a mystery object then you are. Is that really something that is over your head? If so, coding is going to be WAY beyond your abilities.

You haven't caused me any stress. I was trying to get you to tell more about this senor so I could help you. I don't personally care if you get it going or not. It's no stress in my life. I was just trying to help you. If you're more worried about perceived personal respects or slights on internet forums then the programming crowd is probably not for you. We tend to be much more logically minded, not so emotional.

lool how old are you? be honest

Delta_G:
What does lool mean? I see you using that word with varying numbers of o's in it. If English isn't your native tongue, there are sections of the forum for all sorts of other languages. Perhaps there is one where you might be better understood.

Are you done with trying to fix your project? I'm not interested in playing any of these other games about age or whatever with you. There are others here who are actually wanting to learn how to write code and make an Arduino do cool things (and incidentally don't mind adding a little thought before they post and don't get all butthurt if you point out a mistake they made but I digress) and I'd rather spend my time helping them.

loooooooooool
Wow
Yeah you got me, English isn't my native tongue.
Loool you're a joke.

I guess we're never going to discuss the problem so I'm unsubscribing from this thread.