message:
Compile Problem with RFDuino RFD22301

I have the following setup:
- Arduino IDE for Mac 1.8.5
- RFDuino RFD220301
- CP2102 USB to UART connector
- Board set to "RFduino"
- port set correctly (but shouldn't matter as it is a compile error)
- Programmer: AVRISP mkII

When trying to compile an example script using BLE (Such as AdvertisementContinuous) I get the following error

arm-none-eabi-g++: error: /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_188605/core/syscalls.c.o: No such file or directory

Any ideas?

Here's the -v log:

    Arduino: 1.8.5 (Mac OS X), Board: "RFduino"

    /Applications/Arduino.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/julian/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/julian/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/julian/Documents/Arduino/libraries -fqbn=RFduino:RFduino:RFduino -ide-version=10805 -build-path /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200 -warnings=none -build-cache /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_cache_722169 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /Users/julian/Code/openSleep/embedded/sleepduino/sleepduino.ino
    /Applications/Arduino.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino.app/Contents/Java/hardware -hardware /Users/julian/Library/Arduino15/packages -tools /Applications/Arduino.app/Contents/Java/tools-builder -tools /Applications/Arduino.app/Contents/Java/hardware/tools/avr -tools /Users/julian/Library/Arduino15/packages -built-in-libraries /Applications/Arduino.app/Contents/Java/libraries -libraries /Users/julian/Documents/Arduino/libraries -fqbn=RFduino:RFduino:RFduino -ide-version=10805 -build-path /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200 -warnings=none -build-cache /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_cache_722169 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /Users/julian/Code/openSleep/embedded/sleepduino/sleepduino.ino
    Using board 'RFduino' from platform in folder: /Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3
    Using core 'arduino' from platform in folder: /Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3
    Detecting libraries used...
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin  -w -x c++ -E -CC -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp" -o "/dev/null"
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin  -w -x c++ -E -CC -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp" -o "/dev/null"
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin  -w -x c++ -E -CC -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE/RFduinoBLE.cpp" -o "/dev/null"
    Generating function prototypes...
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin  -w -x c++ -E -CC -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp" -o "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/preproc/ctags_target_for_gcc_minus_e.cpp"
    "/Applications/Arduino.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/preproc/ctags_target_for_gcc_minus_e.cpp"
    Compiling sketch...
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -MMD -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp" -o "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp.o"
    Compiling libraries...
    Compiling library "RFduinoBLE"
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -MMD -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE/RFduinoBLE.cpp" -o "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/libraries/RFduinoBLE/RFduinoBLE.cpp.o"
    Compiling core...
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -MMD -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=10805 -mthumb -D__RFduino__ "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/cores/arduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/RFduino/include" "-I/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/system/CMSIS/CMSIS/Include" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/variant.cpp" -o "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/core/variant.cpp.o"
    Using precompiled core
    Linking everything together...
    "/Users/julian/Library/Arduino15/packages/RFduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++" -Wl,--gc-sections --specs=nano.specs -mcpu=cortex-m0 -mthumb -D__RFduino__ "-T/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/linker_scripts/gcc/RFduino.ld" "-Wl,-Map,/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sleepduino.ino.map" -Wl,--cref -o "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sleepduino.ino.elf" "-L/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200" -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/core/syscalls.c.o" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/sketch/sleepduino.ino.cpp.o" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/libraries/RFduinoBLE/RFduinoBLE.cpp.o" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/core/variant.cpp.o" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/libRFduinoSystem.a" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/libRFduino.a" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/libRFduinoBLE.a" "/Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/variants/RFduino/libRFduinoGZLL.a" "/var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/../arduino_cache_722169/core/core_RFduino_RFduino_RFduino_96c93913732efe419124a59ff97a44c7.a" -Wl,--end-group
    arm-none-eabi-g++: error: /var/folders/m6/mfwpb8b13wn4f9fvb4lhx_v40000gp/T/arduino_build_997200/core/syscalls.c.o: No such file or directory
    Using library RFduinoBLE in folder: /Users/julian/Library/Arduino15/packages/RFduino/hardware/RFduino/2.3.3/libraries/RFduinoBLE (legacy)
    exit status 1
    Error compiling for board RFduino.

body: So it appears solved: Using Arduino 1.6.13 I don't get the compile error. Must be an incompatibility with the RFduino Board libraries and the 1.8x IDE.


sender: user

message:
GSM cannot read SMS when Arduino is not reset for the first time after it is powered

I'm using a GSM Module with Arduino along with Node MCU. I have a supply of 9V, 2A in the DC jack of the Arduino and the GSM Shield. The Node MCU is powered from the 3.3V of the Arduino. I can receive messages fine in the GSM when the USB port of the Arduino (including the power supply I mentioned earlier) is connected to the laptop through and monitored using the serial monitor. However if I remove the USB port, the GSM cannot receive the messages anymore but when I press the reset button of the Arduino, it will start receiving messages again. Why does it only works when I reset the Arduino first after powering it up?

    #include <SoftwareSerial.h>
    #include <Wire.h>

    SoftwareSerial gsmSerial(2, 3);

    char incomingByte;
    String inputString;

    // Pin configurations.

    const int outlet1Pin = 4;
    const int outlet2Pin = 5;
    const int outlet3Pin = 6;

    const int ping1Pin = 7;
    const int ping2Pin = 8;
    const int ping3Pin = 9;
    const int ping4Pin = 10;
    const int ping5Pin = 11;
    const int ping6Pin = 12;
    const int signalPin = 13;

    const int pingWaitTime = 3000;

    void setup()
    {
      Serial.begin(9600);
      gsmSerial.begin(9600);

      pinMode(outlet1Pin, INPUT);
      pinMode(outlet2Pin, INPUT);
      pinMode(outlet3Pin, INPUT);

      pinMode(ping1Pin, OUTPUT);
      pinMode(ping2Pin, OUTPUT);
      pinMode(ping3Pin, OUTPUT);
      pinMode(ping4Pin, OUTPUT);
      pinMode(ping5Pin, OUTPUT);
      pinMode(ping6Pin, OUTPUT);
      pinMode(signalPin, OUTPUT);

      initGSM();
      //Serial.flush();
      //gsmSerial.flush();
      //sendSMS("Test send.");

    }

    void loop()
    {
      if (gsmSerial.available())
      {
        digitalWrite(signalPin, HIGH);

        delay(500);

        //Serial.println("Serial available.");

        while (gsmSerial.available())
        {
          incomingByte = gsmSerial.read();
          inputString += incomingByte;
        }

        inputString.toUpperCase();

        checkCommandAction(inputString);

        if (inputString.indexOf("OK") == -1)
        {
          gsmSerial.println("AT+CMGDA=\"DEL ALL\"");
          delay(1000);
        }

        inputString = "";
        gsmSerial.flush();

      }
      digitalWrite(signalPin, LOW);

    }

    void sendSMS(String text)
    {
      Serial.println("Sending Text...");

      gsmSerial.println("AT+CMGF=1");
      delay(1000);

      gsmSerial.print("AT+CMGS=\"+numberhere\"\r");

      delay(1000);

      gsmSerial.print(text);
      delay(1000);

      gsmSerial.print((char)26);
      delay(1000);

      gsmSerial.println();
      Serial.println("Message sent!");
      delay(1000);
    }

    void initGSM()
    {
      gsmSerial.println("ATE0");
      while (!gsmSerial.available())
      {
        gsmSerial.println("AT");
        delay(500);
        Serial.println("Connecting...");
      }

      Serial.println("Connected!");

      gsmSerial.println("AT+CMGF=1");
      delay(500);
      gsmSerial.println("AT+CNMI=1,2,0,0,0");
      delay(500);
      gsmSerial.println("AT+CMGL=\"REC UNREAD\"");
      delay(500);
      gsmSerial.println("AT+CMGDA=\"DEL ALL\"");
      delay(500);

      Serial.println("All messages deleted!");

      Serial.println("Sending Text...");

      gsmSerial.println("AT+CMGF=1");
      delay(500);

      gsmSerial.print("AT+CMGS=\"+639776811077\"\r");

      delay(500);

      gsmSerial.print("Device Initialized!");
      delay(500);

      gsmSerial.print((char)26);
      delay(500);

      gsmSerial.println();

      Serial.println("Message sent!");
      delay(500);
    }

    void checkCommandAction(String command)
    {

      //Serial.println("Check Command.");

      if (command.indexOf("O1ON") > -1)
      {

        digitalWrite(ping1Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping1Pin, !HIGH);
        Serial.println("O1ON Enter");
        sendSMS("Outlet 1 Turned ON by text.");

      }
      else if (command.indexOf("O1OFF") > -1)
      {
        digitalWrite(ping4Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping4Pin, !HIGH);
        Serial.println("O1OFF");
        sendSMS("Outlet 1 Turned OFF by text.");
      }
      else if (command.indexOf("O2ON") > -1)
      {
        digitalWrite(ping2Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping2Pin, !HIGH);
        Serial.println("O2ON");
        sendSMS("Outlet 2 Turned ON by text.");
      }
      else if (command.indexOf("O2OFF") > -1)
      {
        digitalWrite(ping5Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping5Pin, !HIGH);
        Serial.println("O2OFF");
        sendSMS("Outlet 2 Turned OFF by text.");
      }
      else if (command.indexOf("O3ON") > -1)
      {
        digitalWrite(ping3Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping3Pin, !HIGH);
        Serial.println("O3ON");
        sendSMS("Outlet 3 Turned ON by text.");

      }
      else if (command.indexOf("O3OFF") > -1)
      {
        digitalWrite(ping6Pin, !LOW);
        delay(pingWaitTime);
        digitalWrite(ping6Pin, !HIGH);
        Serial.println("O1OFF");
        sendSMS("Outlet 3 Turned OFF by text.");
      }
      else if (command.indexOf("CHECKSTATE") > -1)
      {
        int state1 = !digitalRead(outlet1Pin);
        int state2 = !digitalRead(outlet2Pin);
        int state3 = !digitalRead(outlet3Pin);

        String toSend = "";
        toSend += "Outlet 1: ";
        toSend += String((state1) ? ("ON") : ("OFF"));
        toSend += "Outlet 2: ";
        toSend += String((state2) ? ("ON") : ("OFF"));
        toSend += "Outlet 3: ";
        toSend += String((state3) ? ("ON") : ("OFF"));

        sendSMS(toSend);
      }
    }

    void turnPingsOn()
    {
      // The pins where the pings are connected are
      // configures as INPUT_PULL up, so we need to high
      // it by default.

      digitalWrite(ping1Pin, HIGH);
      digitalWrite(ping2Pin, HIGH);
      digitalWrite(ping3Pin, HIGH);
      digitalWrite(ping4Pin, HIGH);
      digitalWrite(ping5Pin, HIGH);
      digitalWrite(ping6Pin, HIGH);
    }

sender: assistant

body:
In theory you shouldn't rely on the 3.3V supply of the Arduino to power the NodeMCU board, it doesn't have enough power particularly when WIFI data is being transmitted.

Are you removing the USB while the system is live?  If so you are probably spiking various bits that don't like being spiked and that's why it breaks.

If you are removing the USB and THEN powering up the system, what happened when you power down you system and power it back up again after 10 seconds?  My guess is that it won't receive messages.  So there is a difference between applying power and resetting the board, which implies that you are very marginal on your power supply.

If you are using the SIM800 (?) module they need 2Amps to transmit, so if you are only supplying 2A it might not have enough power to cold start, but when reset it does.  So if you can try more power that might help.

Another thought might be you haven't got a proper ground (wall warts aren't normally grounded) so your USB connection is acting as a ground.  If this is the case then it should work when you PC is turned off.

