I'm a Newbie with this and trying to understand what im doing wrong. I'm trying to get this code to send the "SMS" only when the SoundDetector senses sound and becomes High. Right now when the Board iniationally powered up, it sends the sms. But i want it to remain connected to the internet at all times and send a sms Only when SoundDection is High. Anyone with the skills of helping me plug in the correct changes? Thanks in advance.

#include <ESP8266WiFi.h>

int ledPin = 4; // Turns on when soundDetection sensor detects sound and become High
int soundDetection = 5;  // When pressed inPin 5 becomes High and turns on LED and initiates MakerIFTTT to send sms
int val = 0;
int soundDetectionStat;
int DigitalRead = 0;
int makerifttt = val;

WiFiClient client;

String MakerIFTTT_Key ;
;String MakerIFTTT_Event;
char *append_str(char *here, String s) {  int i=0; while (*here++ = s[i]){i++;};return here-1;}
char *append_ul(char *here, unsigned long u) { char buf[20]; return append_str(here, ultoa(u, buf, 10));}
char post_rqst[256];char *p;char *content_length_here;char *json_start;int compi;

void setup()
   WiFi.begin("NSA SURVEILLANCE TEAM","????????");
  while ((!(WiFi.status() == WL_CONNECTED))){

  Serial.println("Your IP Is");
  pinMode(ledPin, OUTPUT);
  pinMode(soundDetection, INPUT);
if   (digitalRead, HIGH)(client.connect("maker.ifttt.com",80)); {
    MakerIFTTT_Key ="??????????????????????";
    MakerIFTTT_Event ="SMS";
    p = post_rqst;
    p = append_str(p, "POST /trigger/");
    p = append_str(p, MakerIFTTT_Event);
    p = append_str(p, "/with/key/");
    p = append_str(p, MakerIFTTT_Key);
    p = append_str(p, " HTTP/1.1\r\n");
    p = append_str(p, "Host: maker.ifttt.com\r\n");
    p = append_str(p, "Content-Type: application/json\r\n");
    p = append_str(p, "Content-Length: ");
    content_length_here = p;
    p = append_str(p, "NN\r\n");
    p = append_str(p, "\r\n");
    json_start = p;
    p = append_str(p, "{\"value1\":\"");
    p = append_str(p, "???????????");
    p = append_str(p, "\",\"value2\":\"");
    p = append_str(p, "ALARM_SOUNDING");
    p = append_str(p, "\",\"value3\":\"");
    p = append_str(p, "");
    p = append_str(p, "\"}");

    compi= strlen(json_start);
    content_length_here[0] = '0' + (compi/10);
    content_length_here[1] = '0' + (compi%10);



void loop()
  val = digitalRead(soundDetection);
  digitalWrite(ledPin, val);
  Serial.println(soundDetection, val);


put on hold as off-topic by Juraj, sempaiscuba, MatsK, gre_gor, Greenonline yesterday

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Arduino, within the scope defined in the help center." – Juraj, sempaiscuba, MatsK, Greenonline
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Thanks Jsotola,, is there and specific spot in the code that you see that need those. Again forgive me if it sounds like a a stupid question. I'm new at all this but trying to learn. – icooperjr Feb 11 at 17:37
  • 1
    take a coding course to learn the basics – Juraj Feb 11 at 18:15
  • Thanks. Most definitely. I’m already in the process of trying to take up one. – icooperjr Feb 11 at 20:02