body:
I am trying to put a web server on my Wemos D1 mini pro. I am using this example for the Arduino code:
https://github.com/wemos/Arduino_D1/blob/master/doc/esp8266wifi/server-examples.rst
<!-- language-all: lang-cpp -->

    #include <ESP8266WiFi.h>

    const char* ssid = "GL-AR300M-ceb";
    const char* password = "********";

    WiFiServer server(80);

    void setup()
    {
      Serial.begin(115200);
      Serial.println();

      Serial.printf("Connecting to %s ", ssid);
      WiFi.begin(ssid, password);
      while (WiFi.status() != WL_CONNECTED)
      {
        delay(500);
        Serial.print(".");
      }
      Serial.println(" connected");

      server.begin();
      Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
    }

    // prepare a web page to be send to a client (web browser)
    String prepareHtmlPage()
    {
      String htmlPage =
         String("HTTP/1.1 200 OK\r\n") +
                "Content-Type: text/html\r\n" +
                "Connection: close\r\n" +  // the connection will be closed after completion of the response
                "Refresh: 5\r\n" +  // refresh the page automatically every 5 sec
                "\r\n" +
                "<!DOCTYPE HTML>" +
                "<html>" +
                "Analog input:  " + String(analogRead(A0)) +
                "</html>" +
                "\r\n";
      return htmlPage;
    }

    void loop()
    {
      WiFiClient client = server.available();
      // wait for a client (web browser) to connect
      if (client)
      {
        Serial.println("\n[Client connected]");
        while (client.connected())
        {
          // read line by line what the client (web browser) is requesting
          if (client.available())
          {
            String line = client.readStringUntil('\r');
            Serial.print(line);
            // wait for end of client's request, that is marked with an empty line
            if (line.length() == 1 && line[0] == '\n')
            {
              client.println(prepareHtmlPage());
              break;
            }
          }
        }
        delay(1); // give the web browser time to receive the data

        // close the connection:
        client.stop();
        Serial.println("[Client disonnected]");
      }
    }

It uploads fine and when I open the serial monitor get this:

Connecting to GL-AR300M-ceb . connected
Web server started, open 192.168.8.119 in a web browser

When I go to the IP address that it gives in the monitor, I only see a blank page. I also can't inspect element, so it doesn't load the HTML part I guess.
When I change the code like this:

    if (client.available())
    {
    //        String line = client.readStringUntil('\r');
    //        Serial.print(line);
    //        // wait for end of client's request, that is marked with an empty line
    //        if (line.length() == 1 && line[0] == '\n')
    //        {
    //          client.println(prepareHtmlPage());
    //          break;
    //        }
              client.println(prepareHtmlPage());
          }

then i see this
 [![screenshot of code as plain text in browser][1]][1]

  [1]: https://i.stack.imgur.com/gLZHI.png

And when i add the break in the code like so:

    client.println(prepareHtmlPage());
    break;

in the code, i get the blank page again.

Does someone have an idea what the problem might be?

title: Creating a webserver on a Wemos D1 mini pro

Answers: 1

body:
you should go for the "Advanced Webserver" example provided by the ESP8266 libraries in your Arduino IDE.
The webserver is using callbacks like

    server.on ( "/", handleRoot );
 server.on ( "/test.svg", drawGraph );

and so on.
Then you can use these handles to give back a html page to your browser like

    server.send(200, "text/plain", message);       //Response to the HTTP request

**Note how the function returns an 200 http code to your browser, which is mandatory for showing up your web page!**


body:
I'm trying to drive 16 of these little [steppers][1] on an Arduino Uno.

Each test driver uses 4 digital pins for control (2 for each coil) so that would be 64 pins I will need.

I'm thinking either getting something like [this][2] or 4 of [these][3].