Sorry this is a bit vague, but your question needs model names and part number for people to be a bit more specific.


message:
How to create "Auto switch case"

I am new to programming. I want to modify this sketch and I really need help. I have a switch case in this sketch, and what I want is an auto change effect.

In this sketch 18 color effects for WS2812B led strip. To change effects you have to press ta button. How do I make it change effect automatically, for example 8-10 seconds. I don't know how to do this. So please help me, huge thanks!

<!-- language-all: lang-cpp -->

    #include "FastLED.h"
    #include <EEPROM.h>
    #define NUM_LEDS 60
    CRGB leds[NUM_LEDS];
    #define PIN 6

    #define BUTTON 2
    byte selectedEffect=0;

    void setup()
    {
      FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
      digitalWrite (BUTTON, HIGH);  // internal pull-up resistor
      attachInterrupt (digitalPinToInterrupt (BUTTON), changeEffect, CHANGE); // pressed
    }

    // *** REPLACE FROM HERE ***
    void loop() {
      EEPROM.get(0,selectedEffect);
      if(selectedEffect>18) {
        selectedEffect=0;
        EEPROM.put(0,0);
      }

      switch(selectedEffect) {

        case 0  : {
                    // RGBLoop - no parameters
                    RGBLoop();
                    break;
                  }

        case 1  : {
                    // FadeInOut - Color (red, green. blue)
                    FadeInOut(0xff, 0x00, 0x00); // red
                    FadeInOut(0xff, 0xff, 0xff); // white
                    FadeInOut(0x00, 0x00, 0xff); // blue
                    break;
                  }

        case 2  : {
                    // Strobe - Color (red, green, blue), number of flashes, flash speed, end pause
                    Strobe(0xff, 0xff, 0xff, 10, 50, 1000);
                    break;
                  }

        case 3  : {
                    // HalloweenEyes - Color (red, green, blue), Size of eye, space between eyes, fade (true/false), steps, fade delay, end pause
                    HalloweenEyes(0xff, 0x00, 0x00,
                                  1, 4,
                                  true, random(5,50), random(50,150),
                                  random(1000, 10000));
                    HalloweenEyes(0xff, 0x00, 0x00,
                                  1, 4,
                                  true, random(5,50), random(50,150),
                                  random(1000, 10000));
                    break;
                  }

        case 4  : {
                    // CylonBounce - Color (red, green, blue), eye size, speed delay, end pause
                    CylonBounce(0xff, 0x00, 0x00, 4, 10, 50);
                    break;
                  }

        case 5  : {
                    // NewKITT - Color (red, green, blue), eye size, speed delay, end pause
                    NewKITT(0xff, 0x00, 0x00, 8, 10, 50);
                    break;
                  }

        case 6  : {
                    // Twinkle - Color (red, green, blue), count, speed delay, only one twinkle (true/false)
                    Twinkle(0xff, 0x00, 0x00, 10, 100, false);
                    break;
                  }

        case 7  : {
                    // TwinkleRandom - twinkle count, speed delay, only one (true/false)
                    TwinkleRandom(20, 100, false);
                    break;
                  }

        case 8  : {
                    // Sparkle - Color (red, green, blue), speed delay
                    Sparkle(0xff, 0xff, 0xff, 0);
                    break;
                  }

        case 9  : {
                    // SnowSparkle - Color (red, green, blue), sparkle delay, speed delay
                    SnowSparkle(0x10, 0x10, 0x10, 20, random(100,1000));
                    break;
                  }

        case 10 : {
                    // Running Lights - Color (red, green, blue), wave dealy
                    RunningLights(0xff,0x00,0x00, 50);  // red
                    RunningLights(0xff,0xff,0xff, 50);  // white
                    RunningLights(0x00,0x00,0xff, 50);  // blue
                    break;
                  }

        case 11 : {
                    // colorWipe - Color (red, green, blue), speed delay
                    colorWipe(0x00,0xff,0x00, 50);
                    colorWipe(0x00,0x00,0x00, 50);
                    break;
                  }

        case 12 : {
                    // rainbowCycle - speed delay
                    rainbowCycle(20);
                    break;
                  }

        case 13 : {
                    // theatherChase - Color (red, green, blue), speed delay
                    theaterChase(0xff,0,0,50);
                    break;
                  }

        case 14 : {
                    // theaterChaseRainbow - Speed delay
                    theaterChaseRainbow(50);
                    break;
                  }

        case 15 : {
                    // Fire - Cooling rate, Sparking rate, speed delay
                    Fire(55,120,15);
                    break;
                  }

                  // simple bouncingBalls not included, since BouncingColoredBalls can perform this as well as shown below
                  // BouncingColoredBalls - Number of balls, color (red, green, blue) array, continuous
                  // CAUTION: If set to continuous then this effect will never stop!!!

        case 16 : {
                    // mimic BouncingBalls
                    byte onecolor[1][3] = { {0xff, 0x00, 0x00} };
                    BouncingColoredBalls(1, onecolor, false);
                    break;
                  }

        case 17 : {
                    // multiple colored balls
                    byte colors[3][3] = { {0xff, 0x00, 0x00},
                                          {0xff, 0xff, 0xff},
                                          {0x00, 0x00, 0xff} };
                    BouncingColoredBalls(3, colors, false);
                    break;
                  }

        case 18 : {
                    // meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay
                    meteorRain(0xff,0xff,0xff,10, 64, true, 30);
                    break;
                  }
      }
    }

    void changeEffect() {
      if (digitalRead (BUTTON) == HIGH) {
        selectedEffect++;
        EEPROM.put(0, selectedEffect);
        asm volatile ("  jmp 0");
      }
    }

    // *************************
    // ** LEDEffect Functions **
    // *************************

    void RGBLoop(){
      for(int j = 0; j < 3; j++ ) {
        // Fade IN
        for(int k = 0; k < 256; k++) {
          switch(j) {
            case 0: setAll(k,0,0); break;
            case 1: setAll(0,k,0); break;
            case 2: setAll(0,0,k); break;
          }
          showStrip();
          delay(3);
        }
        // Fade OUT
        for(int k = 255; k >= 0; k--) {
          switch(j) {
            case 0: setAll(k,0,0); break;
            case 1: setAll(0,k,0); break;
            case 2: setAll(0,0,k); break;
          }
          showStrip();
          delay(3);
        }
      }
    }

    void FadeInOut(byte red, byte green, byte blue){
      float r, g, b;

      for(int k = 0; k < 256; k=k+1) {
        r = (k/256.0)*red;
        g = (k/256.0)*green;
        b = (k/256.0)*blue;
        setAll(r,g,b);
        showStrip();
      }

      for(int k = 255; k >= 0; k=k-2) {
        r = (k/256.0)*red;
        g = (k/256.0)*green;
        b = (k/256.0)*blue;
        setAll(r,g,b);
        showStrip();
      }
    }

    void Strobe(byte red, byte green, byte blue, int StrobeCount, int FlashDelay, int EndPause){
      for(int j = 0; j < StrobeCount; j++) {
        setAll(red,green,blue);
        showStrip();
        delay(FlashDelay);
        setAll(0,0,0);
        showStrip();
        delay(FlashDelay);
      }

     delay(EndPause);
    }

    void HalloweenEyes(byte red, byte green, byte blue,
                       int EyeWidth, int EyeSpace,
                       boolean Fade, int Steps, int FadeDelay,
                       int EndPause){
      randomSeed(analogRead(0));

      int i;
      int StartPoint  = random( 0, NUM_LEDS - (2*EyeWidth) - EyeSpace );
      int Start2ndEye = StartPoint + EyeWidth + EyeSpace;

      for(i = 0; i < EyeWidth; i++) {
        setPixel(StartPoint + i, red, green, blue);
        setPixel(Start2ndEye + i, red, green, blue);
      }

      showStrip();

      if(Fade==true) {
        float r, g, b;

        for(int j = Steps; j >= 0; j--) {
          r = j*(red/Steps);
          g = j*(green/Steps);
          b = j*(blue/Steps);

          for(i = 0; i < EyeWidth; i++) {
            setPixel(StartPoint + i, r, g, b);
            setPixel(Start2ndEye + i, r, g, b);
          }

          showStrip();
          delay(FadeDelay);
        }
      }

      setAll(0,0,0); // Set all black

      delay(EndPause);
    }

    void CylonBounce(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){

      for(int i = 0; i < NUM_LEDS-EyeSize-2; i++) {
        setAll(0,0,0);
        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);
        showStrip();
        delay(SpeedDelay);
      }

      delay(ReturnDelay);

      for(int i = NUM_LEDS-EyeSize-2; i > 0; i--) {
        setAll(0,0,0);
        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);
        showStrip();
        delay(SpeedDelay);
      }

      delay(ReturnDelay);
    }

    void NewKITT(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){
      RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      LeftToRight(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      RightToLeft(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      OutsideToCenter(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
      CenterToOutside(red, green, blue, EyeSize, SpeedDelay, ReturnDelay);
    }

    // used by NewKITT
    void CenterToOutside(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
      for(int i =((NUM_LEDS-EyeSize)/2); i>=0; i--) {
        setAll(0,0,0);

        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);

        setPixel(NUM_LEDS-i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(NUM_LEDS-i-j, red, green, blue);
        }
        setPixel(NUM_LEDS-i-EyeSize-1, red/10, green/10, blue/10);

        showStrip();
        delay(SpeedDelay);
      }
      delay(ReturnDelay);
    }

    // used by NewKITT
    void OutsideToCenter(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
      for(int i = 0; i<=((NUM_LEDS-EyeSize)/2); i++) {
        setAll(0,0,0);

        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);

        setPixel(NUM_LEDS-i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(NUM_LEDS-i-j, red, green, blue);
        }
        setPixel(NUM_LEDS-i-EyeSize-1, red/10, green/10, blue/10);

        showStrip();
        delay(SpeedDelay);
      }
      delay(ReturnDelay);
    }

    // used by NewKITT
    void LeftToRight(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
      for(int i = 0; i < NUM_LEDS-EyeSize-2; i++) {
        setAll(0,0,0);
        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);
        showStrip();
        delay(SpeedDelay);
      }
      delay(ReturnDelay);
    }

    // used by NewKITT
    void RightToLeft(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay) {
      for(int i = NUM_LEDS-EyeSize-2; i > 0; i--) {
        setAll(0,0,0);
        setPixel(i, red/10, green/10, blue/10);
        for(int j = 1; j <= EyeSize; j++) {
          setPixel(i+j, red, green, blue);
        }
        setPixel(i+EyeSize+1, red/10, green/10, blue/10);
        showStrip();
        delay(SpeedDelay);
      }
      delay(ReturnDelay);
    }

    void Twinkle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
      setAll(0,0,0);

      for (int i=0; i<Count; i++) {
         setPixel(random(NUM_LEDS),red,green,blue);
         showStrip();
         delay(SpeedDelay);
         if(OnlyOne) {
           setAll(0,0,0);
         }
       }

      delay(SpeedDelay);
    }

    void TwinkleRandom(int Count, int SpeedDelay, boolean OnlyOne) {
      setAll(0,0,0);

      for (int i=0; i<Count; i++) {
         setPixel(random(NUM_LEDS),random(0,255),random(0,255),random(0,255));
         showStrip();
         delay(SpeedDelay);
         if(OnlyOne) {
           setAll(0,0,0);
         }
       }

      delay(SpeedDelay);
    }

    void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
      int Pixel = random(NUM_LEDS);
      setPixel(Pixel,red,green,blue);
      showStrip();
      delay(SpeedDelay);
      setPixel(Pixel,0,0,0);
    }

    void SnowSparkle(byte red, byte green, byte blue, int SparkleDelay, int SpeedDelay) {
      setAll(red,green,blue);

      int Pixel = random(NUM_LEDS);
      setPixel(Pixel,0xff,0xff,0xff);
      showStrip();
      delay(SparkleDelay);
      setPixel(Pixel,red,green,blue);
      showStrip();
      delay(SpeedDelay);
    }

    void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
      int Position=0;

      for(int i=0; i<NUM_LEDS*2; i++)
      {
          Position++; // = 0; //Position + Rate;
          for(int i=0; i<NUM_LEDS; i++) {
            // sine wave, 3 offset waves make a rainbow!
            //float level = sin(i+Position) * 127 + 128;
            //setPixel(i,level,0,0);
            //float level = sin(i+Position) * 127 + 128;
            setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                       ((sin(i+Position) * 127 + 128)/255)*green,
                       ((sin(i+Position) * 127 + 128)/255)*blue);
          }

          showStrip();
          delay(WaveDelay);
      }
    }

    void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
      for(uint16_t i=0; i<NUM_LEDS; i++) {
          setPixel(i, red, green, blue);
          showStrip();
          delay(SpeedDelay);
      }
    }

    void rainbowCycle(int SpeedDelay) {
      byte *c;
      uint16_t i, j;

      for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
        for(i=0; i< NUM_LEDS; i++) {
          c=Wheel(((i * 256 / NUM_LEDS) + j) & 255);
          setPixel(i, *c, *(c+1), *(c+2));
        }
        showStrip();
        delay(SpeedDelay);
      }
    }

    // used by rainbowCycle and theaterChaseRainbow
    byte * Wheel(byte WheelPos) {
      static byte c[3];

      if(WheelPos < 85) {
       c[0]=WheelPos * 3;
       c[1]=255 - WheelPos * 3;
       c[2]=0;
      } else if(WheelPos < 170) {
       WheelPos -= 85;
       c[0]=255 - WheelPos * 3;
       c[1]=0;
       c[2]=WheelPos * 3;
      } else {
       WheelPos -= 170;
       c[0]=0;
       c[1]=WheelPos * 3;
       c[2]=255 - WheelPos * 3;
      }

      return c;
    }

    void theaterChase(byte red, byte green, byte blue, int SpeedDelay) {
      for (int j=0; j<10; j++) {  //do 10 cycles of chasing
        for (int q=0; q < 3; q++) {
          for (int i=0; i < NUM_LEDS; i=i+3) {
            setPixel(i+q, red, green, blue);    //turn every third pixel on
          }
          showStrip();

          delay(SpeedDelay);

          for (int i=0; i < NUM_LEDS; i=i+3) {
            setPixel(i+q, 0,0,0);        //turn every third pixel off
          }
        }
      }
    }

    void theaterChaseRainbow(int SpeedDelay) {
      byte *c;

      for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
        for (int q=0; q < 3; q++) {
            for (int i=0; i < NUM_LEDS; i=i+3) {
              c = Wheel( (i+j) % 255);
              setPixel(i+q, *c, *(c+1), *(c+2));    //turn every third pixel on
            }
            showStrip();

            delay(SpeedDelay);

            for (int i=0; i < NUM_LEDS; i=i+3) {
              setPixel(i+q, 0,0,0);        //turn every third pixel off
            }
        }
      }
    }

    void Fire(int Cooling, int Sparking, int SpeedDelay) {
      static byte heat[NUM_LEDS];
      int cooldown;

      // Step 1.  Cool down every cell a little
      for( int i = 0; i < NUM_LEDS; i++) {
        cooldown = random(0, ((Cooling * 10) / NUM_LEDS) + 2);

        if(cooldown>heat[i]) {
          heat[i]=0;
        } else {
          heat[i]=heat[i]-cooldown;
        }
      }

      // Step 2.  Heat from each cell drifts 'up' and diffuses a little
      for( int k= NUM_LEDS - 1; k >= 2; k--) {
        heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
      }

      // Step 3.  Randomly ignite new 'sparks' near the bottom
      if( random(255) < Sparking ) {
        int y = random(7);
        heat[y] = heat[y] + random(160,255);
        //heat[y] = random(160,255);
      }

      // Step 4.  Convert heat to LED colors
      for( int j = 0; j < NUM_LEDS; j++) {
        setPixelHeatColor(j, heat[j] );
      }

      showStrip();
      delay(SpeedDelay);
    }

    void setPixelHeatColor (int Pixel, byte temperature) {
      // Scale 'heat' down from 0-255 to 0-191
      byte t192 = round((temperature/255.0)*191);

      // calculate ramp up from
      byte heatramp = t192 & 0x3F; // 0..63
      heatramp <<= 2; // scale up to 0..252

      // figure out which third of the spectrum we're in:
      if( t192 > 0x80) {                     // hottest
        setPixel(Pixel, 255, 255, heatramp);
      } else if( t192 > 0x40 ) {             // middle
        setPixel(Pixel, 255, heatramp, 0);
      } else {                               // coolest
        setPixel(Pixel, heatramp, 0, 0);
      }
    }

    void BouncingColoredBalls(int BallCount, byte colors[][3], boolean continuous) {
      float Gravity = -9.81;
      int StartHeight = 1;

      float Height[BallCount];
      float ImpactVelocityStart = sqrt( -2 * Gravity * StartHeight );
      float ImpactVelocity[BallCount];
      float TimeSinceLastBounce[BallCount];
      int   Position[BallCount];
      long  ClockTimeSinceLastBounce[BallCount];
      float Dampening[BallCount];
      boolean ballBouncing[BallCount];
      boolean ballsStillBouncing = true;

      for (int i = 0 ; i < BallCount ; i++) {
        ClockTimeSinceLastBounce[i] = millis();
        Height[i] = StartHeight;
        Position[i] = 0;
        ImpactVelocity[i] = ImpactVelocityStart;
        TimeSinceLastBounce[i] = 0;
        Dampening[i] = 0.90 - float(i)/pow(BallCount,2);
        ballBouncing[i]=true;
      }

      while (ballsStillBouncing) {
        for (int i = 0 ; i < BallCount ; i++) {
          TimeSinceLastBounce[i] =  millis() - ClockTimeSinceLastBounce[i];
          Height[i] = 0.5 * Gravity * pow( TimeSinceLastBounce[i]/1000 , 2.0 ) + ImpactVelocity[i] * TimeSinceLastBounce[i]/1000;

          if ( Height[i] < 0 ) {
            Height[i] = 0;
            ImpactVelocity[i] = Dampening[i] * ImpactVelocity[i];
            ClockTimeSinceLastBounce[i] = millis();

            if ( ImpactVelocity[i] < 0.01 ) {
              if (continuous) {
                ImpactVelocity[i] = ImpactVelocityStart;
              } else {
                ballBouncing[i]=false;
              }
            }
          }
          Position[i] = round( Height[i] * (NUM_LEDS - 1) / StartHeight);
        }

        ballsStillBouncing = false; // assume no balls bouncing
        for (int i = 0 ; i < BallCount ; i++) {
          setPixel(Position[i],colors[i][0],colors[i][1],colors[i][2]);
          if ( ballBouncing[i] ) {
            ballsStillBouncing = true;
          }
        }

        showStrip();
        setAll(0,0,0);
      }
    }

    void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
      setAll(0,0,0);

      for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {

        // fade brightness all LEDs one step
        for(int j=0; j<NUM_LEDS; j++) {
          if( (!meteorRandomDecay) || (random(10)>5) ) {
            fadeToBlack(j, meteorTrailDecay );
          }
        }

        // draw meteor
        for(int j = 0; j < meteorSize; j++) {
          if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
            setPixel(i-j, red, green, blue);
          }
        }

        showStrip();
        delay(SpeedDelay);
      }
    }

    // used by meteorrain
    void fadeToBlack(int ledNo, byte fadeValue) {
     #ifdef ADAFRUIT_NEOPIXEL_H
        // NeoPixel
        uint32_t oldColor;
        uint8_t r, g, b;
        int value;

        oldColor = strip.getPixelColor(ledNo);
        r = (oldColor & 0x00ff0000UL) >> 16;
        g = (oldColor & 0x0000ff00UL) >> 8;
        b = (oldColor & 0x000000ffUL);

        r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
        g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
        b=(b<=10)? 0 : (int) b-(b*fadeValue/256);

        strip.setPixelColor(ledNo, r,g,b);
     #endif
     #ifndef ADAFRUIT_NEOPIXEL_H
       // FastLED
       leds[ledNo].fadeToBlackBy( fadeValue );
     #endif
    }

    // *** REPLACE TO HERE ***

    // ***************************************
    // ** FastLed/NeoPixel Common Functions **
    // ***************************************

    // Apply LED color changes
    void showStrip() {
     #ifdef ADAFRUIT_NEOPIXEL_H
       // NeoPixel
       strip.show();
     #endif
     #ifndef ADAFRUIT_NEOPIXEL_H
       // FastLED
       FastLED.show();
     #endif
    }

    // Set a LED color (not yet visible)
    void setPixel(int Pixel, byte red, byte green, byte blue) {
     #ifdef ADAFRUIT_NEOPIXEL_H
       // NeoPixel
       strip.setPixelColor(Pixel, strip.Color(red, green, blue));
     #endif
     #ifndef ADAFRUIT_NEOPIXEL_H
       // FastLED
       leds[Pixel].r = red;
       leds[Pixel].g = green;
       leds[Pixel].b = blue;
     #endif
    }

    // Set all LEDs to a given color and apply it (visible)
    void setAll(byte red, byte green, byte blue) {
      for(int i = 0; i < NUM_LEDS; i++ ) {
        setPixel(i, red, green, blue);
      }
      showStrip();
    }

