[help] arduino uno with 3 water level connect to GSM

hello and hi..

im student and still new in using arduino and gsm.

my project is, using arduino to measure 3 level of water, which is low, medium and high, and each level will display with
LED.

than each level will be sent to GSM to sending sms to the mobile phone..

anyone have ideal??

i already build 1 circuit water level at the board. but i think it more easier and look more simple if i using arduino

anyone have code and connection arduino to gsm?? =( =(

Uploaded with ImageShack.us

this is my coding for 3 level of water detector.. but, how to connect to GSM?

Please, spend some time reading this http://arduino.cc/forum/index.php/topic,148850.0.html, especially on how to properly post your code. Then use the search function of this forum to look for posts about GSM. You will find plenty.

// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

const int buttonPin1 = 3;
const int ledPin1 =12;

const int buttonPin2 = 4;
const int ledPin2 = 11;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int buttonState1 = 0;
int buttonState2 = 0;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);  
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT); 
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);  
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);


  if (buttonState == HIGH) {digitalWrite(ledPin, HIGH);  
  } 
  else {digitalWrite(ledPin, LOW); 
  }                                  // low level
  
  if(buttonState1 == HIGH) {digitalWrite(ledPin1, HIGH);
  }
  
  else{digitalWrite(ledPin1, LOW);
  }                                  //medium level

  if(buttonState2 == HIGH) {digitalWrite(ledPin2, HIGH);
  }
  
  else{digitalWrite(ledPin2, LOW);
  }                                //High level
}

Hi, thanks for following the advice about posting your code.

As it is, it is way too simple to send text messages. Note that loop() is repeated forever, and you may have thousands of repetitions each second. Now consider this:

  • buttonState read HIGH, you send a message.
  • at the next repetition of loop, buttonState is still HIGH; do you want to send another message?

And the same for the other buttons.

You need to refine your logic: since we are dealing with water levels, I assume you have three buttons at different levels, so if button 3 is high we should have buttons 2 and 1 high as well. You don't need to check for them. But you need to keep track of the highest state read by your buttons, so if the state gets higher than in the previous loop you may send a message, but if the state remains the same you do nothing. You may also want to send a message if the state falls below 1 (no button pressed). As for the middle level, you probably don't want to do anything because it should be the normal position.