Would something like that work ?
What's the most straight forward way to drive these on an Arduino Uno ?

  [1]: https://www.amazon.co.uk/28BYJ-48-Stepper-ULN2003-Arduino-Raspberry/dp/B07857HCWN/ref=sr_1_6?s=electronics&ie=UTF8&qid=1527686132&sr=1-6&keywords=5v+stepper
  [2]: https://uk.farnell.com/macetech/mtcen001/centipede-shield-gpio-expander/dp/2804676?langId=44&CMP=KNC-GUK-GEN-SHOPPING&catalogId=15001&storeId=10151&storeId=10151&krypto=pzWhyQJMteR7S5tpgdfh0160J+TS6ciZYF0/MAHkFV0hn5KvS3XeXtTtxa4MR4XJHizFO1kjn3awnXz3lLkWcjk/UoSzq558CKaBud8xr21N/e4vL3nv6hw0nScKvdmburI7nFVUexkGx5bTIJXYf2Wg8CIHyjMD7Id+HLOosfa4gshkvBG8eUU35TnUItBMeRaqrFJWC+7LPgs5aM8ebMKLsrPF+KnKuI8R9JLH6t4EU5BMXH6ldjzUyQKOJJZH/s5/9dORc59h/kWLOD6GtB0RiiJarK6PvtknLm/whS2543RYRJJLDYmhPdw+KNXswjECe5zC1+LznJXT3nK4Bs5WmUpD+SUIBsvxQUIefnAmA5ZLVQO5ggsMNhmOoOx8gDfX7FGZrQ1mlUGwKUxmmV76eBzfkyf0eBGVyKERD/+bXrPgYnVb7Mr/tob0uWHmFImcE1y0yiZRf90kpCWJyUXB4MO2s+fa3cxDtrIQOFdSv+AHFJwJ3eXv8L2k4kEqi+SK77EUXkgeU7aiHUjHZs0k4gPlMfuu6ZvGGLRZPRv3NTwxW1CMQFRiWgwVXnKdPEUPDAnzEng0GpDd31VPSifqhxhrfhvYTAx2BfbqE8ZRqj+kQy9jcIi3XiZwrSY4MuYPJzCgy2nQNLzGqA1yjQ==
  [3]: https://coolcomponents.co.uk/products/16-output-i-o-expander-breakout-sx1509

title: How to drive 16 stepper motors with Arduino?

Answers: 1

body:
If you need to drive all 16 simultaneously and independently, the Uno may not have enough capability to do it. Consider the worst-case number of motors and highest rate(s) you expect to drive at once, plus anything else you need the Uno doing at the same time. You might try a simple sketch to do all of these things (substituting LEDs for the motor drivers) at once, and use a scope to examine those LED output signals for the right frequency, wave-form, and lack of jitter. Without I/O expanders, you won't get to 16 motors' worth of outputs (unless you already have an I/O expander) but you might try doubling up on the existing output (use non-overlapping motor phases if you can).

If the Uno can manage that with clean outputs, you'll have a better idea whether it can manage the full load. If it doesn't, you may need to reconsider your choice of processor with respect to its clock-speed, both kinds of memory (depending on what you learned), number of outputs, possibly number of available timers and of interrupts.


body:
I know that you go to *preferences.txt* and there is `editor.font=` line setting, but I can't get what font name to type in there to use **Ubuntu Mono**. I would like to use that font please. I've tried:

    Ubuntu_Mono
    Ubuntu-Mono
    Ubuntu Mono
    Ubuntu+Mono
    Ubuntu.Mono
    UbuntuMono
    Ubuntumono
    ubuntumono
    'Ubuntu Mono'
    "Ubuntu Mono"
    'UbuntuMono'
    "UbuntuMono"
    'Ubuntu-Mono'
    "Ubuntu-Mono"
    'Ubuntu_Mono'
    "Ubuntu_Mono"
Thanks for answer :]

PS: Yes, I've restarted the studio every time, but some non-monotype/default font showed up.

title: Arduino IDE - Ubuntu Mono Font Name?

Answers: 1

body:
You need to specify the font, style and size.  I think you want

    editor.font=Ubuntu Mono,plain,12

I don't know the exact name you should use for the font but you must have all three fields separated by commas.

The second field can be "plain", "bold" or "italic".