body:
use millis to check

    static unsigned long lastChange = millis();
    if(auto_changing && millis()-lastChange  > 10*1000){
        selectedEffect++;
        EEPROM.put(0,selectedEffect);
        lastChange = millis();
    }

Put this before the `if(selectedEffect>18)` and it will cycle each effect for at least 10 seconds before going to the next effect.

---

BTW I suggest that you rejig your code like blinkWithoutDelay so you don't need to use interrupts the flash memory and `jmp 0` and can instead avoid that.

It'll require quite a bit of refactoring though but will allow you to fade from one effect to the next smoothly.


message:
Can i use a range in a switchcase like in pascal?

in pascal's case statement i can use this:

    Var i : integer;
    ...
    Case i of
     1..5 : DoSomething;
    end;

i was wondering if there is a way in can do this with c/c++ in the arduino compiler using:

    switch (var) {
       case 1..5:
         // statements
         break;

or is this only possible using if/else?

body:
Short answer: No

Longer answer: Each case in a switch statement must be a discrete value (which is why floats and doubles won't work either) but there are way around it.  In order of preference:

A) Utilise the "drop through" feature

    switch (value)
    {
      case 1: // Deliberate drop through
      case 2: // Deliberate drop through
      case 3: // Deliberate drop through
      case 4: // Deliberate drop through
      case 5:
        DoThingA();
        break;
      case 6:
        DoThingB();
        break;
    }

B) Change the logic so the range is the default  (not nice, but if you have no other option):

    switch (value)
    {
      case 6:
        DoThingB();
        break;
      default:
        DoThingA();
        break;
    }

