a simple question for some.
i need both things to becorrect using and..
What have I messed up with my "and"?if((rdsBuffer[0] =='\0')+(smsmuteState == LOW));
thanks
a simple question for some.
i need both things to becorrect using and..
What have I messed up with my "and"?if((rdsBuffer[0] =='\0')+(smsmuteState == LOW));
thanks
What have I messed up with my "and"?
Plus is NOT and. && is.
If statements rarely end with semicolons.
Hackdub:
a simple question for some.i need both things to becorrect using and..
What have I messed up with my "and"?if((rdsBuffer[0] =='\0')+(smsmuteState == LOW));
thanks
if ((rdsBuffer[0] =='\0') && (smsmuteState == LOW))
{
//insert code
}
Like that?
bingo... thanks
I want my GSM module not to text if "sms mute state" is HIGH, but it still sends sms does...
I have checked "smsmuteState" and it is definately hi, as the LCD displayes correctly "SMS Mute"
Have I got the %% correct?
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW));
{
sms.beginSMS("0xxx66404142");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("myemail\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("SMS SENT OK");
delay(5000);
lcd.clear();
}
if (smsmuteState == HIGH);
lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();
}
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW));
What was said about Mr. if and Mr Semicolon not being friends?
tx
nope still texting although that input is hi
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
{
sms.beginSMS("0xxxx6404142");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("xxxxxxx\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("SMS SENT OK");
delay(5000);
lcd.clear();
}
if (smsmuteState == HIGH);
lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();
}
}
if (smsmuteState == HIGH);
See my earlier reply.
May need braces too.
nope still texting although that input is hi
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
{
sms.beginSMS("0xxxx6404142");
I wonder why?
You are not testing for HIGH!
Confused.. what you mean?
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
{
sms.beginSMS("0xxxxxxxx142");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("mrdxxxxxxxin\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("SMS SENT OK");
delay(5000);
lcd.clear();
}
if (smsmuteState == HIGH)
lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();
}
}
I have pulled that pin hi, and im looking for a low to text?
smsmute pin
I have pulled that pin hi,
That pin? What does that mean? Use names that reflect what you are using in the code.
I've pulled smsmutePin High
full code
// libraries
#include <GSM.h>
#include <LiquidCrystal.h>
#include <Si4703_Breakout.h>
#include <Wire.h>
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess; // include a 'true' parameter to enable debugging
GSM_SMS sms;
GSMScanner scannerNetworks;
GSMModem modemTest;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 9, 8);
// This section descibes button connection.
const int buttonPin = A0;
const int upbuttPin = A2;
const int downbuttPin = A3;
const int selectPin = A1;
const int smsmutePin = 6;
//radio connection
int resetPin = 10;
int SDIO = A4;
int SCLK = A5;
///////////freq map
int Freq[][5] ={
{
995, 899 , 921, 943, 0 }//WV
,
{895 , 917, 939, 964, 0 }};//kvh
const int NUM_FREQS = sizeof Freq[0]/sizeof Freq[0][0];
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int upbuttState = 0; // variable for reading the pushbutton status
int downbuttState = 0;
int selectbuttState = 0;
int smsmuteState = 0;
int select = 0;
Si4703_Breakout radio(resetPin, SDIO, SCLK);
int channel;
int volume;
char rdsBuffer[20];
// Save data variables
String IMEI = "";
// serial monitor result messages
String errortext = "ERROR";
/// NAME INDEX
char * Names[] = {
"Wenvoe ", "Kilvey Hill "};
const int NAME_COUNT = sizeof Names / sizeof Names[0];
int NameIndex = 0;
void setup()
{
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
pinMode(upbuttPin, INPUT);
pinMode(downbuttPin, INPUT);
pinMode(selectPin, INPUT);
pinMode(smsmutePin, INPUT);
// pinMode(ledPin, OUTPUT);
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
{
radio.powerOn();
radio.setVolume(0);
}
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("FM Rover by DM");
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("--Please Wait--");
lcd.setCursor(0, 1);
lcd.print("-GSM Connecting-");
// Serial.println("GSM networks scanner");
scannerNetworks.begin();
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
{
notConnected = false;
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Connected");
delay(2000);
lcd.clear();
}
else
{
Serial.println("Not connected");
lcd.setCursor(0, 1);
lcd.clear();
lcd.print("NO GSM !");
delay(1000);
}
}
// get modem parameters
// IMEI, modem unique identifier
// Serial.print("Modem IMEI: ");
IMEI = modemTest.getIMEI();
IMEI.replace("\n","");
if(IMEI != NULL);
// Serial.println(IMEI);
///////////////// SELECT SITE NAME //////////////////////
while(select==0){
// read the state of the pushbutton value:
upbuttState = digitalRead(upbuttPin);
downbuttState = digitalRead(downbuttPin);
selectbuttState = digitalRead(selectPin);
smsmuteState = digitalRead(smsmutePin);
// if it is, the upbuttState is HIGH:
if (upbuttState == HIGH) {
// increment name
NameIndex = (NameIndex+1)%NAME_COUNT;
} // Wrap around
//if it is, the upbuttState is HIGH:
if (downbuttState == HIGH) {
// increment name
NameIndex = (NameIndex-1)%NAME_COUNT;
if (NameIndex < 0) {
NameIndex=NAME_COUNT-1;
}
} // Wrap around
if (selectbuttState == HIGH){
select=1;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("> ");
lcd.setCursor(2,0);
lcd.print (Names[NameIndex]);
lcd.setCursor(0,1);
lcd.print("Select Location ");
delay(500);
lcd.clear();
}
}
void loop()
{
{
volume --;
if (volume < 0) volume = 15;
radio.setVolume(volume);
displayInfo();
for(int i=0; i<NUM_FREQS; i++) {
channel=Freq[NameIndex][i];
if (channel != 0) {
//channel = 995; // Radio 1
radio.setChannel(channel);
displayInfo();
radio.readRDS(rdsBuffer, 10000);
//lcd.clear();
lcd.setCursor(0, 0);
lcd.print(rdsBuffer);
delay(5000);
lcd.setCursor(0, 1);
lcd.print(Names[NameIndex]);
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
{
sms.beginSMS("0xxxxxx142");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("xxxxxxxxx\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("SMS SENT OK");
delay(5000);
lcd.clear();
}
if (smsmuteState == HIGH)
lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();
}
}
}
}
void displayInfo()
{
//////////////////DISPLAY GSM INFO ON LCD ///////////////
// currently connected carrier
// Serial.print("Current carrier: ");
// Serial.println(scannerNetworks.getCurrentCarrier());
//lcd.clear();
lcd.setCursor(0, 1);
// Print a message to the LCD.
lcd.print(scannerNetworks.getCurrentCarrier());
// returns strength and ber
// signal strength in 0-31 scale. 31 means power > 51dBm
// // BER is the Bit Error Rate. 0-7 scale. 99=not detectable
// Serial.print("Signal Strength: ");
// Serial.print(scannerNetworks.getSignalStrength());
// Serial.println(" [0-31]");
// set up the LCD's number of columns and rows:
lcd.setCursor(15, 1);
lcd.print("%");
lcd.setCursor(13, 1);
lcd.print(scannerNetworks.getSignalStrength().toInt() * 100 / 32);
}
if(IMEI != NULL);
What was the purpose of that?
if (smsmuteState == HIGH)
lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();
Are you hoping those 4 lines are controlled by the "if"? The indentation says "yes" but the code says "no".
I've pulled smsmutePin High
And you test to see that it is LOW:
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
If it is:
sms.beginSMS("0xxxxxx142");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("xxxxxxxxx\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
Now, I could be wrong, but that looks like code to send an SMS when smsmuteState is LOW (not HIGH).
Exactly I dont want it to send sms when the pin is high..
if((rdsBuffer[0] =='\0')&&(smsmuteState == LOW))
{
sms.beginSMS("077xxxx42");
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SITE FAULT ! ");
delay(1000);
lcd.clear();
lcd.print("SMS SENDING");
sms.print("xxxxxxn\xFEgmail.com ");
sms.print(Names[NameIndex]);
sms.print(" ");
sms.print(channel);
sms.print(" SHUT DOWN");
sms.endSMS();
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("SMS SENT OK");
delay(5000);
lcd.clear();
}
if (smsmuteState == HIGH)
{lcd.setCursor(0, 1);
lcd.print("SMS MUTE!");
delay(5000);
lcd.clear();}
}
Exactly I dont want it to send sms when the pin is high..
And, it doesn't. So, what is the problem?
well pin6 smsmutePin is currently held high, & it still sends SMS!
well pin6 smsmutePin is currently held high, & it still sends SMS!
Where do you actually read the state of the pin? In setup()! Try actually reading it in loop().
AHH DOH
thanks, still learning.
Take care David