/-----( Loop function )-----/
void loop() {
boolean run_cycle = true;
const int lowerSersor = digitalRead(8); // lower float sensor on digital pin 8
if (lowerSersor == LOW) { // float sensor has dropped down - tank empty
// Toggle on
if (run_cycle) {
sendSMS();
run_cycle = false;
}
}
if (lowerSensor == HIGH) { // tank now full
// Toggle off
if (run_cycle == false) {
run_cycle = true;
}
}
}
void sendSMS() {
// Some code here to send a sms
Serial.println("AT");
delay(1000);
Serial.println("AT+CMGF=1"); // send SMS in text mode
delay(1000);
Serial.println("AT+CMGS="+01XXXX""); //CHANGE TO Number , you'd like to receive message
delay(1000);
Serial.print("Water level is low in underground tank (attention required)"); // content of the message
Serial.write(26); // ctrl+z ASCII code
}
when i copy past the code to UNO it give me following error
Arduino: 1.8.4 (Mac OS X), Board: "Arduino/Genuino Uno"
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void loop()':
F1ILXY7IDIN9JKB:15: error: 'sendSMS' was not declared in this scope
sendSMS();
^
F1ILXY7IDIN9JKB:19: error: 'lowerSensor' was not declared in this scope
if (lowerSensor == HIGH) { // tank now full
^
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void setup()':
F1ILXY7IDIN9JKB:33: error: redefinition of 'void setup()'
void setup()
^
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino:2:6: note: 'void setup()' previously defined here
void setup() {
^
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino: In function 'void loop()':
F1ILXY7IDIN9JKB:41: error: redefinition of 'void loop()'
void loop()
^
/Users/Omair/Downloads/F1ILXY7IDIN9JKB/F1ILXY7IDIN9JKB.ino:8:6: note: 'void loop()' previously defined here
void loop() {
^
exit status 1
'sendSMS' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Hi,
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Hello... Need some help Getting error message when verifying the code.
Error message attached as attachment.
/*-----( Setup function )-----*/
void setup() {
Serial.begin(9600);
pinMode(8, INPUT_PULLUP);
}
/*-----( Loop function )-----*/
void loop() {
boolean run_cycle = true;
const int lowerSersor = digitalRead(8); // lower float sensor on digital pin 8
if (lowerSersor == LOW) { // float sensor has dropped down - tank empty
// Toggle on
if (run_cycle) {
sendSMS();
run_cycle = false;
}
}
if (lowerSensor == HIGH) { // tank now full
// Toggle off
if (run_cycle == false) {
run_cycle = true;
}
}
}
//ERFINDER CODE
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available()>0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+923400008550\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS
delay(1000);
}