C) Use a helper function (Really ugly, but...).  There would have to be a good reason not to call the DoThing() from the helper function.

    enum DoOptions {EOptionA, EOptionB};
    DoOptions DoWhat (int value)
    {
      if (value < 6) return EOptionA;
      return EOptionB;
    }
    switch (DoWhat(value))
    {
      case EOptionA:
        DoThingA();
        break;
      case EOptionB:
        DoThingB();
        break;
    }


body:
There are some GNU extensions available in the avr-gcc/avr-g++ compilers (used in Arduino IDE for AVR based Arduino boards). One of them is suport of `...` for the `case`:

      switch (i)
      {
        case  10 ... 100:  Serial.println(F("First"));           break;
        case 101 ... 1000: Serial.println(F("Second"));          break;
        default:           Serial.println(F("Everything else")); break;
      }

But, it's not the part of C/C++ standard, it's just compiler extension, so there is possibility it fails to compile on different platforms (mainly different compiler). So it's better to avoid it in portable code.


message:
IOT-GA6 gsm module Arduino +CME error 58

I've recently bought a IOT-GA6 gsm module . I want to use it to send an mms but doesn't work.
The SMS and call work.
When I execute the void function (mms) the monitor shows the error message +CME EYROR:58.
Does anybody know what this means and how to solve it?
[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/ulwjw.jpg

this is my code

    include SoftwareSerial.h
    include SD.h

    define  CS    4

    SoftwareSerial A6Module(2, 3);

    File dataFile;

    int i;

    unsigned char data=0;

    void setup()
    {
      pinMode(PWR,OUTPUT);
      pinMode(CS,OUTPUT);

      A6Module.begin(115200);
      Serial.begin(115200);

      digitalWrite(PWR,LOW);
      delay(10);

      digitalWrite(PWR,HIGH);
      delay(10);

      if (!SD.begin(CS)) Serial.println("initialization failed!");
      else Serial.println("initialization done.");
    }

    void loop()
    {
      if(Serial.available())
      {
        while(Serial.available())
        {
          data=Serial.read();
          Serial.write(data);
          Serial.println("\n");
        }
        //data=0;
      }

      if(Serial.available())
      {
        data=Serial.read();
      }

      if(data=='1')
      {
        A6Module.println("AT+CGMI\r"); //Manufacturer identification
      }

      if(data=='2')
      {
        A6Module.println("AT+CGMM\r"); //Model identification
      }

      if(data=='3')
      {
        A6Module.println("AT+CGMR\r"); //Software version
      }

      if(data=='4')
      {
        A6Module.println("AT+CGSN\r"); //IMEI number
      }

      if(data=='5')
      {
        A6Module.println("ATD+21369682909;\r"); //Calling
      }

      if(data=='6')
      {
        A6Module.println("ATH\r"); //Hang Up
      }

      if(data=='7')
      {
        A6Module.println("AT+CMGF=1");
        delay(2000);
        A6Module.print("AT+CMGS=\"+213696829093");
        A6Module.print(char(34));  // "
        A6Module.print(char(13));  // CR
        A6Module.print('\r');  // hex equivalent of newline
        delay(2000);
        A6Module.print("A6 test message");
        delay(500);
        A6Module.println (char(26));  //ctrl_z
      }

      if(data=='8')
      {
        A6Module.println("AT+CMGR=1\r"); //Read message
      }

      if(data=='9')
      {
       A6Module.println("AT+CMGD=1,0\r"); //Delete message
      }

      if(data=='s') sendMMS();
      data=0;
    }

    void sendMMS()
    {
      A6Module.print("AT+CMMSINIT");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSCURL=\"http://mms.itelcel.com/servlets/mms\"");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSCID=1\r");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSPROTO=\"148.233.151.240\",8080");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSSENDCFG=6,3,0,0,2,4\r");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+SAPBR=3,1,\"CONTYPE\",\"MMS\"\r");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+SAPBR=3,1,\"APN\",\"mms.itelcel.com\"");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+SAPBR=1,1");
      delay(4000);
      if(A6Module.available())

      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+SAPBR=2,1");
      delay(4000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSEDIT=1");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSDOWN=\"PIC\",19293,2000000,\"test.jpg\"\r");
      delay(1000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }

      dataFile=SD.open("test.jpg");
      i=0;
      if(dataFile)
      {
        while(dataFile.available())
        {
          data=dataFile.read();
          if(data<0x10) Serial.print("0");
          Serial.print(data,HEX);
          i++;
          if((i@)==0) Serial.println();
          A6Module.write(data);
        }
        dataFile.close();
      }
      else
      {
        Serial.println("error opening test.jpg");
      }

      delay(1000);
      A6Module.print("AT+CMMSRECP=\"+213696829093");
      delay(100);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSVIEW\r");
      delay(2000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSSEND\r");
      delay(2000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSEDIT=0\r");
      delay(2000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
      A6Module.print("AT+CMMSTERM\r");
      delay(2000);

      if(A6Module.available())
      {
        while(A6Module.available()) Serial.write(A6Module.read());
      }
    }

body: The Arduino Uno does not support the maximum current requested by GA6, try an external source for the gprs module of at least 6V using common ground between the gprs module and the arduino.


message:
Arduino Switching Between Loops IR Remote

I've been working on an LED strip project. However, I've come to a stand still at the moment. Within the program I am wanting to assign different lighting effects to each button on my IR remote. I am wanting the program to work on the basis that each lighting effect will run, until another button is pressed, to start another effect.

Currently with my code I have made it so each effect will run, once, when the corresponding button on the IR remote is pressed.

I am fairly new to C++ / Arduino but from my understanding I need to have a variable which would hold the current value of the IR remote. I am unsure on how to actually implement this. I will post my code below and if anyone could give me tips or even amendments to my code it would be to a great help.

Thank you in advanced.
<!-- language-all: lang-cpp -->

    #include "IRremote.h"
    #include <Adafruit_NeoPixel.h>
    #ifdef __AVR__
    #include <avr/power.h>
    #endif
    #define PIN 6

    Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800);

    int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

    /*-----( Declare objects )-----*/
    IRrecv irrecv(receiver);     // create instance of 'irrecv'
    decode_results results;      // create instance of 'decode_results'
    int Remote = 0;

    /*-----( Function )-----*/
    void translateIR() // takes action based on IR code received

    // describing Remote IR codes

    {
      switch(results.value)
      {
      case 0xFFA25D: Serial.println("POWER");
      ArrowRight(strip.Color(25, 0, 0), 100); //Red
      ArrowRight(strip.Color(0, 0, 25), 100); //Blue
      break;

      case 0xFFE21D: Serial.println("FUNC/STOP");
      ArrowLeft(strip.Color(25, 0, 0), 100); // Red
      ArrowLeft(strip.Color(0, 0, 25), 100); // Blue
      break;

      default:
      Serial.println(" other button   ");

      }// End Case

      delay(0); // Do not get immediate repeat

    } //END translateIR
    void setup()   /*----( SETUP: RUNS ONCE )----*/
    {
      Serial.begin(9600);
      Serial.println("IR Receiver Button Decode");
      irrecv.enableIRIn(); // Start the receiver
      strip.begin();
      strip.show();
      Remote = 0;

    }/*--(end setup )---*/

    void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
    {
      if (irrecv.decode(&results)) // have we received an IR signal?

      {
        translateIR();
        irrecv.resume(); // receive the next value
      }
    }/* --(end main loop )-- */

    void ArrowRight(uint32_t c, uint8_t wait) {
      for (int j = 0; j < 1; j++) { // The j<# determines how many cycles
        for (uint16_t i = strip.numPixels()/2; i < strip.numPixels(); i++) {
          strip.setPixelColor(i, c);
          strip.show();
          delay(50);
        }
        for (uint16_t i = 0; i < strip.numPixels(); i++) {
          strip.setPixelColor(i, 0);
        }
        strip.show();
        delay(50);
      }
    }

    void ArrowLeft(uint32_t c, uint8_t wait) {
      for (int j = 0; j < 1; j++) { // The j<# determines how many cycles
        for (uint16_t i = strip.numPixels()/2-1; i + 1 > 0 ; i--) {
          strip.setPixelColor(i, c);
          strip.show();
          delay(50);
        }
        for (uint16_t i = strip.numPixels(); i + 1 > 0 ; i--) {
          strip.setPixelColor(i, 0);
        }
        strip.show();
        delay(50);
      }
    }

body:
`delay(0)` apparently[*] acts like `delay(2^32)` or about 10^10 milliseconds. That may not be what you had in mind ... :)

Try reducing the delay to 1 or use `delayMicroseconds()` to get something shorter. That should at least get you some repeatable results.

(10^10 mSec is ~ 16.5 weeks, for those without a calculator handy).

[*]  I didn't read the code, nor wait for the call to expire. I tried it and saw that the Uno froze. I'm guessing a zero-argument to delay() isn't rejected but just gets decremented as usual, until it hits zero.


body:
>  I need to have a variable which would hold the current value of the
> IR remote.

You already have one.  It's called results and is of type decode_results.

    decode_results results;

You read the IR results into that variable.  Then you clear it to look for another one.  What you need is a way to store the last good code that you got.  Your best bet is to just use an int and store a certain number for each code, store a 1 when you get 0xFFA25D and a 2 when you get 0xFFE21D or something like that.  Then use that int instead of the results variable to decide what to do in the rest of the code.


message:
won't verify a simple code

When I tried to verify a simple “Hello world” program I get the following message:

    class hardwareSerial has no member named printin.

What does it mean?

body: Try using `println` instead of `printin`.  It stands for **print** **l**i**n**e.


message:
How do I get more than 64 characters of message from serial

I am trying to make a moving message board using an Arduino Uno, HC-05 Bluetooth module and DMD board.
Sending message to the DMD through the Bluetooth module can only give a not more than 62 character message.
I need help in what to do to get up to 200 or more. Thanks.

body:
First: There is no such concept of a message on the Serial bus, unless you implement it yourself. On hardware level only individual bytes are transmitted, and you don't even know, when each byte will be transmitted exactly. Since there are only individual bytes in the first place, there is no limitation on how many bytes can be transmitted.

Yes, the `Serial` library has a limited buffer of 64 bytes, but as Majenko wrote it is not intended for buffering all bytes for one of your messages. It should only buffer the bytes, until the main sketch can read them from the buffer. On reading the bytes will be removed from the buffer, leasing buffer space for new characters.

The buffer size of the `Serial` library can be increased by changing the numbers in `HardwareSerial.h` in the following lines

    #define SERIAL_TX_BUFFER_SIZE 64

    #define SERIAL_RX_BUFFER_SIZE 64

But this is not really the solution to your problem. When first filling the buffer and then read the whole message you just arbitrarly
constrain yourself to a insufficient solution.

Instead of waiting for all the messages bytes (and finally filling up the buffer) you should steadily check, if new bytes are available and then load them into your own buffer. You can use a delimiter byte to mark the end of a message, mostly "\n" (newline character) is used for this. Copy the bytes into your own buffer, until you read the delimiter byte. Then use the message as a whole for your application. Don't forget to clear your buffer afterwards.

The examples for the `Serial` library, especially the `SerialEvent` example show how to do this in your code.


body: The software from the transmitter can break the text you want to send into pieces of 62 characters in length and send them one by one. The receiver will save the most recent piece in a String and join it with a another String which will be storing the whole message. If you don't mind it being a little bit slower, then this is the solution for you


message:
Need Input: Wait for voltage input to begin script & when voltage maintains 0V for X amount of time Reset and wait for Voltage Input

So I'm currently working on an automotive set up.

I'm using a 555 timer to emulate a turn-signal alternating voltage pulse (12V to 0V and repeat) for debugging purposes which is output to turnPin/A1.

Here's the goal: When voltage is greater than 1V arduino is to supply constant power to output pin (pin 13) until input voltage is returned to constant 0 (or end of turn signal input) for x-time or as I'll refer to as Timeout.

It seems I've gotten the constant power to apply when input is applied and then turn off constant output when voltage is back to 0V. However I'm having difficulty getting the timeout function to work properly as the LED still remains HIGH.

EDIT: I've reworked the code to use millis(); rather than purely using sensor inputs. I've also added comments to help walk you through what I believe is happened/what I want to happen.
------------------------------

    // Constants won't change
    const int ledPin = LED_BUILTIN; //using built in led + pin13
    const int turnPin = A1;   // the input pin (turn signal alternating 5V/0V/5V/0V & so-forth)

    // Variables will change
    int ledState = LOW;    // the current state of the output pin
    int prevLed = ledState;
    int lastVoltage = 1;    // the previous reading from voltage source
    int state = 1;      // the current "state" (see below)
         // State = 1++: LED OFF -- State = 0: LED ON

    // The following variables are long's because the time, measured in miliseconds,
    // will quickly become a bigger number than can be stored in an int.

    long previousMillis = 0; //the last time the voltage reached 0
    long waitTime = 100; // the wait time

    void setup()
    {
      pinMode(ledState, OUTPUT);  //set output pin
      pinMode(turnPin, INPUT);   //set input pin NOTE: SIGNAL ALTERNATES
    5V/0V/5V/0V & so forth to emulate a turn signal for this application
      Serial.begin(9600);    //begin serial
    }

    void loop()
    {
      int sensorValue = analogRead(turnPin);  // Read voltage at input pin
      float voltage = sensorValue * (5.0/1023.0); // Convert
      unsigned long currentMillis = millis();    // set currentMillis as current
     time

      if (voltage > 1)  //if Voltage greater than 1V
      {
        ledState = HIGH;  //turn led on
        state = 0;   //set state to 0
      }

      if (voltage < 1)  //if voltage less than 1V
      {
        currentMillis;   //set currentMillis as current time

        if ((millis() - currentMillis) > waitTime) // if (current time minus time voltage was less than 1) is greater than wait time
        {
            ledState = LOW;  //set LED to off
            Serial.print("OFF - TIMED OUT - WAITING FOR INPUT: "); //output message for debug
            Serial.println(state);//current state
           state++;     //increment state (time passed)
        }
            else if ((millis() - currentMillis) < waitTime) // if (current time minus time voltage was less than 1) is less than wait time
         {
          ledState = HIGH;    //set LED to on
         }
      }
      digitalWrite(ledPin, ledState); //send LED status to output
    }

body:
It's hard to know where to start here. :)

---

     if (currentMillis + 500)

OK, what is that doing? It is adding 500 to currentMillis so that will be true almost all the time.

---

    if (status = 3)

That is assigning 3 to status and then checking if it is non-zero, which it will be (it will be 3).

---

    int turnPin = A1;
    ...

      int sensorValue = analogRead(A1);

Why not write:

      int sensorValue = analogRead(turnPin);

---

    float voltage = sensorValue * (5.0 / 1023.0);

You calculate `voltage` but never use it. Why bother?

---

>  As for your question regarding if (currentMillis + 500) I wanted this statement to take the current time and add 500 to it and then check ...

OK, then this is the way to do that:

    // see if 1/2 a second is up
    if (currentMillis - previousMillis >= 500)
       {
       previousMillis = currentMillis;  // reset previousMillis
       ... do something ...
       }

BTW, `previousMillis` is also a variable you weren't using anywhere else.


body:
Thanks for everyone's input. I've come up with the solution.

Using the `while` function I was able to create two "states" for the code to be in. A timed-out state and *not* timed-out state, respectively. While in the timed-out state the output will be 0 and vice-versa for the latter and wait for the voltage to reach 0 for "X" amount of time.

I also integrated a "learn" feature to set the delay based on the alternating input voltage if necessary. Otherwise it will default to the value within the `timeoutWait` variable.