The third field is the font size, I'm not sure the units.


body:
I'm trying to get an arduino sending data to node but with no success.
I'm connecting to an ar-drone 2.0 as in https://gist.github.com/maxogden/4152815

Here is my **Arduino** code:

        #include <TinyGPS++.h>
        #include <SoftwareSerial.h>
        #include <Wire.h>
        #include "Adafruit_HTU21DF.h"
        /*
          Sketch per creare json contenente
          lat,lon,data,ora,temp, hum
        */
        static const int GPS_RXPin = 16, GPS_TXPin = 10;
        static const uint32_t GPSBaud = 9600;

        Adafruit_HTU21DF htu = Adafruit_HTU21DF();

        // The TinyGPS++ object
        TinyGPSPlus gps;

        // The serial connection to the GPS device
        SoftwareSerial ss(GPS_RXPin, GPS_TXPin);

        //JSON
        const size_t bufferSize = JSON_OBJECT_SIZE(6);
        DynamicJsonBuffer jsonBuffer(bufferSize);
        JsonObject& oData = jsonBuffer.createObject();

        void setup()
        {
          Serial1.begin(9600);
          Serial.begin(9600);
          ss.begin(GPSBaud);
          if (!htu.begin()) {
            Serial1.println("Couldn't find Adafruit_HTU21DF!");
            while (1);
          }
        }

        void loop()
        {
          float lat = gps.location.lat();
          float lon = gps.location.lng();
          float date = gps.date.value();
          float timestamp = gps.time.value();
          float temp = htu.readTemperature();
          float hum = htu.readHumidity();

          Serial1.print(lat);
          Serial1.print(";");
          Serial1.print(lon);
          Serial1.print(";");
          Serial1.print(date);
          Serial1.print(";");
          Serial1.print(timestamp);
          Serial1.print(";");
          Serial1.print(temp);
          Serial1.print(";");
          Serial1.print(hum);
          Serial1.print(";\n");

          //////

          Serial.print(lat);
          Serial.print(";");
          Serial.print(lon);
          Serial.print(";");
          Serial.print(date);
          Serial.print(";");
          Serial.print(timestamp);
          Serial.print(";");
          Serial.print(temp);
          Serial.print(";");
          Serial.print(hum);
          Serial.print(";\n")

          smartDelay(1000);
          if (millis() > 5000 && gps.charsProcessed() < 10)
            Serial1.println(F("No GPS data received: check wiring"));
        }

        // This custom version of delay() ensures that the gps object
        // is being "fed".
        static void smartDelay(unsigned long ms)
        {
          unsigned long start = millis();
          do
          {
            while (ss.available())
              gps.encode(ss.read());
          } while (millis() - start < ms);
        }

and this my **NodeJS** code:

        var serialport = require('node-serialport');
        var WebSocketServer = require('ws').Server;

        var wss = new WebSocketServer({host:'0.0.0.0',port: 9999});
        var sp = new serialport.SerialPort("/dev/ttyO3", {
          parser: serialport.parsers.readline("\n"),
          baud: 9600,
          buffersize: 65536
        });

        wss.on('connection', function(ws) {
          ws.send('connected');
          ws.on('message', function(message) {
            console.log('received: %s', message);
          });
          sp.on('data', function(chunk) {
            var fromArduino = chunk.toString();
            ws.send(fromArduino);
            console.log(fromArduino);
          });
        });

While the CSV comes out nice on Arduino IDE serial monitor, it is all messed up both on ws and node console.

[![drone console shows messed up strings, adruino ide monitor shows them fine][1]][1]

I'm using this version of NodeJS and node-serial: https://github.com/felixge/node-cross-compiler/downloads

and set ttyO3 as in https://gist.github.com/maxogden/4152815

A voltage diveder is set between drone RX and Arduino TX1 to lower signal from 5v to 1.8v.

Thanks for any help!

Lorenzo

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

