Pages: [1]   Go Down
Author Topic: simple boolean question  (Read 3897 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
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:
boolean no_sound;

void setup() {
  no_sound=true;
}

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

Leighton Buzzard, UK
Offline Offline
Edison Member
*
Karma: 20
Posts: 1318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(no_sound=true)
sets no_sound to true

(no_sound==true)
tests to see if it is true smiley
« Last Edit: January 23, 2011, 05:39:25 pm by mmcp42 » Logged

there are only 10 types of people
them that understands binary
and them that doesn't

Pages: [1]   Go Up
Jump to: