Go Down

Topic: simple boolean question (Read 5894 times) previous topic - next topic


I'm sure this is simple...but I'm so bad at math and logic and I can't figure it out and I can't seem to find the problem anywhere else in the forums.

I just want a potentiometer to make a few bleeps on each turn and then stop. So for example, if the potentiometer is between 0-400, I want it to make three tones and stop. If it's any other number, I don't want it to do anything.
Very, very simple, no? I just can't figure it out. What am I don't wrong?

Here is my code:

Code: [Select]

boolean no_sound;

void setup() {

void loop() {
 int pot = analogRead(0);
 if ((pot > 0) && (pot < 400) && (no_sound=true)) {
   tone (28, 1999, 400);
   tone (28, 500, 800);
   tone (28, 3000, 200);
 }else {


Jan 23, 2011, 09:42 pm Last Edit: Jan 23, 2011, 11:39 pm by mmcp42 Reason: 1
sets no_sound to true

tests to see if it is true :)
there are only 10 types of people
them that understands binary
and them that doesn't

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131