----------
**UPDATE 2 JUN 2018**
I managed to make things a little bettere with the following code:
**ARDUINO:**
        #include <TinyGPS++.h>
        #include <Wire.h>
        #include "Adafruit_HTU21DF.h"
        /*
          Sketch per creare json contenente
          lat,lon,data,ora,temp, hum
        */
        static const uint32_t GPSBaud = 9600;

        Adafruit_HTU21DF htu = Adafruit_HTU21DF();

        // The TinyGPS++ object
        TinyGPSPlus gps;

        void setup()
        {
          Serial1.begin(9600);
          //  Serial.begin(9600);
          if (!htu.begin()) {
            Serial1.println("Couldn't find Adafruit_HTU21DF!");
            while (1);
          }
        }

        void loop()
        {
          while (Serial1.available()) {
            gps.encode(Serial1.read());
          }
          float lat = gps.location.lat();
          float lon = gps.location.lng();
          int date = gps.date.value();
          float timestamp = gps.time.value();
          float temp = htu.readTemperature();
          float hum = htu.readHumidity();

          Serial1.print(lat);
          Serial1.print(";");
          Serial1.print(lon);
          Serial1.print(";");
          Serial1.print(date);
          Serial1.print(";");
          Serial1.print(timestamp);
          Serial1.print(";");
          Serial1.print(temp);
          Serial1.print(";");
          Serial1.print(hum);
          Serial1.print(";_");
          Serial1.println();
        }

**NODE JS**:

        var serialport = require('node-serialport');
        var WebSocketServer = require('ws').Server;

        var wss = new WebSocketServer({host:'0.0.0.0',port: 9999});
        var sp = new serialport.SerialPort("/dev/ttyO3", {
          parser: serialport.parsers.readline("_"),
          // parser: serialport.parsers.raw,
          baud: 9600,
          buffersize: 1024
        });
        wss.on('connection', function(ws) {

          sp.on('data', function(chunk) {
            var fromArduino = chunk.toString();
            // console.log(fromArduino);
            ws.send(fromArduino);
            sp.flush();
          });
        });

Now data comes out tidy on both console and ws for most of the times: I guess the problem was the serialport buffersize.

I also removed serial software from Arduino code.

title: arduino nodejs serial data chunked and not in synch

Answers: 1

body:
      Serial.print(lat);
      Serial.print(";");
      Serial.print(lon);
      Serial.print(";");
      Serial.print(date);
      Serial.print(";");
      Serial.print(timestamp);
      Serial.print(";");
      Serial.print(temp);
      Serial.print(";");
      Serial.print(hum);
      Serial.println(";");

`Serial.println` will print an `\r\n` at the end ([source][1]). `\r` is a "carriage return" which will move the curser back to the beginning of the line.

Since you are reading your data with a parser that looks for `\n` and removes that, you are left with a string that looks like  `[csv data..]\r`. Once you print that to console verbatim you get the behaviour you are looking at.

Replace `Serial.println(";");` by `Serial.print(";\n");` (same for `Serial1`) and see what happens.

  [1]: https://www.arduino.cc/en/serial/println


body:
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.

title: Compile Problem with RFDuino RFD22301

Answers: 1

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.


body:
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);
    }

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

Answers: 1

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.


body:
I am currently working on a display library. The font should be stored in PROGMEM. The code looks something like this:

<!-- language: c++ -->

    unsigned int i = 0;
    Serial.println(pgm_read_byte(&font[1]),HEX);
    unsigned char width = pgm_read_byte(&font[0]);
    unsigned char height = pgm_read_byte(&font[1]);
    unsigned char spacing = pgm_read_byte(&font[2]);

The strange thing is that the code breaks (Serial spits out random characters, OLED displays only noise or nothing) when I remove the

    Serial.println(pgm_read_byte(&font[1]),HEX);

If I replace it with something like

    Serial.println("Hello World!");

the code breaks as well, but in a different way. I think pgm_read_byte() returns different things with different Strings in the Serial.println() function.

Is there something going on with the compiler? Are there some optimization options that I should change? Or am I doing it completely wrong?

Here is the whole function:

<!-- language: c++ -->

    /**
     *
     * Displays text using a predefined sprite in PROGMEM
     * Only fonts with a uniform letter spacing are supported
     * The font must have the following format
     * Byte   Description
     *  0.    X width of one letter in pixel
     *  1.    Y height of one letter in bytes (8 pixel)
     *  2.    letter spacing in pixels
     *  3.    data
     *  .      .
     *  .      .
     *  .      .
     *  N.    data
     *
     * The data is arranged like this
     *    | 0 | 1 | 2 | 3 | 4 | ... |126|127
     *     b0  b1  b2
     *     b3  b4  b5
     *    LSB D0
     * In each byte the data is displayed like this
     *    .
     *    .
     *    .
     *    MSB D7
     *
     * A font starts with the symbol "!" (ASCII 33) and ends with the symbol "~" (ASCII 126).
     * Each symbol in between has to be present. The letters have to be arranged like this
     * Letter     A       B       C
     * Bytes    b0 b1   b2 b3   b4 b5
     *          b6 b7   b8 b9  b10 b11
     *
     * @param unsigned char disp[]          the display buffer where the text should be shown
     * @param const unsigned char font[]    the font in PROGMEM
     * @param const char *string            the string to display
     * @param unsigned char X               x location
     * @param unsigned char Y               y location
     * @param int mode                      blend mode
     */
    void gfx::text(unsigned char disp[], unsigned char *font, const char *string, unsigned char X, unsigned char Y, int mode){
      unsigned int i = 0;
      Serial.println(pgm_read_byte(&font[1]),HEX);
      unsigned char width = pgm_read_byte(&font[0]);
      unsigned char height = pgm_read_byte(&font[1]);
      unsigned char spacing = pgm_read_byte(&font[2]);
      while(string[i])
      {
        if(string[i] > 32 && string[i] < 127){  //only display valid characters, otherwise leave a blank spot
          unsigned char s[width*height];
          unsigned char c = string[i] - 33;
          //transfer pixel with and height to the sprite
          s[0] = width;
          s[1] = height;
          //copy the other bytes
          for(int y = 0; y < height; y++){
            for(int x = 0; x < width; x++){
              unsigned int sprite_pointer = 2 + width*y + x;
              unsigned int font_pointer = 3 + c*width + x + y*width*93;
              s[sprite_pointer] = pgm_read_byte(&font[font_pointer]);
            }
          }
          sprite(disp,s,X+i*(width + spacing),Y,mode);
        }
        i++;
      }
    }

title: Strange things happening with Arduino PROGMEM

Answers: 0


body:
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();
    }

title: How to create "Auto switch case"

Answers: 1

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.


body:
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?

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

Answers: 2

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.


body:
 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());
      }
    }

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

Answers: 1

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.


body:
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);
      }
    }

title: Arduino Switching Between Loops IR Remote

Answers: 2

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.


body:
I'm trying to read out GPS positions from a serial GPS module I have.

I'm using an Arduino Ethernet and a Haicom HI-204 III GPS (http://www.haicom.com.tw/driver/hi-204iii_usb.pdf).