Code is below. Please let me know if you have any input/suggestions.

    /*
      PURPOSE: This application was built for an automotive application. Client replaced OEM turn signal's with aftermarket multicolor
      LED strips controlled by an unknown controller. In order for the turn signal function of the LED strips to work the
      controller had to be powered on. It was undesired to run the LED's every time the vehicle was driven. Therefore, the
      controller needed to be supplied constant power when an input from the OEM turn signal wiring (which alternates 16V/0V/16V/0V...
      and so-forth was applied.

      OVERVIEW: In a nutshell: this application will supply constant output to any specified output (pin 13 in this case) when 5 Volts is
      applied to any specified Analog input (pin A1 in this case). When voltage to the input pin is discontinued after 250milliseconds
      the constant output will be terminated. The application will then wait for voltage to be resupplied to the input pin.

      This application will also support an alternating input source (turn signal in this case). The amount of time to wait before returning
      the output pin to an OFF state is determined one of two methods.

      METHOD 1: Setting a default by amending the timeoutWait variable.
      METHOD 2: Using the Learn Button to time voltage drops and adjust the time-out wait time accordingly (+ 50 milliseconds for any variations in timing)

      USING THE LEARN BUTTON: At any point in time, press and hold the push button for approximately 6-seconds (real time - non simulation). This will
      time the difference in time between Voltage > 1 and Voltage < 1 and set it as the timeoutWait time. NOTE: The variable timeoutWait is not updated!
      The variable blinkRate is updated with this data.

      CIRCUIT: For emulation purposes a circuit was built using a 5V Power Supply connected to an ATTINY microprocessor (to emulate the alternating
      turn signal of 5V/0V/5V/0V alternation every 250milliseconds) connected to pin A1 on an Arduino UNO R3. An LED with a 1kΩ resistor was connected to pin 13.
      The learn button is powered and grounded from the arduino board with a 10kΩ resistor and connected to Digital Pin 2 on the arduino board.*/

    // Constants won't change
    int output = 13;            // Pin to output voltage
    int input = A1;             // Pin to receive voltage
    int learnButton = 2;        // Pin to receive signal for learn mode
    int waitTime = 500;         // Time to wait in milliseconds
    int timeoutWait = 250;      // Time to wait in milliseconds

    // These variables will change
    int relayState = LOW;       // Track what state the relay is in
    bool timeout = false;       // Track if we're timed-out or not
    bool learnMode = false;     // Track if we're supposed to be in learn mode or not
    int blinkRate = 0;          // Store blink interval in millis (obtained from learn mode)
    int lastButtonState = 0;    // Track the last state of the learn button
    int buttonState = 0;        // Track the current state of the learn button

    // The following variables are long's because the time, measured in miliseconds,
    // will quickly become a bigger number than can be stored in an int.
    long timerStart = 0;        // Track when timer started
    long timerStop = 0;         // Track when timer stopped
    long passedTime = 0;        // Track time elapsed =(timerStop - timerStart)
    long blinkStart = 0;        // Track when blink HIGH (learn mode)
    long blinkStop = 0;         // Track when blink LOW  (learn mode)

    void setup()
    {
      pinMode(relayState, OUTPUT); // Set output pin
      pinMode(input, INPUT);       // Set input pin
      pinMode(learnButton, INPUT); // Set input pin (learn mode)
    }

    void loop()
    {
      int sensorValue = analogRead(input);          // Read voltage at input pin
      float voltage = sensorValue * (5.0 / 1023.0); // Convert
      buttonState = digitalRead(learnButton);       // Read the learnButton pin
      Serial.begin(9600);                           //  Begin serial communication

      if (buttonState == HIGH)  // If the learnButton is pressed
      {
        learnMode = true;   // Enter learnMode
      }
      delay(50);        // Debounce

          if (voltage > 1)    // If Voltage is Greater Than 1 Volt
      {
        timeout = false;  // Set timeout state to FALSE since there's no reason to timeout
        passedTime = 0;   // Reset passedTime variable
        timerStart = 0;   // Reset timerStart variable
        timerStop = 0;    // Reset timerStop variable
      }

      if (voltage < 1)  //If Voltage is Less Than 1 Volt
      {
        timerStart = millis();                 // Start the timeout timer
        delay(waitTime);                       // How long should we wait until it times out?
        timerStop = millis();                  // Stop the timeout timer
        passedTime = (timerStop - timerStart); // Calculate how much time we waited

        if (passedTime >= waitTime) //If the calculated time is greater than or equal to our wait time
        {
          sensorValue;      // Re-check the Voltage first

          if (voltage < 1)  // If the voltage is still Less Than 1 Volt
          {
            timeout = true; // Set timeout state to TRUE since the voltage has been less than 1 Volt for >= our Wait Time
            timerStart = 0; // Reseet timerStart variable
            timerStop = 0;  // Reset timerStop variable
            passedTime = 0; // Reset passedTime variable
          }
        }
      }

      while (timeout == true)                    // If TIMEOUT = TRUE
      {
        relayState = LOW;                        // Set the relay state to LOW/OFF
        sensorValue = analogRead(input);         // Read voltage at input pin
        voltage = sensorValue * (5.0 / 1023.0);  // Convert
        digitalWrite(output, relayState);        // Tell the relay to turn off

        if (voltage > 1)    // if the voltage is Greater Than 1 Volt
        {
          timeout = false;  // Set timeout state to FALSE since there's no reason to timeout
          timerStart = 0;   // Reseet timerStart variable
          timerStop = 0;    // Reset timerStop variable
          passedTime = 0;   // Reset passedTime variable

        }

        if (voltage < 1)
        {
          timeout = true; // Set timeout state to TRUE since the voltage has been less than 1 Volt
          timerStart = 0; // Reseet timerStart variable
          timerStop = 0;  // Reset timerStop variable
          passedTime = 0; // Reset passedTime variable
        }
      }

      while (timeout == false)  // If TIMEOUT = FALSE
      {
        sensorValue = analogRead(input);        // Read voltage at input pin
        voltage = sensorValue * (5.0 / 1023.0); // Convert
        relayState = HIGH;                      // Set the relay to ON/HIGH since we're not timed out
        digitalWrite(output, relayState);       // The the relay to turn on
        buttonState = digitalRead(learnButton); // Read the learnButton pin

        if (buttonState == HIGH)  // If the learnButton is pressed
        {
          learnMode = true; // Enter learnMode
        }
        delay(50);        // Debounce

        if (voltage < 1)  // If the voltage is Less Than 1 Volt
        {
          timerStart = millis();                // Start the timeout timer

          if (blinkRate > 100)          // If blinkRate is Greater Than 100
          {
            timeoutWait = blinkRate + 50; // Set timeoutWait to blinkRate value + 50 milliseconds for any variations in timing
          }
          else                // If blinkRate is not Greater Than 100
          {
            timeoutWait = timeoutWait; // Leave default value alone
          }

          delay(timeoutWait);                     // How long should we wait to timeout in this state?
          timerStop = millis();                   // Stop the timeout timer
          passedTime = (timerStop - timerStart);  // Calculate how much time we waited

          if (passedTime >= timeoutWait)  //If the calculated time is greater than or equal to our assigned wait time
          {
            sensorValue;        //Re-check the sensor first

            if (voltage < 1)    //If the sensor read less than 1 Volt
            {
              relayState = LOW; //Set the relay state to OFF/LOW.
              timeout = true;   //Keep us in the timed out state.
              timerStart = 0;   //Reset timerStart variable.
              timerStop = 0;    //Reset timerStop variable.
              passedTime = 0;   //Resed passedTime variable.
            }
          }
        }
      }
      while (learnMode == true)  // If LEARNMODE = TRUE
      {
        sensorValue = analogRead(input);        // Read voltage at input pin
        voltage = sensorValue * (5.0 / 1023.0); // Convert
        Serial.println("LEARN MODE ACTIVE");  // Print to Serial Monitor

        while (voltage > 1)
        {
          sensorValue = analogRead(input);        // Read voltage at input pin
          voltage = sensorValue * (5.0 / 1023.0); // Convert
          blinkStart = millis();          // Set blinkStart as running millis();
          Serial.print("Start: ");          // Print to Serial Monitor
          Serial.println(blinkStart);       // Print to Serial Monitor
          delay(50);                // Debounce
        }
        while (voltage < 1)
        {
          sensorValue = analogRead(input);        // Read voltage at input pin
          voltage = sensorValue * (5.0 / 1023.0); // Convert
          blinkStop = millis();           // Set blinkStop as running millis();
          Serial.print("Stop: ");         // Print to Serial Monitor
          Serial.println(blinkStop);        // Print to Serial Monitor
          delay(50);                // Debounce
        }

        blinkRate = (blinkStop - blinkStart);   // Calculate blinkRate
        Serial.print("Blink Interval: ");     // Print to Serial Monitor
        Serial.println(blinkRate);          // Print to Serial Monitor
        delay(50);                  // Debounce
        learnMode = false;              // Exit learnMode
      }
      digitalWrite(output, relayState);       // Send relayState
    }


message:
Arduino or Raspberry? Self Balancing robot

Here's another one, as you probably have seen before.

I'm finishing college, and I'd like, base of my subscription to be a self balancing robot that can send data to a screen. What kind of data? I am in the brain-storming zone with this question and so far I have:

 - Distance to other objects

 - Time, temperature, direction N-S-W-E, pressure (as in a car where you measure oil temp, tire pressure etc)

 - State of balance (as on y axix, a point going from -y to y where 0 is the balance point)

 - Any othet possible inte-[deleted]-resting thing you could get as a response from a little two-wheels robot

 - Remote control via wireless preferably

Now, the big question. Is arduino the best choice, or should I consider Raspberry Pi?

Thanks in advance!

body:
This depends on the type of screen you want to interface. An Arduino UNO can with big effort interface a VGA signal with very low resolution and only few colors. Better are little screens (like small OLED screens or small LCD displays with integrated controller). Using a more capable Arduino (like the Mega) can extent the capabilities of your project. The RaspberryPi has of course big display capabilities (like 1080p over HDMI).

There is also another side to the problem: A self balancing robot needs to control its motors very fast (changing the direction fastly depending in sensor input). A RaspberryPi is in principle a computer, not a microcontroller. Programs in it don't have a garanteed time of execution, so especially under high load the program might have to wait for its turn, effectively destabilizing the robot. For these real time fast applications a simple microcontroller is fitted better.

Since you also want wireless control you might be interested in using an ESP (WLAN) as a microcontroller.

All in all you should use a microcontroller for driving the balancing logic and motor control. Depending in your needs you can either use only this microcontroller to do all the other things too or connect another board as a master (eg over I2C vor SPI) which tells the microcontroller what to do. For this a raspberryPi is good.

If you provide more information about the concrete target capabilities you might get a better answer. The scope of your project is too open for clear answers.


message:
How to send int[][] as a byte array through Serial

I have `int arr[50][2];` and I need to send it through Serial. But I don't know how to do it. is it possible?

body:
In the comment you write that the receiving end is an Arduino too. Then you can send the data in binary form.

To send the array:

    Serial.write((byte*) arr, sizeof(arr));

 - `(byte*)` is cast of the memory location of arr to a byte array
 - `sizeof` returns the size of the array in bytes

To receive the binary data you must know the size. Here we read 100 16-bit integers:

    Serial.readBytes((byte*) arr, 100 * sizeof(short));

Function [readBytes][1] is one of the 'timed' functions of Stream. It waits for the next byte (until timeout).

