trying to teach myself functions.

can someone walk me through where Im missing how to break out of the loop?

I wanted to write a simple function to blink the LED at either a fast rate or a slow rate but im missing how to exit out of the loop…

bool    sHasLooped  = false;
bool    fHasLooped  = false;

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
Serial.println(" Start Fast Blink");
Serial.println();  
FastBlink();
Serial.println("Fast Blink Done");
Serial.println(); 
Serial.println("Start Slow Blink");
Serial.println();
SlowBlink();
Serial.println("Slow Blink DOne");
Serial.println();
digitalWrite(LED_BUILTIN, LOW);
}

void SlowBlink(){
     if ( sHasLooped == false )
   {
       for ( int x = 0; x < 10; x++ )
       {
          digitalWrite(LED_BUILTIN, HIGH);   // Turn the LED on (Note that LOW is the voltage level
          delay(500);                      // Wait for a second
          digitalWrite(LED_BUILTIN, LOW);  // Turn the LED off by making the voltage HIGH
          delay(500); 
      sHasLooped = true; 
      break;        
       }
   }
} 
void FastBlink(){
     if ( fHasLooped == false )
   {
       for ( int x = 0; x < 10; x++ )
       {
          digitalWrite(LED_BUILTIN, HIGH);   // Turn the LED on (Note that LOW is the voltage level
          delay(150);                      // Wait for a second
          digitalWrite(LED_BUILTIN, LOW);  // Turn the LED off by making the voltage HIGH
          delay(150); 
      fHasLooped = true;
      break;         
       }
   }
}

im missing how to exit out of the loop

Unclear what you mean.

Please describe what you really want to do.

   for ( int x = 0; x < 10; x++ )
    {
      digitalWrite(LED_BUILTIN, HIGH);   // Turn the LED on (Note that LOW is the voltage level
      delay(500);                      // Wait for a second
      digitalWrite(LED_BUILTIN, LOW);  // Turn the LED off by making the voltage HIGH
      delay(500);
      sHasLooped = true;
      break;
    }

Let’s pretend for now that there are no other problems
It looks like you want to do something 10 times. If that is the case then why break out of the for loop unconditionally as you do ?

Hi Bob, Im just banging around trying to figure things out... programming clearly is not my strong-suite :) I included the break just to test to see what it does... i have been through several iterations moving, adding, and deleting various bits of code to see how it affects the device. Im trying to understand where I'm screwing things up.

I just got a few WeMOS boards and some PIR sensors and have got them up and running, able to connect to the WiFi and send a push message when the PIR triggers… what I am trying to do is fast blink the LED when the push message data is being sent… and in the process teach myself a little more coding.

here is what I have so far:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>

int led = LED_BUILTIN;                // the pin that the LED is atteched to
int sensor = 4;              // the pin that the sensor is atteched to
int state = LOW;             // by default, no motion detected
int val = 0;                 // variable to store the sensor status (value)

char APIKEY[] = "#######################"; // API key
char CHANNEL[] = "#########";                               // channel name

char serverName[] = "api.pushetta.com";
boolean lastConnected = false;

int status = WL_IDLE_STATUS;
const char* ssid = "#######";  //  your network SSID (name)
const char* pass = "##################";   // your network password

IPAddress ipMulti (192, 168, 1, 169);   // IP of Wemos D1 Device you want

void setup() {
  WiFiClient client;   // turn on wifi client mode
  pinMode(led, OUTPUT);      // initalize LED as an output
  pinMode(sensor, INPUT);    // initialize sensor as an input
  Serial.begin(115200);   // start serial connection
  WiFi.begin(ssid, pass);  // setting up Station AP

  // Wait for connect to AP
  Serial.print("[Connecting]");
  Serial.print(ssid);
  int tries = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    tries++;
    if (tries > 30) {
      break;
    }
  }
  Serial.println("Connected to wifi");

}

void loop()
{

  Serial.println("Connecting to Pushetta");
  WiFiClient client;  // Use WiFiClient class to create TCP connections
  const int httpPort = 80;
  if (!client.connect("api.pushetta.com", httpPort)) {
    Serial.println("Connection failed");
    return;
  }
  val = digitalRead(sensor);   // read sensor value
    if (val == HIGH) {           // check if the sensor is HIGH
      digitalWrite(led, HIGH);   // turn LED ON
      sendToPushetta(CHANNEL, "WeMOS Motion!");
      delay(2000);
    FastBlink();
    delay(10000);                

       if (state == LOW) {
      Serial.println("No Motion Detected"); 
      state = HIGH;       // update variable state to HIGH
        }  
    }  
}

//Function for sending the request to Pushetta
void sendToPushetta(char channel[], String text) {
  WiFiClient client;
  client.stop();

  if (client.connect(serverName, 80))
  {
    client.print("POST /api/pushes/");
    client.print(channel);
    client.println("/ HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.print("Authorization: Token ");
    client.println(APIKEY);
    client.println("Content-Type: application/json");
    client.print("Content-Length: ");
    client.println(text.length() + 46);
    client.println();
    client.print("{ \"body\" : \"");
    client.print(text);
    client.println("\", \"message_type\" : \"text/plain\" }");
    client.println();
  }
}

//Function for FAST blinking LED 
void FastBlink() {
  Serial.print("Blink");
  digitalWrite(LED_BUILTIN, HIGH);   // Turn the LED on (Note that LOW is the voltage level
  delay(150);                      
  digitalWrite(LED_BUILTIN, LOW);  // Turn the LED off by making the voltage HIGH
  delay(150);                      
}

I suggest if you want to have a blinking LED light WHILST sending you have to look into Photothreading and blink without delay. It can get a little complicated. Remember that everything in arduino is sequential and you cannot run more than 1 thing at a time. Photothreading makes it seem like that is happening.

if you want to learn: here

I suggest that you have the LED on when sending a message and turn it off when the message has been sent.

The keyword "break;" will exit the loop when it is run.

Most people will have some condition to break. so if(something) {break;}

Otherwise you are just breaking out of the loop on it's first run

what I am trying to do is fast blink the LED when the push message data is being sent

OK, but you need to understand why this

    digitalWrite(led, HIGH);   // turn LED ON
    sendToPushetta(CHANNEL, "WeMOS Motion!");
    delay(2000);
    FastBlink();
    delay(10000);

Is not likely to work because the delay() function causes the program to freeze for the delay period. Are you expecting/wanting the LED to blink for a period of time when the FastBlink() function is called or are you happy that it turns the LED on and off once.

Incidentally, you may want to review the comments and.or the code in the FastBlink() function because the code does not match the comments.

Im trying to understand where I'm screwing things up.

If you have car problems, do you send your wife/girlfriend/whatever out to start the car, while you hide in the bathroom, and then wonder why you can't hear what's wrong with the car?

Use Serial.print() statements, so you can hear what's wrong with your car.