If I connect the GPS directly to my computer (through a USB-serial converter) at 4800 baud, 8N1, I receive a nice stream of position and diagnostics messages:

    $GPGGA,183652.000,5702.0870,N,00954.4732,E,1,06,2.0,20.5,M,42.5,M,,0000*62
    $GPGSA,A,3,22,08,27,18,11,32,,,,,,,3.4,2.0,2.7*37
    $GPRMC,183652.000,A,5702.0870,N,00954.4732,E,0.00,,310518,,,A*70
    $GPGGA,183653.000,5702.0870,N,00954.4732,E,1,06,2.0,20.5,M,42.5,M,,0000*63
    $GPGSA,A,3,22,08,27,18,11,32,,,,,,,3.4,2.0,2.7*37
    $GPRMC,183653.000,A,5702.0870,N,00954.4732,E,0.00,,310518,,,A*71
    $GPGGA,183654.000,5702.0870,N,00954.4732,E,1,06,2.0,20.5,M,42.5,M,,0000*64
    $GPGSA,A,3,22,08,27,18,11,32,,,,,,,3.4,2.0,2.7*37
    $GPGSV,3,1,12,08,67,204,28,18,59,267,23,10,47,067,26,11,46,279,32*72
    $GPGSV,3,2,12,27,36,156,30,01,33,270,20,32,31,116,32,28,26,314,18*79
    $GPGSV,3,3,12,22,21,217,33,14,15,140,24,20,09,055,,24,04,038,*7D
    $GPRMC,183654.000,A,5702.0870,N,00954.4732,E,0.00,,310518,,,A*76
    $GPGGA,183655.000,5702.0870,N,00954.4732,E,1,06,2.0,20.5,M,42.5,M,,0000*65
    $GPGSA,A,3,22,08,27,18,11,32,,,,,,,3.4,2.0,2.7*37
    $GPRMC,183655.000,A,5702.0870,N,00954.4732,E,0.00,,310518,,,A*77
    $GPGGA,183656.000,5702.0870,N,00954.4732,E,1,06,2.0,20.5,M,42.5,M,,0000*66

Now I'm trying to read these messages from the Arduino. But when I connect the GPS to a SoftwareSerial port, I only get gibberish:

>:⸮⸮J2⸮⸮>>⸮

(note that when I copy/paste the output to here, many of the charaters disappear, so they are probably completely invalid)

My code looks like this:

    #include <SoftwareSerial.h>

    #define rxPin 3
    #define txPin 4

    SoftwareSerial gpsSerial(rxPin, txPin); // RX, TX

    void setup (){
      Serial.begin(4800);
      gpsSerial.begin(4800);
    }

    void loop (){
      while (gpsSerial.available()) {
        char c = gpsSerial.read();
        Serial.write(c);
      }
    }

In think the output looks like wrong serial settings, but I have tested all speeds (and verified that 4800 baud works through the serial adapter), and as far as I can tell, SoftwareSerial is 8N1 by default.

What am I doing wrong?

title: Serial communication between GPS and Arduino Ethernet

Answers: 0


body:
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?

title: won't verify a simple code

Answers: 1

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


body:
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.

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

Answers: 2

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


body:
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
    }

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

Answers: 2

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
    }


body:
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!

title: Arduino or Raspberry? Self Balancing robot

Answers: 1

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.


body:
I have a bitmap to draw defined as below.
<!-- language-all: lang-cpp -->

    PROGMEM const unsigned char ship1 [] = {0x18, 0x3C, 0x7E, 0xFF, 0x81, 0xC3};

It is then used by the `arduboy` library's draw slow bitmap function like so:

    arduboy.drawSlowXYBitmap(5,5, ship1, 8 , 6, WHITE);

Can anyone explain to me why the bitmap only draws correctly with the `PROGMEM` keyword? I omitted it at first and it causes the bitmap to look completely different.

I see that this keyword makes the data get written to flash instead of SRAM.

The hardware I am using is the Arduboy.

The `arduboy.drawSlowXYBitmap()` function is from https://github.com/Arduboy/Arduboy

    void Arduboy::drawSlowXYBitmap
    (int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color)
    {
      // no need to dar at all of we're offscreen
      if (x+w < 0 || x > WIDTH-1 || y+h < 0 || y > HEIGHT-1)
        return;

      int16_t xi, yi, byteWidth = (w + 7) / 8;
      for(yi = 0; yi < h; yi++) {
        for(xi = 0; xi < w; xi++ ) {
          if(pgm_read_byte(bitmap + yi * byteWidth + xi / 8) & (128 >> (xi & 7))) {
            drawPixel(x + xi, y + yi, color);
          }
        }
      }
    }

Imagine two programs identical apart from the `PROGMEM` keyword. The program only contains the lines mentioned above and the relevant calls to refresh the display. What I want an explanation of is why I get a garbled image without it and a fine image with it.

title: Bitmap only displays correctly with PROGMEM keyword

Answers: 0