If one Arduino is 8-bit and the second is 32-bit, then use the type `short` instead of int, because the size of type int is different, but [the type short is 16 bit long on all Arduinos][2].

  [1]: https://www.arduino.cc/reference/en/language/functions/communication/stream/streamreadbytes/
  [2]: https://www.arduino.cc/reference/en/language/variables/data-types/short/


message:
How to run Arduino code on Linux?

I want to use an MFRC522 module as explained in this [video][1].

But is it possible to get around with Arduino and use a TTL to USB converter to connect RC522 directly to my PC running Ubuntu?

Using the RC222's UART interface, should I rewrite Arduino libraries from scratch for PC or is there a way to easily port the libraries?

  [1]: https://www.youtube.com/watch?v=So83sH6-jwM

body:
Arduino libraries rely on the Arduino API to operate (usually). Things like the Serial object are expected to be defined.

Linux doesn't have any of that stuff, so you would have to implement it all yourself.

There is the "Wiring Pi" project for (obviously) the Raspberry Pi that implements the majority of the Arudino API, but whether that could be made to run on Linux on a PC is anyone's guess.

It may be simpler to just examine the existing library (and datasheet) and implement it yourself in your chosen language.


message:
If I use a biasing circuit for a signal going into an analog input pin, will it affect the ADC operation?

If I have a single 100Hz AC signal biased by two 1 M-ohm resistors (as per schematic below), and then output to an Arduino UNO analog input pin, with the UNO sampling at around 1 kHz using delays, would there be any issues with the ADC result?

[![Biasing circuit][1]][1]

(*Source of schematic: http://tinyurl.com/ycprqsdx*)

From the Atmega328P's spec sheet (the UNO's microprocessor) it recommends an output impedance of 10 k-ohms or less, as shown below.
If I used the pair of 1 M-ohm resistors as a biasing circuit and then deliberately slow down the sampling with delays (i.e.: in loop, do analogRead, then delay, then do analogRead, etc.), would it still be okay?

[![Excerpt from Atmega328P spec sheet][2]][2]

  [1]: https://i.stack.imgur.com/XQBEb.png
  [2]: https://i.stack.imgur.com/0GaAF.png

body:
It will give bad results. You're not slowing down the sampling, you're taking samples at a longer interval - a very different thing.

The Arduino uses a *Successive Approximation* ADC. That uses a clock to control the output of a DAC and compare that voltage with the incoming voltage stored in the S&H capacitor.

In order for the S&H capacitor to get charged to the correct level it has to be connected to the GPIO pin long enough. Since there is only one ADC and 6 analog input pins, it goes through a MUX first.

The delay that needs increasing is the delay between the pin being connected to the capacitor and the capacitor being connected to the ADC.  This is called the *acquisition time*.

The `analogRead()` function does these basic operations in sequence:

1. Connect the SHC to the GPIO pin through the mux.
2. Wait
3. Disconnect the SHC from the GPIO and connect it to the ADC
4. Clock each bit from the comparator to the result registers.

Putting a delay between each analogRead would just delay the connecting of the SHC to the GPIO pin, not increase the time it's connected to the GPIO pin.

You would have to manipulate the ADC registers to do your own sample timing.  Or, just reduce your output impedance.


body: Adding capacitance to the input will help compensate for the high impedance but it also forms a low pass filter. For a 16 MHz Arduino the ADC clock is set to 16 MHz/128 = 125 KHz. Each conversion in AVR takes 13 ADC clocks so 125 KHz /13 = 9615 Hz. That is the maximum possible sampling rate, but the actual sampling rate in your application depends on the interval between successive conversions calls.


message:
how to know the channel i receive information from when i use nRF24L01 to connect between 3 of them

i am using nRF24L01 to connect between 3 of them ( 1 is master and the others are slaves) and i am using nRF24 library , my problem is that when the master receive something from the other slaves and do not know from which channel the infromation come so is there is a way to know from which channel

//master channel code:
  const byte addresses[][6] = {"00001", "00002","00003"};
  radio.openWritingPipe(addresses[1]); // mastr
  radio.openReadingPipe(2, addresses[0]); // carwl
  radio.openReadingPipe(2, addresses[2]); // carwl2

//slave 1 channel code :
  const byte addresses[][6] = {"00001", "00002","00003"};
  radio.openWritingPipe(addresses[0]); // carw1
  radio.openReadingPipe(2, addresses[1]); // mastr

//slave 2 channel code:
  const byte addresses[][6] = {"00001", "00002","00003"};
  radio.openWritingPipe(addresses[0]); // 00003
  radio.openReadingPipe(2, addresses[2]); // 00002

library i use: https://github.com/nRF24/RF24

body:
The nRF24 is highly versatile and can be programmed for a number of different network topologies.  It appears you want either

 1. One-to-many network - where the master node sends data to the slave nodes
 2. Many-to-one network - where the master receives data from many slaves.

Both networks are achieved with the same radio channel (`RF_CH`) on all nodes.

For a one-to-many network you need to have a different RX address for each slave node.  Set the master TX address to the RX address of the corresponding slave  that you want to receive the data.  Done.

For a many-to-one network you are limited to 6 slave nodes.  On the master radio you will need to set the addresses of data pipes 0-5 to the slave TX addresses.  The master will be listening for data on all pipes and signal an interrupt whenever data is received on any of them.

To achieve bi-directional communication with a (practically) unlimited number of slave nodes, your best bet is to use the in-built ACK PAYLOAD feature of nRF24.  In addition to configuring a one-to-many network, you need to enable ACK payload on each radio node.  The procedure to follow is given in the nRF24L01 data sheet.  I can't recommend strongly enough how important that is to read and learn from.  You will be able to send a message from the master to one slave, and get data back from that node in the same radio transmission, auto-retransmit etc included in the bargain.  This way you also know which node the data are coming from - without needed to encode the identity of the slave node in the message.  It's incredible what these little radios will let you achieve!


body:
You can pass the`RF24.available` function a pointer to a variable. The available function will write the pipe-number of the message to that variable.

