hi all
I wanted to make something using the Arduino Uno and a parallax ultrasonic sensors and also with icomsat sim900 gsm / gprs shield. I wanted at a distance above 100 centimeters will send a message to the phone and at a distance of less than 5 centimeters will also send a message. I've made ??the code but it will send the message continuously. if anyone wants to help me for making the program I will be grateful
some code previews would be helpful.
ali007:
but it will send the message continuously.
This part confuses me. Please elaborate? Is this part of the issue you need help with??
And that distance of 5 or 100 centimeters is from what? The floor? Your phone? Some other object?
Are you only interested in sending messages when the sensor is at exactly 5 or 100 centimeters from some object?
Is there any tolerance in that measurement (eg. ±0.1cm)?
ali007:
if anyone wants to help me for making the program I will be grateful
I'm sure there are plenty of people here who would be glad to assist. but a bit more information is needed.
Good luck!
This sensor will measure the height of the water , if the water level of 100 centimeters above the shield will send the message " safe water level " message will be received by the phone , but if the water level is less than 5 centimeters shield will then send the message " height of the water hazard " . position sensor is on top of a water tank .
I have a code like this , but it still seems wrong
include " SIM900.h "
include <NewPing.h>
include <SoftwareSerial.h>
include " sms.h "
SMSGSM sms ;
const int pinping = 10 ;
led1 int = 7 ;
int numdata ;
boolean started = false ;
void setup ( )
{
Serial.begin ( 9600 ) ;
Serial.println ( " GSM Shield testing . " ) ;
if ( gsm.begin ( 2400 ) ) {
Serial.println ( " \ nstatus = READY " ) ;
started = true ;
} Else Serial.println ( " \ nstatus = IDLE " ) ;
if ( started ) {
}
} ;
void loop ( )
{
long duration , cm ;
pinMode ( 10 , OUTPUT ) ;
digitalWrite ( 10 , LOW ) ;
delayMicroseconds ( 2 ) ;
digitalWrite ( 10 , HIGH ) ;
delayMicroseconds ( 5 ) ;
digitalWrite ( 10 , LOW ) ;
pinMode ( 10 , INPUT ) ;
pinMode ( led1 , OUTPUT ) ;
duration = pulseIn ( 10 , HIGH ) ;
cm = microsecondsToCentimeters ( duration ) ;
Serial.print ( " Altitude Trash : " ) ;
Serial.print ( cm ) ;
Serial.println ( ) ;
delay (1000 ) ;
if ( cm < 5 )
{
digitalWrite ( LED1 , HIGH ) ; }
{
if ( sms.SendSMS ( " +6285642717909 " , " full of garbage " ) )
Serial.println ( " \ nSMS sent OK " ) ;
}
if ( cm > = 100 )
{
digitalWrite ( led1 , LOW ) ;
}
if ( sms.SendSMS ( " +6285642717909 " , " Trash empty " ) )
Serial.println ( " \ nSMS sent OK " ) ;
}
microsecondsToInches long (long microseconds )
{
return microseconds / 74/2 ;
}
microsecondsToCentimeters long (long microseconds )
{
return microseconds / 29/2 ;
}
I have a code like this , but it still seems wrong
It won't even compile, so it IS wrong. The else statement doesn't start with E.