Arduino GSM Shield

Hey guys I am trying to get some help with my code. I have build a project which is a water level control. I am using an arduino water sensor which will measure the water as it raises. I have three stages, the 1st stage will turn a GREEN led on and will play a tone, also a text message will be send. 2nd stage will turn on a YELLOW led on and play a different tone. 3rd a RED led will be turn as well as a relay which will turn on a water pump. If the water decrease then the LEDS start turning off but the water pump will be on until the YELLOW led turn off. This part I describe is working fine. The problem I had was trying to send a second text message after the 3rd (RED) leds turns on. I wrote the same piece of code I used to send the 1st text but the program didn’t run as expected. If I put the texting code for the 3rd stage then when the RED led come on it stays on as well as the pump even though I put the sensor out of the water and I don’t receive the text. CAN ANYONE HELP?

sketch_jan28a.ino (2.28 KB)


Frequency of what? What the hell does flag mean?


Perhaps you ought to look at the range of value that an int can hold!

What do your serial prints tell you is happening?

the flag is calling the action of the speaker at the end
for(int i=0;i<100;i++){

also freq=50000; is the tone being play.

also freq=50000; is the tone being play.

An int, which is what you are using, can hold a value between -32768 and +32767. No matter how much you wish it would, 50000 will NOT fit in an int.