An [example can be found in the documentation](http://tmrh20.github.io/RF24/classRF24.html#ace7dd139fabc16b77cb8325faa07620f)


message:
One shift delay in receiving the response messages when using two nRF24L01 to communicate with each other

When I send "a" from the Serial Monitor of the slave, on the master slave window it will show "car1_place_2_go = a" then it should show on the slave Serial Monitor "a" but it doesn't show up in the slave serial window until I send another new characters. So there is a 1 delay shift in the messages showed on the slave Serial Monitor.

Master:

<!-- language-all: lang- -->

    #include <SPI.h>
    #include <SoftwareSerial.h>
    #include <nRF24L01.h>
    #include <RF24.h>

    RF24 radio(7, 8); // CE, CSN
    const byte addresses[][6] = {"00001", "00002"};

    char car1_place_2_go;
    char car2_place_2_go;
    char temp_place = 0 ;

    void setup()
    {
      Serial.begin(9600);
      radio.begin();
      radio.openWritingPipe(addresses[1]); // mastr
      radio.openReadingPipe(1, addresses[0]); // carwl

      radio.setPALevel(RF24_PA_MIN);
    }

    void loop()
    {
      delay(5);
      radio.startListening();

      if (radio.available())
      {
        radio.read(&car1_place_2_go, sizeof(car1_place_2_go));
        Serial.print("car1_place_2_go = ");
        Serial.println(car1_place_2_go);

        delay(5);
        radio.stopListening();

        radio.write(&car1_place_2_go, sizeof(car1_place_2_go));
      }
    }

Slave:

    #include <SPI.h>
    #include <SoftwareSerial.h>
    #include <nRF24L01.h>
    #include <RF24.h>

    RF24 radio(7, 8); // CE, CSN
    const byte addresses[][6] = {"00001", "00002"};

    char car1_place_2_go;
    char car2_place_2_go;

    void setup() {
      Serial.begin(9600);
      radio.begin();
      radio.openWritingPipe(addresses[0]); // 00003
      radio.openReadingPipe(1, addresses[1]); // 00002

      radio.setPALevel(RF24_PA_MIN);
    }

    void loop()
    {
      if (Serial.available() > 0)
      {
        car2_place_2_go = Serial.read();

        delay(5);
        radio.stopListening();

        radio.write(&car2_place_2_go, sizeof(car2_place_2_go));

        radio.startListening();

        if ( radio.available())
        {
          char text[32] = "";
          radio.read(&text, sizeof(text));
          Serial.println(text);
        }
      }
    }

Library I use: https://github.com/nRF24/RF24

body:
i found the problem is that the receiver in the slave doesn't see what send to it until the next loop and that mean it need a delay so it can see what transmit to it so i add this while loop in the slave so the slave doesn't exit the "void loop" function until it get the message from the master

slave

     radio.startListening();

        while(! radio.available())
        {

        }
        if ( radio.available())
        {
            char text[32] = "";
            radio.read(&text, sizeof(text));
            Serial.println(text);
         }


message:
ISP with 115200 baud

I have a serial ISP programmer of protocol type "stk500v1" which expects 115200 baud data rate. I have used it successfully with Atmel Studio by calling avrdude manually (custom tool) in the past. This just involves the avrdude option

> -b 115200

But recently I wanted to do use the Arduino software instead of Atmel Studio for a quick mockup. But everytime I try to "Upload with Programmer", the avrdude commandline includes the option

> -b 19200

and so the programming fails.

I can make it work by changing the hard wired serial rate in the programmer from 115200 to 19200, but then of course the programming is dead slow, which I don't want.

I have also looked for a baudrate entry for stk500v1 in "avrdude.conf", but didn't find any. How can I change the baud rate for "Upload with programmer" in the Arduino software?

body:
You have to edit the `programmers.txt` file. (The one in `~/.arduino15/packages/arduino/hardware/avr/1.6.21/`, _not_ the one in `arduino-1.8.x/hardware/arduino/avr/`)

    avrisp.name=AVR ISP
    avrisp.communication=serial
    avrisp.protocol=stk500v1
    avrisp.program.protocol=stk500v1
    avrisp.program.speed=115200
    avrisp.program.tool=avrdude
    avrisp.program.extra_params=-P{serial.port} -b{program.speed}

Add a `avrisp.program.speed` option, and pass this option as one of the `extra_params` to the command line call of avrdude.
It is then used on [line 112](https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/platform.txt#L112) of `platform.txt`:

    tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} {program.verify} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

You could of course also make a copy of that avrisp entry, and add your own programmer, just give it a different name.


message:
How to store an RFID tag number in a string

I want to send RFID tag number to PHP page. So far I have sent a fixed string to php and it worked, now I am not getting data in string when i scan rfid tag. I want to store every RFID tag number in a string when it is scanned, so that I can send it to php page.

    if (rfid.isCard()) {

        String rfid_uid = "";
        if (rfid.readCardSerial()) {
            String rfid_uid = "";
            for (int i = 0; i < 4; i++) {
                Serial.print(rfid.serNum[i], HEX);
                rfid_uid = rfid.serNum[i];
            }

            Serial.println();
        }
        //delay(7000);
        Serial.print("User ID \n");
        Serial.println(rfid_uid);
        make_request(rfid_uid);
    }

This is the path to php page

             String method = "GET /ethernet/data.php?rfid_uid=";

body:
    String rfid_uid = "";
    if (rfid.readCardSerial()) {
        String rfid_uid = "";
        for (int i = 0; i < 4; i++) {
            Serial.print(rfid.serNum[i], HEX);
            rfid_uid = rfid.serNum[i];
        }

        Serial.println();
    }

This code has multiple problems:

* the variable `rfid_uid` is defined twice, they are overshadowing each other. The inner part only assigns a value to the `rfid_uid` delcared in the inside of the `if` statement, the outer `rfid_uid` will remain empty
* As you can see with `Serial.print(rfid.serNum[i], HEX);`, the element `rfid.serNum[i]` is an integer, which is printed as hex. (e.g. 123 = `7B`), in `rfid_uid = rfid.serNum[i];` you however assign the direct numerical value, without converting it to hex

You can try the following, if you want the serial number as a 4 byte hex string:

    String rfid_uid = "";
    if (rfid.readCardSerial()) {
        for (int i = 0; i < 4; i++) {
            String uid_part = String(rfid.serNum[i], HEX);
            Serial.print(uid_part);
            rfid_uid += uid_part;
        }

        Serial.println();
    }
    //rest as before

This should construct a `String` object from the integer in `HEX` format and append (using the `+=` operator it to the `rfid_uid` string). Thus, after 4 iterations, the `String` value is built up and can be used in the request.


body:
[do not use String][1]

    char url[64];
    sprintf(url, "GET /ethernet/data.php?rfid_uid=xxxx", rfid[0], rfid[1], rfid[2], rfid[3]);

  [1]: https://hackingmajenkoblog.wordpress.com/2016/02/04/the-evils-of-arduino-strings/


message:
Digital output from one nano to digital input of another.

Can I connect the digital out of one arduino to a digital input of another? To detect a high/low state...
One powered in one room on USB. The other in another room separate psu (connecting the grounds).
I know I can use tx/rx serial. But if the other way would work, less programming and 1 wire less..

body:
Yes, you can. As you noted, you do need to connect the grounds of both Arduinos.

For some extra protection you could put a resistor between the output and the input. For example a 1kOhm. That way, if you accidentally set both pins as outputs, or plug the wire in the incorrect pin, you won’t get a dead-short.


message:
TimerOne Library - Response time

I'm trying to write a library for (rather slow) communication with visible light and have recently tried to include the TimerOne library as a timer.
I want to send bits at 2kHz, so with a period of 500µs. I'm initializing the `Timer1` with 500(µs) like this and then attach an interrupt to it to call my transmit function:

    Timer1.initialize(500);
    Timer1.attachInterrupt(transmitBit);

However, when I try to measure the period with a logic analyzer, it tells me that there is actually a period of 2,000µs. Could this be due to some overhead created by the library? Where else could the problem be?

If you need any other information just let me know and I'll try to provide it.

Thanks in advance for your feedback.

**EDIT:** I've just tried adding the period as a parameter to the `attachInterrupt` like so:

    Timer1.attachInterrupt(transmitBit, 500);

And now I'm measuring a period of 30µs for whatever reason? Can anyone explain me what's going on?

**EDIT:** This is the rest of my (relevant) code:

    Transmitter::Transmitter()
    {
      [...]
      Timer1.initialize(500);
    }

    Transmitter* Transmitter::_instance;

    void Transmitter::start() {
      _instance = this;
      Timer1.attachInterrupt(_transmitBit, 500);
      _active = true;
    }

    static void Transmitter::_transmitBit() {
      _instance->transmitBit();
    }

    void Transmitter::transmitBit() {
      if(_active) {
        //Preperation
        if(!_manHalf) { //only change the state when the manchester bit is completely transmitted.
          if(_busy) {
            //Serial.println("Transmitting!");
            /** if there is currently a transmission running
              * read the next bit from the frame
              */
            _state = *(_frame + _pos);
            if(_pos >= _frameSize) {
              _busy = false;
              _state = 0;
              _pos = 0;
            }
            _pos++;
          } else { //else transmit the idle pattern
            _state = 0;
          }
        }
        //Transmission
        if (!_manHalf) {
          digitalWrite(_pin, !_state);
        } else {
          digitalWrite(_pin, _state);
        }
        _manHalf = !_manHalf;
      } else {
        digitalWrite(_pin, HIGH);
      }
    }

body:
Before using libraries, try to see whether you can manipulate the timer registers directly to achieve what you want.  You may find it is easier!

In the following example I assume you are using an ATmega328 chip.  The code may be slightly different for other microcontrollers.  In that case you can read the data sheets for both microcontrollers and work out what you need to change.

I also assume the data you want to transmit is stored in a byte array.  Initialize the data how you prefer.

e.g: ` byte my_data[10] = {0,0,0,0,0,0,0,0,0,0};`

Next, you want to initialize timer1 in the main loop

    TCCR1A=0;
    TCCR1B=0;

To send data at 2000 bits per second, the following settings can be used

    ICR1=124; // Timer counter resets to 0 after reaching 124
    OCR1A=125;
    OCR1B=125; // other counter match registers must be higher than ICR1
    TCCR1A=B00000010; // waveform generation mode 14, fast PWM, ICR1=top
    TCCR1B=B00011011; // clock scaler 64, 1 count = 4 us.  125*4 us = 500 us
    TIFR1 |= (_BV(ICF1) | _BV(OCF1A) | _BV(OCF1B)); // Clear match flags

This will set the timer1 match register bit `ICF1` every 500 us.  There are several ways of using the timer to send the data.  My preference would be to poll the match flag.  The timing precision is about as good as you can get - a couple of clock cycles:

    loop_until_bit_is_set(TIFR1,ICF1); // wait until TCNT1=ICR1
    TIFR1 |= (_BV(ICF1) | _BV(OCF1A) | _BV(OCF1B)); // clear match flags
    // switch digital output high or low depending on data bit to be sent

One way is to run a state machine loop like this:

    unsigned int state;

    void setup(){
    state=0;
    }

    void loop(){
    switch (state){
    case 0: // idle or receiving data to be sent
    TCCR1A=0;
    TCCR1B=0;
    // insert other code here
    // conditional function, when message data received, set state=1;
    break;

    case 1: // setup timer
    ICR1=124; // Timer counter resets to 0 after reaching 124
    OCR1A=125;
    OCR1B=125; // other counter match registers must be higher than ICR1
    TCCR1A=B00000010; // waveform generation mode 14, fast PWM, ICR1=top
    TCCR1B=B00011011; // clock scaler 64, 1 count = 4 us.  125*4 us = 500 us
    TIFR1 |= (_BV(ICF1) | _BV(OCF1A) | _BV(OCF1B)); // Clear match flags
    state=2;
    break;

    case 2:
    loop_until_bit_is_set(TIFR1,ICF1); // wait until TCNT1==ICR1
    TIFR1 |= (_BV(ICF1) | _BV(OCF1A) | _BV(OCF1B)); // clear match flags
    // switch digital output high or low depending on data bit to be sent

    // add conditional function so that when you are finished sending data, reset to state=0;
    break;

    }
    }

As always, please upvote if you find this helpful.


message:
Is there any library for use Arduino Uno with esp8266-01 module?

I have a Arduino Uno and the esp8266 module,(NOT THE SHIELD).

I was looking for some library that I could use to connect to Wifi and set a webserver, but I can't find anything. I just found for Arduino Wifi Shield which uses SPI.

It is possible to use arduino lets say to read a LM35 and then send that data to the ESP8266 module and serve it in a page as webserver?

I know that I can use AT commands with ESP8266 to connect to wifi and to create a server, but I cannot find any function to set the data to be served.

https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf

body: Why involve the UNO at all.  The ESP88266 could be programmed with the Arduino IDE to read the sensor and deal with the internet all by itself.  It doesn't need the UNO to do what you want.


body:
You didn't google hard enaugh.

There are plenty of examples serving your environment.

This [instructables](http://www.instructables.com/id/Simple-Webserver-Using-Arduino-UNOMega-and-ESP8266/) is just one of it.

> The main aim of this instructable is to show how you can create a simple web server using Arduino and Wi-Fi module which displays the sensor data in the webpage.


body:
For a webserver, program the ESP8266 directly. This allows you to make use of the internal SPI flash memory to store your webpages. You can't do this with AT commands.

The Arduino UNO does not have enough processing power and/or memory for advanced internet stuff. If you want a webserver over AT commands, the Arduino has to do all the hard work, the ESP8266 is just a dumb slave that establishes a TCP connection.
The ESP8266 is much faster, and has many times more memory, so it makes sense to let it do all the heavy lifting.

Take a look at this guide:
[ESP8266 temperature logger][1]

You can copy pretty much all code, but instead of measuring the temperature from an actual sensor, read it from the `Serial` input.

Then just connect the Arduino to the ESP8266 over Serial (or SPI or I²C or SoftwareSerial, whatever you prefer), and have it send the temperature to the ESP8266, for example every second.

To program the ESP8266, you can use the USB-to-Serial adapter of one of your Arduinos.

***

In this case, where you just want to read a single LM35, you could even use only the ESP8266. It is true that the LM35 requires at least 4V, but this is not a problem, since most ESP8266 dev boards also provide a 5V supply. The analog input range of 0-1.0V would allow for a temperature up to 100°C.

  [1]: https://tttapa.github.io/ESP8266/Chap16 - Data Logging.html