text:
Touch Board from Bare Conductive not uploading arduino code example
I have an issue with this example https://github.com/BareConductive/mpr121/tree/public/MPR121/Examples/SimpleTouch when trying to upload it. Also, there was an issue when compiling it, however, the arduino suggested the change (wrong naming) that made the code compile. However, no upload. I have tried both boards available and both ports available *that are showing as options.
I get this verbose output:
processing.app.debug.RunnerException
    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:152)
    at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
    at processing.app.SketchController.upload(SketchController.java:732)
    at processing.app.SketchController.exportApplet(SketchController.java:703)
    at processing.app.Editor$UploadHandler.run(Editor.java:2061)
    at java.lang.Thread.run(Thread.java:748)
Caused by: processing.app.SerialException: Error touching serial port '/dev/cu.BLTH'.
    at processing.app.Serial.touchForCDCReset(Serial.java:107)
    at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:136)
    ... 5 more
Caused by: jssc.SerialPortException: Port name - /dev/cu.BLTH; Method name - openPort(); Exception type - Port busy.
    at jssc.SerialPort.openPort(SerialPort.java:164)
    at processing.app.Serial.touchForCDCReset(Serial.java:101)
    ... 6 more

Thank you in advance for any help.

try compiling and uploading an empty sketch ... one that has only void setup() {} and void loop() {} ... the github library is probably irrelevant to your question

This seems to be a problem with the Arduino IDE, not with your sketch. What OS are you using and what version of the Arduino IDE? How did you install it?

/dev/cu.BLTH This thing is (or was) supposedly an Arduino Leonardo so far the IDE is concerned and would that not present itself as cu.BLTH. If there's more to this than just choosing the wrong port, maybe make that clear.

@jsotola and others, thank you, I have just tried uploading an empty sketch over both available ports and I get the same results except that with the second port I also get the> avrdude: butterfly_recv(): programmer is not responding
// Arduino works fine with arduino uno.

@chrisl I am on Mac OS Monterey 12.4 and Arduino IDE 1.8.19

Verify that something relevant shows up in System Information if and only if the board is attached. If not, make sure your micro-usb cable is not the charging-only variety.


text:
RGB led strip is too dim
I'm following this tutorial to build an Arduino powered RGB led strip controller but I'm facing two problems:

When I use digitalOutput the lights are too dim.
When I use PWM the leds change so slightly that I can barely detect a change.

These are the parts I'm using:

Wemos D1 mini
a USB cable to power the Wemos
1k ohm resistors
TIP31c transistors
A power outlet 12V 1A to power the strip (which works fine with the original controller unit)

The circuit connected as presented in the tutorial (like the circuit below) doesn't work, the board does not start.
If I disconnect the board GND from the outlet GND then the board starts but the leds are too dim to be visible
What am I doing wrong?

simulate this circuit – Schematic created using CircuitLab

Is your strip also 1m as described in the article?

@chrisl no, its 5m long

why are you applying -12V to a +12V pin?

@jsotola I'm not, I forgot to rotate the outlet

as you've tagged this question with esp8266 - it may be worth noting, that the PWM range for esp8266 is 0...1023, whereas I believe arduino has a range of 0...255 - so, if your code only uses a range up to 255, you're only using 1/4 of maximum, hence ... DIM :p

The Wemos D1 Mini is a 3.3V device. With a 1k base resistor, the most base current you're going to get is (3.3V / 1k ohm) = 3.3mA.
Looking at the datasheet, the current gain (h_FE) for the TIP31 transistor is no more than 50. So the maximum current you will pass from collector to emitter is 50*3.3mA = 165mA.
Your base resistor is too large and is limiting the current to your LED strip to no more than 165mA per channel. Try reducing the base resistor to 150 ohm. The TIP31 can handle continuous collector current of 3A, so you ought to be safe with a 1A power supply, and 150 ohm resistor.
UPDATE:
Per @Gerben's comment, the ESP8266 can source a maximum of 12mA from a GPIO pin, so you should not use lower than a 225 ohm base resistor on the initial TIP31. A Darlington pair would look something like:

simulate this circuit – Schematic created using CircuitLab

So wich transistor can I use? The fact that my strip is 5m long changes anything?

What is the total current drawn on each channel of the strip? The TIP31 is not what is making your LEDs dim, it's the resistor value on the base of the transistor which is limiting the current that the transistor will allow. If you use a 150ohm resistor, you will max out your power supply before you max out the transistor.

Sorry, misread your answer. The lowest resistor I have right now is 220ohms, meaning the maximum current I can get will be 750mA, is my math correct? Also, how do I calculate the maximum amperage? If I cut the led strip I will need less amps, right?

Put two 220ohm resistors in parallel to make a 110ohm equivalent.

The maximum drive current for a GPIO on the ESP8266 is only 12mA. So the lowest value you could use is 225 Ohms. Either get a different transistor, or wire two of them in a darlington-pair.

I'm a little confused. The resistor TIP31 will always multiply the inputted amps? What will happen if I use a 220ohm resistor? Could it damage the board? On the given circuit, will the output be ((3,3/225) * 50 * 50) 36A? How can I calculate the output amps?

Schematic in the update is kinda weird. It can't be working for 12V led strip with common anode

@NicosKaralis It's not that easy. The transistor has something called "datasheet" and it says exactly what the maximum C-E current is. Also you have to count with heat dissipation (= current * voltage drop)

@KIIV I’m more lost than when I’ve started. Can I use a 480ohm with a single TIP31C? How can I calculate the maximum current allowed and the optimal current? (Based on amount of leds)

@NicosKaralis Maximum current is fixed (in TIP31 datasheet). The collector-emitter current is roughly Current gain times current between base and emitter. Led strip current is known, it's about 20mA per three LEDs for each color (again you need its datasheet or you can measure it).

@KIIV ok, Maximum Collector Current 3A, I have 300 LEDs (5m strip with 60leds/m) meaning the optimal current is 2A. How do I calculate current gain and the current between base and emitter?

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Empty output with GPS module GTPA010
I've synced my Uno with the Arduino IDE and I'm using the following code to get the GPS coordinates:
#include <TinyGPS.h>
#include <SoftwareSerial.h>

unsigned long fix_age;
SoftwareSerial GPS(4,3);
TinyGPS gps;
void gpsdump(TinyGPS &gps);
bool feedgps();
void getGPS();
long lat, lon;
float LAT, LON;

void setup(){
  GPS.begin(9600);
  Serial.begin(9600);
}

void loop(){
  long lat, lon;
  unsigned long fix_age, time, date, speed, course;
  unsigned long chars;
  unsigned short sentences, failed_checksum;
  // retrieves +/- lat/long in 100000ths of a degree
  gps.get_position(&lat, &lon, &fix_age);
  // time in hh:mm:ss, date in dd/mm/yy

  getGPS();
  Serial.print("Latitude : ");
  Serial.print(lat/100000,7); //#UPDATED
  Serial.print(" :: Longitude : ");
  Serial.println(lon/100000,7); //#UPDATED
}

void getGPS(){
  bool newdata = false;
  unsigned long start = millis();
  // Every 1 seconds we print an update
  while (millis() - start < 1000)
  {
    if (feedgps ()){
      newdata = true;
    }
  }
  if (newdata)
  {
    gpsdump(gps);
  }
}

bool feedgps(){
  while (GPS.available())
  {
    if (gps.encode(GPS.read()))
      return true;
  }
  return 0;
}

void gpsdump(TinyGPS &gps)
{
  //byte month, day, hour, minute, second, hundredths;
  gps.get_position(&lat, &lon);
  Serial.print("Hello World : "); //#UPDATED (Test)
  LAT = lat;
  LON = lon;
  {
    feedgps(); // If we don't feed the gps during this long
  }
}

When I compile, it uploads successfully and when I check the serial streams, it displays:
Latitude : 41103 :: Longitude : 41103
But my lat/lon (in the risk of disclosing location) is
(38.984898400, -76.957276900)
It doesn't seem to be the same.

is the GPS getting a good view of the sky?   Should add some prints to see if you are getting into gpsdump()   or just print your lat/lon rather then reassigning it to LAT/LON

@ChadG: I've kept it on a wide window sill with a view. So I guess that should work. Surprisingly, now it's even displaying garbage like
⸮7C⸮wyCCZVa⸮HR-⸮K=LR3⸮(⸮:⸮xk;GqB⸮9Jb⸮j
I added some prints inside the gpsdump(). Nothing happens, so I'm not even sure if it's getting into it.

Can you update the code and provide the output

@ChadG: I updated the code and results.

Actually update the code in the question, its to hard to go back and forth between your original code and the comment.   Did you ever try the GPS baud rate of 4800?

@ChadG: I did just now. No change in the lat/lon. Also if I change the baud rate from 9600 in the serial monitor, it again outputs garbage.

You have control of both sides of the serial monitor speed.   The drop down in the serial monitor needs to match the speed that is in the Serial.begin() function.   The GPS.begin() needs to match what the gps is outputting. (which is usually fixed and not changable)    I would print the data received from the gps directly to the console, no need to try and process it until you are sure your getting good data from the GPS. The strings coming out of the gps are human readable, so you will be able to see if your getting data this way, and then send it be processed after that is working

@ChadG: In that case, my other (possibly duplicated) post should output the raw data correctly?
https://arduino.stackexchange.com/questions/53963/garbage-output-with-gps-module-gtpa010?noredirect=1#comment112937_53963

Did changed the baud rate on the other code do any good?

@ChadG: Surprisingly, no. I'm really clueless now.

Did you ensure you have the RX/TX pins correct for the GPS? You can swap them in the code without harming anything.

@ChadG: After a discussion with my team, it seems the GPS module was faulty. I replaced it with a Adafruit Ultimate GPS and now it's working fine :) What a pain!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
NRF24L01+ - After stopListening, can't write data
Okay so this is the code for my receiver.
This is quite confusing so let's dub Receiver = DEVICE 1 and Transmitter = DEVICE 2
DEVICE 1: NRF24L01+, HC-05 (Bluetooth)
DEVICE 2: NRF24L01+
So DEVICE 1 will receive data from DEVICE 2. Also When it receives data from my phone that is connected to the HC-05 module, it will radio.StopListening and radio.write.
But for some reason, after i do radio.StopListening, radio.write doesnt work.
Currently, DEVICE 2 has a very simple code to receive data being sent from DEVICE 1. I've done this just to check if there's any data being sent when DEVICE 1's HC-05 module receives data.
Code:

#include "Arduino.h"
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio(9, 8);

byte addresses[][6] = {"1Node","2Node"};

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_2MBPS);
  radio.setChannel(124);

  // Open a writing and reading pipe on each radio, with opposite addresses
  radio.openWritingPipe(addresses[0]);
  radio.openReadingPipe(1, addresses[1]);
}

void loop() {
  unsigned char rf_data; //Make a variable to store the data
  unsigned char bt_data;
  unsigned char tosend;
  radio.startListening();

  if (radio.available()){
    while (radio.available()){
      radio.read(&rf_data, sizeof(rf_data));
      Serial.println(rf_data);
      }
    }

  if (Serial.available()>0){
    while (Serial.available()>0){
      bt_data = Serial.read();
      radio.stopListening();
      Serial.println(bt_data); //----------- I'M ABLE TO SERIAL PRINTLN ----
      radio.write(&bt_data, sizeof(bt_data)); //-------- BUT I'M UNABLE TO PERFORM THIS CODE HERE FOR SOME REASON
      }
    }

}

I've added comments to show which part works and which part doesn't
I hope this question isn't too hard to understand.

naming the Receiver  DEVICE 1 is less confusing?

@jsotola cant u be a bit more helpful

Are the example sketches working? Maybe you have an issue that is not related to your code.

There could be few reasons but, firstly I would like to ask you to check if your write command is working at all. Try to disable reading mode and leave just write mode:
#include "Arduino.h"
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>

RF24 radio(9, 8);

byte addresses[][6] = {"1Node","2Node"};

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_2MBPS);
  radio.setChannel(124);

  // Open a writing and reading pipe on each radio, with opposite addresses
  radio.openWritingPipe(addresses[0]);
  //radio.openReadingPipe(1, addresses[1]);
}

void loop() {
  unsigned char rf_data; //Make a variable to store the data
  unsigned char bt_data;
  unsigned char tosend;
  //radio.startListening();

 // if (radio.available()){
 //   while (radio.available()){
 //     radio.read(&rf_data, sizeof(rf_data));
 //     Serial.println(rf_data);
 //    }
 //   }

  if (Serial.available()>0){
    while (Serial.available()>0){
      bt_data = Serial.read();
      //radio.stopListening();
      Serial.println(bt_data); //----------- I'M ABLE TO SERIAL PRINTLN ----
      radio.write(&bt_data, sizeof(bt_data)); //-------- BUT I'M UNABLE TO PERFORM THIS CODE HERE FOR SOME REASON
      }
    }

}

Try above code and if it will not work change RF24_2MBPS to RF24_1MBPS and RF24_PA_MIN to RF24_PA_LOW on both modules (transmitter and receiver)


text:
Trying to get a ILI9341 TFT to work with UTFT library
I'm currently trying to fill out the constructor but I'm not sure what's what...
The constructor of the UTFT library goes as follows:
UTFT(Model, SDA, SCL, CS, RST[, RS]);

Where the last bit is optional.
SDA meaning Serial Data, SCL serial clock, CS chip select, RST reset and RS register select.

This is the screen I'm trying to connect. As far as I understand:
SDI (MOSI) goes to SDA
SCK goes to SCL
CS  goes to CS
RST goes to Reset?
RS goes to D/C?
But it doesn't work. What am I missing...
Here's my full code:
#include <UTFT.h>

//Digital Pins:
//53 = MOSI
//52 = SCK,
//10 = CS
//6 = RS
//7 = D/C
UTFT myGLCD(ILI9341_S5P,53,52,10,6,7);

void setup() {
    myGLCD.InitLCD(PORTRAIT);
    myGLCD.clrScr();

}

void loop() {
    myGLCD.fillScr(0,0,255);

}

I did get the screen to work with the Adafruit_GFX library. I used 1k resistors between all of the data lines, including reset. When using the screen with the GFX library I connected reset to 3,3v.

SDA/SCL is I2C (Wire). MISO/MOSI/CLK/CS is SPI

from where do you have the UTFT library? I don't see one in Library Manager

@Juraj found it on rinky-dink electronics: http://www.rinkydinkelectronics.com/library.php?id=51

the library is not for SPI connected display

it doesn't work does not describe the observed results.

@Juraj , thank you for clearing that up. I will look out for a different library then. Can you tell me how you found out that it's not for SPI displays, apart from looking at SDA/SCL being for I2C? I'm still new to arduino.

the library you linked has documentation in the downloaded zip. and of course there is the source code not using SPI

and reset of a device should be connected to a gpio pin, to be able to reset the device from sketch

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Using TFT touchscreen with Arduino Uno R3 via I2C
I've recently gotten into Arduino, due to a friend asking to be part of a project. The project requires a few 24V LED strips to be controllable via PWM, probably over MOSFETs (we have someone else in the team that will look after the electronics, I will be mostly responsible for the code) and also various sensors to measure the environment. However, the project should also include a touchscreen that will be used for programming these LEDs based on time and date, and displaying the data from these sensors, or program further events based on their input.
As far as I understand it should be possible to drive a TFT touchscreen via I2C? I've done some googling over the past two hours or so and could barely find any information about what screens to use for such projects, no tutorials, nor if there are any libraries available.
Is it doable to do a project of this magnitude with a Uno R3, or should I consider a Due or Mega?
I have a touchscreen shield right here, but it leaves me with only one PWM and one analogue pin if I don't plan on using the SD card that is on its back.
Maybe I'll find the answer myself, but I have literally only joined the Arduino/microcontroller fun a few days ago and am reading up on the whole topic in a 'for dummies' book which is very interesting, but it only touches on I2C at the very end and I don't want to confuse myself too much by jumping ahead and reading about stuff that doesn't directly answer my questions. So I turn to you guys for at least pointing me in the right direction on what I should read up on or linking me to tutorials.
Also, if you guys have any books to recommend on the topic I'll be glad to take recommendations.
Thanks in advance

A TFT touchscreen actually normally consists of two completely separate items:

TFT Display
Touchscreen and optional interface chip

While you can get both of those together on a board with both using I2C it is quite rare. It is far more common to find boards with either SPI or 8- (or 16-) bit parallel interfaces for the TFT screen, and SPI (or sometimes 4 channel analog - a direct connection to the touch screen itself) for the touch screen.
I2C is really only used for very small screens. The slow speed of the I2C protocol means that updating the display is very slow, which results in very poor performance for anything bigger than, say 128x128 pixels. It's usually used for things like small OLED displays rather than larger TFT displays.
Touchscreens with I2C are normally capacitative rather than the cheap resistive, so tend to be a little more expensive and harder to work with. The most common touch screen chip, the XPT2046, is SPI.
Fitting everything you want to do into an Uno is going to be tight, and not just because of the number of IO pins a display usually demands. Working with displays usually means lots of graphics (icons, symbols, fonts, etc), and that means a lot of flash memory. A Mega2560 would be a better choice for that if you want to remain with 8-bit.
However better graphical results would be obtained using a more powerful board. The Arduino Due, with its 32-bit ARM chip, would allow you to do much more graphical manipulation, such as drawing nice graphs etc.
My personal preference, though, is to use a PIC32 based board and the chipKIT core, coupled with my own powerful DisplayCore library. But then I'm biased.

I see, thanks a lot for your comment. I've also found out that SPI is more suited for our targeted screensize.

I think for now I'm going to stay with Arduino since I'm still new to all of this, and having so many tutorials and books at my disposal is great until I understand better how all of it works.
I've already ordered a Mega since I already understood that it's going to be tight with I/O anyway if we want to control x amount of LED strips, tho I do also know about shiftregisters capable of PWM such as the TLC5490, which is also underway. Mega will be nice for prototyping anyway.

Absolutely, though I have to plug my stuff when I can ;) The TLC5490 is nasty to work with. The TLC59116 is far far better.

In what way is it nasty to work with? I'll look into the TLC59116 too.

From what I remember the protocol is custom and very awkward to use. The TLC59116 is just plain I2C.

Actually I may be confusing it with some early addressable LEDs that used a protocol that needed constantly refreshing. The TLC5940 is just like a shift register, with all the down sides that come with that (having to refresh the entire chain to just change one LED). It's not as bad as I was remembering, but the TLC59116 is still better being I2C that lets you address each output individually.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Can now() roll over just like millis()?
I'm using now() and millis() to trigger events after a certain time has passed.
I am aware, and it's also easily found on the web, that millis() rolls over after a certain time has passed and for code that has to run indefinitely you have to handle this.
However I am not aware of if now() can do the same at some point. I mean it does count the seconds from the 1.1.1970 so just regarding this fact, it should not roll over. However, just like millis() this has to be counted somewhere no? How does it work?

What now() are you talking about? Could you give a reference?

@EdgarBonet probably https://www.arduino.cc/en/Reference/CurieTimeNow

he asks about Epoch seconds in Arduino, as used by the TimeLib

It may be worth noting that you don't necessarily have to "handle" millis() rollover; you just have to prepare your comparison correctly, and there is no rollover problem, as long as you are trying to compare durations smaller than the maximum millis() value.

If now() is from the TimeLib.h library, then this definition:
typedef unsigned long time_t;

indicates time_t is 32-bit unsigned value. Since it represents seconds since 1970-Jan-01 00:00:00, it will experience a rollover when representing dates past approximately 2106 (1970-Jan-01 + 2^32 seconds). Being unsigned, it also cannot represent dates earlier than 1970-Jan-01.
This is slightly different than the 2038 Rollover Problem, which occurs when a system defines a time_t as a signed 32-bit integer, and thus experiences this rollover earlier, in year 2038.
All of this depends on how/where the type time_t is defined for your CPU architecture, and this answer assumes an 8-bit AVR like Arduino Uno. If you use a different architecture, for which TimeLib.h has a different type definition, read the source code to find out exactly what you're dealing with.

sorry, long is 32 bits on 32 bits system too

arm gcc and xtensa compiler have time_t as signed long

Yes, it's highly architecture dependent.

Thank you, this is the answer I was looking for.

now() is a function that is specific to Intel Curie based boards.
It returns an unsigned long (which on a 32-bit system is the same as an unsigned int) and so can provide the number of seconds since 1/1/1970 up until the year 2106, at which point it will roll over.
If you plan on having your system run continuously for more than the next 88 years you will have to deal with that rollover correctly, including:

Using subtraction to "wrap around" your calculations
Not trying to calculate any periods longer than 136 years

Time represented in seconds from 1970-01-01 is called Epoch or Unix time. Function now() and similar functions in Arduino libraries returning 'epoch' use 32-bit representation. Some use the time_t type defined in basic includes distributed with the compiler (types.h). On some compilers or in many time and RTC libraries the 32-bit type is signed allowing to represent time before 1970, on some system the type is unsigned.
The signed 32 bit type for epoch time overflows in 2038 (Year 2038 problem). The unsigned 32-bit overflows in 2106.
I use the TimeLib library and it uses the time_t type defined on SAMD and ESP in type.h distributed with the compiler. ARM GCC has time_t as long, which is signed 32 bit type. The same for ESP boards with xtensa compiler. time_t for AVR is defined in the TimeLib library as unsigned 32bit type and overflows in 2016.


text:
ArduinoJson buffer gets overwritten
I have not that much experience with native languages like c/c++ and I'm facing a strange issue, which drives me crazy. So I'm using an Wemos D1 mini (ESP8266) which uses a class calles ConfigManager to read a configuration file from eeprom. The config file is formatted as json, so I'm using ArduinoJson to parse the content. I have declared a StaticJsonBuffer and pointer to a JsonObject in the header, like you can see in the code example:
//FILE: ConfigManager.h
#ifndef ConfigManager_H
#define ConfigManager_H

#include <Arduino.h>
#include <ArduinoJson.h>
#include <FS.h>
#include "Logger.h"

class ConfigManager {
public:

    Settings *settings;

    ConfigManager();

    void read_from_eeprom();

private:

    File configFile;
    JsonObject *json;
    StaticJsonBuffer<200> jsonBuffer;

    void open_file(const char *permission);

    void read_json();

    void recreate_file();

    void create_json();

    void check_success();

    void populate_settings();

    void clean_up();
};

#endif

When the function read_from_eeprom is invoked, it opens the file and invokes the functionread_json:
void ConfigManager::read_json() {
    size_t size = configFile.size();
    Log.verbose("[ConfigManager] Config file size: %d", size);

    std::unique_ptr<char[]> buf(new char[size]);
    configFile.readBytes(buf.get(), size);
    Log.verbose("[ConfigManager] File content: %s", buf.get());

    Log.verbose("[ConfigManager] Parsing json");
    json = &jsonBuffer.parseObject(buf.get());

    Log.notice("[ConfigManager] Json is:");
    json->printTo(Serial);
    Serial.println();
}

Which is followed by a call to check_success()
void ConfigManager::check_success() {
    Log.notice("[ConfigManager] Json is:");
    json->printTo(Serial);
    Serial.println();

    bool should_recreate = true;
    if (json->success()) {
        Log.notice("[ConfigManager] Parsed json successfully");

        auto version = json->get<const char*>("version");
        if (version) {
            if (strcmp(version, Settings::current_version) == 0) {
                Log.notice("[ConfigManager] Config version is up2date");
                should_recreate = false;
            } else {
                Log.warning("[ConfigManager] Config version outdated");
            }
        } else {
            Log.warning("[ConfigManager] Invalid config file");
        }
    } else {
        Log.warning("[ConfigManager] Config file is not valid json");
    }

    if (should_recreate) {
        Log.notice("[ConfigManager] Recreating config file");
        recreate_file();
        create_json();
    }

    Log.notice("JSON IS: ");
    json->prettyPrintTo(Serial);

    Log.notice("[ConfigManager] Sucessfully read json");
}

So what I noticed is that the file content is fine. E.g. {"version":"0.2","led_count":"64"}.
Then the json is parsed, which succeeds and logs the json object, which is again {"version":"0.2","led_count":"64"}.
Afterwards the function returns, and calls check_success, which again prints the content of the json object to the log, but this time it seems that something has overwritten the JsonBuffer, which causes the json object to be corrupted. This time the logged content is {"v␂":"0.2","led_count":"64"} (with some strange unicorn characters that change as the source code changes). I'm trying to figure out whats going on for many hours now, but I'm stuck. Can someone please point me in the right direction to solve this problem? Thank you!

the ArduinoJson library doesn't copy the strings, it only stores pointers and writes terminating zeros into input buffer. And your buffer buf is disposed by std::unique_ptr at the end of read_json() function

That's exactly what I needed. I'm now creating the unique_ptr dynamically and dispose it at the end. It now works flawless. Thank you so much!

@Simon Could you show an example of how you did that ?

@AnumSheraz The 3rd line in the read_json function (where I create the unique_ptr) was the issue. A quick fix would be to move the variable to class level rather than defining it in the function itself. This will keep the buffer available until the class instance is disposed.


text:
Can we control an Arduino with voice commands?
I'm looking for some method to control an Arduino with voice commands.
Could this work on this platform?

"Google Now" is a proprietary process that requires the Android operating system. You can't run Android on an Arduino, at least not if you're having to ask. However, controlling an Arduino by your voice IS possible, maybe.


text:
TFT touch, 4bit data transfer
I followed instructions to get my TFT to work.

I want to use other pins on the Arduino Uno for other I/O, so how can I use 4-bit data transfer for the TFT touchscreen?

Hi Veno, welcome to StackExchange. Unfortunately, it is not clear what you are asking. Are you asking how to get the touch screen to work? Try TFTLCD-Library. You say that you followed instructions... Which instructions did you follow to get our TFT to work? Can you edit your post and provide a link? Also, if you have another question relating to building an "antenna analyzer", then please ask a separate question.

You read the datasheet for the chip that is on your TFT display (whatever that is) and find if it even supports a 4-bit mode.  It probably doesn't. I have a large number of TFT screens here and I don't recall any of them using parallel 4-bit.  It sounds like you actually want a TFT screen that works of SPI rather than a parallel interface.  Those are available, but by using SPI the screen updates are considerably slower.

Yes,it will be slower with ISP, I want to test 4bit code on my TFT, can u help me

@VenuGopalRaoAggress No, I can't. Not unless you tell us what your TFT is. That means the exact model number of the chip that is on the TFT screen itself (ILIxxxx, SSDxxxx, SDxxxx, XPxxxx, etc) and how the TFT screen is wired up to the Arduino (schematic of the TFT screen's carrier shield).

Chip is 7783, Tannq

Not familiar with the ST7783 ( I assume it's Sitronix). I know the ST7781 and ST7785 and as I suspected, neither support a 4 bit interface. They do have an SPI mode, but the carrier shield has to be wired right for it.  I would suggest shopping around for an SPI TFT screen.  You won't find one with a 4-bit parallel interface - they simply don't exist.  8 bit, 16 bit or 18 bit. Never 4 bit.


text:
Arduino EEPROMex library problem
I am trying to write a float value to the EEPROM on an Arduino MEGA2560. According to some research I should use Arduino EEPROMex library. I added the library to Arduino, but I get the message "EEPROM was not declared in this scope". How can I solve this problem or have you got any suggestions to do this?

Show us code...

It sounds like you've used the word EEPROM somewhere in your code without a function after it. As the first comment asks: CODE PLZ.


text:
I have an 'error' with my code
The following code gives me an error:
// RFIDunio.h is from http://learn.robotgeek.com/getting-started-guides/39-robot-kits/151-rfiduino.html
#include <RFIDuino.h>

byte    keyTag[5] = {0,0,0,0,0};
boolean noise = false;
byte    masterTag[5] = {37,0,0,127,24};
byte    tagData[5];
byte    tagDatas[5];
boolean verifyKey = false;
boolean mastaKey = false;

void setup()
{
  Serial.begin(9600);
  Serial.println("Welcome to my system!");
}

RFIDuino myRFIDuino(1.2);

void loop()
{
  if(myRFIDunio.scanForTag(tagData == true)
  {
    verifyKey = myRFIDunio.compareTagData(tagData, keyTag);
    mastaKey = myRFIDunio.compareTagData(tagData, masterTag);
    if(verifyKey == true)
    {
      digitalWrite(myRFIDunio.led2,HIGH);
      if(noise == true)
      {
        myRFIDunio.successSound();
      }
      Serial.println("Correct Key!" + " UID = " + tagData[5]);
      delay(250);
      digitalWrite(myRFIDunio.led2,LOW);
    }
    else if(mastaKey == true)
    {
      Serial.println("Programming mode activated!");
      delay(500);
      Serial.println("Please scan a card.");
      myRFIDunio.scanForTag(tagDatas == true)
      delay(1000);
      tagDatas[5] = tagData[5];
      Serial.println("Card has been programmed!");
    }
    else
    {
      digitalWrite(myRFIDuno.led1,HIGH);
      if(noise == true)
         {
            myRFIDuino.errorSound();
         }
      Serial.println("Wrong! " + "UID = " + tagData[5]);
      delay(250);
      digitalWrite(myRFIDunio.led1,LOW);
    }
  }

The error is:
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\variants\standard -IC:\Users\*****\Documents\Arduino\libraries\RFIDuino C:\Users\*****\AppData\Local\Temp\build6101268048586666869.tmp\sketch_jul24a.cpp -o C:\Users\*****\AppData\Local\Temp\build6101268048586666869.tmp\sketch_jul24a.cpp.o
sketch_jul24a.ino: In function 'void loop()':
sketch_jul24a:20: error: 'myRFIDunio' was not declared in this scope
sketch_jul24a:20: error: ISO C++ forbids comparison between pointer and integer
sketch_jul24a:21: error: expected `)' before '{' token
sketch_jul24a:55: error: expected statement at end of input
sketch_jul24a:55: error: expected `}' at end of input

Did you even read the errors?! It tells you precisely what's wrong. error: 'myRFIDunio' was not declared - because you've spelt it incorrectly. In fact, you've managed to spell it three different ways throughout your code: myRFIDuino; myRFIDunio; myRFIDuno. Read, read, and read again.

if(myRFIDunio.scanForTag(tagData == true)

I think you have a bracket missing there.
if(myRFIDunio.scanForTag(tagData) == true)

Also I think you have spelled myRFIDuino wrong.  ni <-> in
if(myRFIDuino.scanForTag(tagData) == true)

And you need a } at the end of your program.
As well, you can't add strings together like you are doing in your Serial prints.  Break them up into multiple prints:
Serial.print("Correct Key!  UID = ");
Serial.println(tagData[5]);

You also have other bits that make no sense at all, such as:
myRFIDuino.scanForTag(tagDatas == true)

One further thing - that library will never work on Linux, or on MAC OS/X where case sensitivity is enabled on the filesystem.  The .cpp file is including a badly named .h file.

myRFIDunio.scanForTag(tagDatas == true)    is for getting the card information so you can program it, I am on windows. I will change the serial prints.                                                                                http://pastebin.com/RMrE8aD0

That line is gibberish, unless you are wanting to pass a boolean value to the scanForTag function which states whether or not tagDatas is true, which it can't be since it's an array.  Why is the == true even there?!

I am just trying to figure this out. Is there any way to get the tag data then.  and put it into a byte.

I have no idea. I don't know what "the tag data is", only that your program has syntax errors that I have identified.  I do not know what the program is supposed to do - nor even what a "RFIDuino" is or what it does.

Tag data is what rfid tags hold, they all have indiffrent unique ids. This reads them. I can show you the library if you want.

I have seen the library.  I have even submitted a pull request to it to correct their capitalization error.  I have never seen an RFID tag that just has a single byte for it's ID though.  If you want help with working out how to use the library then look at the examples.  First correct the syntax errors like I have told you.

@IanOxyMoron: If you have further questions then you would be best served by opening further questions.

C++ is spelling-sensitive; identifiers need to be spelled the same way each time they are used.


text:
How I can print several numbers via Serial with very few lines of code?
Could someone help me how to output the numbers from 1 to 10 via Serial, without having to write out each command by hand?
Below is my sketch - I need it concise instead of a long sketch:
#include <Streaming.h
//setup
void setup() {
 Serial. begin(9600);//The faster the better
}//Close the sertup

//main loop
void loop() {

  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(1) << endl;
  delay(1000);
  Serial<< _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(20) << endl;
   delay(1000);
  while(1){}//freeze the main loop

}

Where is the photo?

It is better to post the code, not photograph a screen with it on. Just copy the code from your sketch, edit your post, and post it into it. Select the code and hit Ctrl+K to indent it, and make it look nice.

The faster the better - how about 115200 baud then?

Can you tell me how to add my code here?

Edit your question (Click "edit"). Copy the code from your sketch and paste it into the question. Then select the code and hit Ctrl+K to indent it and make it look like code.

I have just did it, can you check it please

Sorry Nick my English not very well and I don't have experience in this website

I have tried many time to use your code but it doesn't work I don't know why, anyway this is my code and I hope you write it shorter then mine.

[This replaces my earlier answer, and addresses information added to the question.]
You apparently want a sketch that outputs 1, 2, 3 ... 100 to serial output, where each number string is embedded within a control sequence.
Here are two ways.  The first program outputs the sequence once, using ordinary Arduino Serial.write(), Serial.print() and Serial.println() statements:
Program 1.  Output 1, 2, 3 ... 100 once
void setup() {
  Serial.begin(9600);
  for (int j=1; j<=100; ++j) {
    Serial.write(27); // Send escape character
    Serial.print("[2J"); // Send erase-screen command
    Serial.print("\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t");
    Serial.println(j); // Send j in decimal format
    delay(1000);
  }
}
void loop() {}

The other program will output the sequence repeatedly.  It uses the Streaming.h library, but in a  rational manner; for example, instead of quoting every character separately like the program in the photo, it quotes character sequences in strings.  Note, Esc [2J is an ANSI escape code sequence that erases the screen it is directed to, if the screen device is ANSI compliant.
Program 2.  Output 1, 2, 3 ... 100 repeatedly
#include <Streaming.h> // or "Streaming.h" if appropriate
byte j=0;
void setup() {
  Serial.begin(9600);
}
void loop() {
  ++j;
  // Send Esc [2J which will erase screen
  Serial << _BYTE(27) << "[2J";
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << j;
  if (j >= 100) j=0;
  delay(1000);
}

Yasir, I added a } that was missing, and also added delay(1000);.  When you say  “I have tried many time to use your code but it doesn't work” are you referring to Nick's code, or to one of my programs above?  What happens when you compile and upload the code?

Thank you so so much I really appreciate your help, I have just copy your code and it works very well.;-)

Ah, a challenge!

I have to write from 1 to 100, and I don't want to repeat it all 100 times

Your question did not make that clear. Anyway:
int main () {
  Serial.begin (9600);
  for (int i = 1; i <= 100; i++)
    Serial.println (i);
  while (true);
  }

You can probably make it shorter at the expense of readability.
int main(){Serial.begin(9600);for(int i=1;i<=100;i++)Serial.println(i);while(1);}

Ah, a challenge!
I have to write from 1 to 100, and I don't want to repeat it all 100 times
Your question did not make that clear. Anyway:
int main () {
Serial.begin (9600);
for (int i = 1; i <= 100; i++)
Serial.println (i);
while (true);
}
You can probably make it shorter at the expense of readability.
int main(){Serial.begin(9600);for(int i=1;i<=100;i++)Serial.println(i);while(1);}. If I use this way, the number will count automatically from 1 to 10 ?

You don't need to copy and paste my entire answer into your comment. That is just very confusing. If I use this way, the number will count automatically from 1 to 10 - well you said 100 in your comment ("I have to write from 1 to 100"). Try to pay attention when you are typing. Asking for 10/100/10 is really confusing. Yes, that is what a for loop does. You may want to read a tutorial on C programming. Copying and pasting 100 times is not what your teacher had in mind, I bet.

Nick,  where you say int main (), was that intentional, or did you mean to have void setup()  ?

It was intentional in the spirit of keeping it "short". Doing a main means you don't need both setup and loop, and is more in-line with standard C programming. You do, of course, need to also call init() if you expect to use timers, delay() and so on.

Hi guys. I have tried many time to use your code but it doesn't work I don't know why, anyway this is my code and I hope you write it shorter then mine.

It worked when I tested it. In what way does it not work for you? Compiler error? Wrong numbers shown? No numbers? Please be specific.

Fixing the typos in your original code, so that it should probably read:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(1) << endl;
  delay(1000);
  Serial<< _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27)<< _BYTE(91)<< _BYTE(50)<< _BYTE(74);//CLR
  Serial<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<<"\n"<< endl;
  Serial<<"\t"<<"\t"<<"\t"<<"\t"<<"\t"<< _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then condensing the cursor positioning lines, gives:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(1) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n" << endl;
  Serial << "\t\t\t\t\t" << _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then joining the two cursor positioning lines, gives:
#include <Streaming.h>

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(1) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(2) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(3) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(4) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(5) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(6) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(7) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(8) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(9) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(10) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(11) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(12) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(13) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(14) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(15) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(16) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(17) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(18) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(19) << endl;
  delay(1000);
  Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
  Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(20) << endl;
  delay(1000);
  while(1){} //freeze the main loop
}

Then putting each repeated line in a for loop, and adding a Maximum Count const variable, gives:
#include <Streaming.h>

const int MaxCount = 20;

//setup
void setup() {
 Serial.begin(9600);  //The faster the better
}   //Close the setup

//main loop
void loop() {
  for (int n = 1; n < 20; n++) {
    Serial << _BYTE(27) << _BYTE(91) << _BYTE(50) << _BYTE(74); //CLR
    Serial << "\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t" << _DEC(n) << endl;
    delay(1000);
  }

  while(1){} //freeze the main loop
}

However, jwpat7's answer is much better, and Nick's answer is the shortest.

authors: Александр Балан


text:
PlatformIO :collect2.exe: error: ld returned 1 exit status
I am trying some library files for esp8266. I created hpp and .cpp files. But i try to compile program i got this error on VSCode.
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\huzzah\firmware.elf] Error 1
I put files in src folder but still got this. What are points that i missed?
Building in release mode
Linking .pio\build\huzzah\firmware.elf
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::Neotimer()':
main.cpp:(.text._ZN8NeotimerC2Ev+0x0): multiple definition of `Neotimer::Neotimer()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerC2Ev+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::Neotimer()':
main.cpp:(.text._ZN8NeotimerC2Ev+0x0): multiple definition of `Neotimer::Neotimer()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerC2Ev+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::Neotimer(unsigned long)':
main.cpp:(.text._ZN8NeotimerC2Em+0x0): multiple definition of `Neotimer::Neotimer(unsigned long)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerC2Em+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::Neotimer(unsigned long)':
main.cpp:(.text._ZN8NeotimerC2Em+0x0): multiple definition of `Neotimer::Neotimer(unsigned long)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerC2Em+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::~Neotimer()':
main.cpp:(.text._ZN8NeotimerD2Ev+0x0): multiple definition of `Neotimer::~Neotimer()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerD2Ev+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::~Neotimer()':
main.cpp:(.text._ZN8NeotimerD2Ev+0x0): multiple definition of `Neotimer::~Neotimer()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8NeotimerD2Ev+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::init()':
main.cpp:(.text._ZN8Neotimer4initEv+0x0): multiple definition of `Neotimer::init()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer4initEv+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::repeatReset()':
main.cpp:(.text._ZN8Neotimer11repeatResetEv+0x0): multiple definition of `Neotimer::repeatReset()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer11repeatResetEv+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::done()':
main.cpp:(.text._ZN8Neotimer4doneEv+0x4): multiple definition of `Neotimer::done()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer4doneEv+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::set(unsigned long)':
main.cpp:(.text._ZN8Neotimer3setEm+0x0): multiple definition of `Neotimer::set(unsigned long)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer3setEm+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::get()':
main.cpp:(.text._ZN8Neotimer3getEv+0x0): multiple definition of `Neotimer::get()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer3getEv+0x0): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::stop()':
main.cpp:(.text._ZN8Neotimer4stopEv+0x4): multiple definition of `Neotimer::stop()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer4stopEv+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::reset()':
main.cpp:(.text._ZN8Neotimer5resetEv+0x8): multiple definition of `Neotimer::reset()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer5resetEv+0x8): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::repeat()':
main.cpp:(.text._ZN8Neotimer6repeatEv+0xc): multiple definition of `Neotimer::repeat()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer6repeatEv+0xc): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::repeat(int)':
main.cpp:(.text._ZN8Neotimer6repeatEi+0x8): multiple definition of `Neotimer::repeat(int)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer6repeatEi+0x8): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::repeat(int, unsigned long)':
main.cpp:(.text._ZN8Neotimer6repeatEim+0x4): multiple definition of `Neotimer::repeat(int, unsigned long)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer6repeatEim+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::start()':
main.cpp:(.text._ZN8Neotimer5startEv+0x4): multiple definition of `Neotimer::start()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer5startEv+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::debounce(bool)':
main.cpp:(.text._ZN8Neotimer8debounceEb+0x8): multiple definition of `Neotimer::debounce(bool)'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer8debounceEb+0x8): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::restart()':
main.cpp:(.text._ZN8Neotimer7restartEv+0x4): multiple definition of `Neotimer::restart()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer7restartEv+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::waiting()':
main.cpp:(.text._ZN8Neotimer7waitingEv+0x4): multiple definition of `Neotimer::waiting()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer7waitingEv+0x4): first defined here
c:/users/dogan/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\huzzah\src\main.cpp.o: in function `Neotimer::started()':
main.cpp:(.text._ZN8Neotimer7startedEv+0x0): multiple definition of `Neotimer::started()'; .pio\build\huzzah\src\communication.cpp.o:communication.cpp:(.text._ZN8Neotimer7startedEv+0x0): first defined here

Sorry, i am new on stackexchange community so i can do basic mistakes about usage.
Now, i am adding my main.cpp,communication.cpp and communication.h files. As i said before, i didnt included neotimer and deleted. I used to add this library to my project, PIO library interface. I am thinking this problem coming from this. Great thanks for your patient and advises.
communication.cpp:
#include "communication.h"
#include "database.h"
#include "management.h"
#include "wifi.h"

String GetCommand(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length() - 1;

  for (int i = 0; i <= maxIndex && found <= index; i++)
   {
    if (data.charAt(i) == separator || i == maxIndex)
    {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }
  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

void checkStream(WiFiServer tcpServer,WiFiClient tcpClient, Neotimer timer,boolean pulseCheck)
{

 // WiFiClient _tcpClient;
  tcpClient.setTimeout(200);
  tcpClient  = tcpServer.available();

  if(tcpClient && tcpClient.connected())
  {
    Serial.println("Timer Off");
    timer.stop();
    String requestStr = tcpClient.readStringUntil('\r');
      if(requestStr.length()>=8)
      {
        tcpClient.print(ParseStream(requestStr));
        pulseCheck = false;
        delay(3000);
         String requestSplitStr = GetCommand(requestStr, ' ', 0);
         if(requestSplitStr == "ayg_set_modem_info")
         {
          Serial.println("Device is going to sleep now!");
          Sleep();
         }
      }
  }
  else
  {
    return;
  }
}

String ParseStream(String content)
{
  String requestSplitStr = GetCommand(content, ' ', 0);
  if(requestSplitStr == "ayg_set_modem_info")
  {
    String ssid = GetCommand(content, ' ', 1);
    String pass = GetCommand(content, ' ', 2);
    Serial.println("SSID,PASS TAKING");
    delay(200);
    ClearEP();
    boolean resSsid = WriteEPSsid(ssid);
    boolean resPass = WriteEPPass(pass);
    Aprint("SSID: "+ReadEPSsid());
    Aprint("Pass: "+ReadEPPass());
    //_tcpClient.flush();
    if(resPass)
    {
      if(STATest())
      {
        return JsonResult("true");

      }
      else
      {
        return JsonResult("false");
      }

    }
    else
    {
      return JsonResult("false");
    }

  }

  else if(requestSplitStr == "ayg_get_vbatt")
  {
    return JsonResult(GetBattery());
   // _tcpClient.flush();
   // _tcpClient.stop();
  }

communication.h
#ifndef communication_h
#define communication_h
#if ARDUINO > 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <WiFiServer.h>
#include <WiFiClient.h>
#include <neotimer.h>
#include "ArduinoJson.h"

//VARIABLES

    String GetCommand(String data, char seperator, int index);
    String ParseStream(String content);
    void checkStream(WiFiServer tcpServer,WiFiClient tcpClient, Neotimer timer,boolean pulseCheck);
    String JsonResult(String result);

#endif

main.cpp:
#include <stdlib.h>
#include <HX711.h>
#include <Arduino.h>
#include <ESP8266WebServer.h>

#include <string.h>
#include "communication.h"
#include <management.h>
#include <wifi.h>
#include <database.h>

#define DOUT 13 // D7
#define SCK 15 // D8
#define led1 5 // D1- Color?
#define led2 4 // D2-Color?
#define led3 0 // D3-Color?
#define led4 2 // D4 Color?
#define led5 14 // D5 Color_?
#define button 12 //Button-D5
#define VERSION "1.0"
#define CALIBRATIONWEIGHT 5.0
#define LPG  12.2

struct rst_info *rtc_info = system_get_rst_info();
ADC_MODE(ADC_VCC);
WiFiServer _tcpServer(41400);
WiFiClient _tcpClient;
//HTTPClient http;
HX711 scale;

/*Scale Values*/
float tareValFromclient;
float calibration_factor = 26845.0;
float grossWeight;
char sGrossWeight[10];
int ledPercentage;
/*Sleep Values*/
bool sleepPulseCheck=false;

/*Timers and Intervals*/
/*const unsigned long sleepInterval = 200000; // Seconds to sleep
const unsigned long scaleInterval = 2000; // Interval for scaling tank
const unsigned long ledInterval = 200;
Neotimer sleepTimer(sleepInterval);
Neotimer scaleTimer(scaleInterval);
Neotimer ledTimer(ledInterval);*/

#pragma region PROTOYPES
/*PROTOTYPES*/
void Initialize();
String checkTankTare();
void powerUpScale();
void powerDownScale();
bool Tare();
void getGrossWeight(float *fGross, char*sGross);
String getDeviceTare();
float calculateFirstNetWeight();
float getNetWeight();
int calculatePercentage();
void ledDrivePercentage(int percentage);
String calibrateScale();
#pragma endregion

/*---------------------------------------*/

void setup() {
  ESP.eraseConfig();
  Initialize();
  Serial.println("started");
}

void loop() {
  //Serial.printf("connected:%d\n", WiFi.softAPgetStationNum()); // bağlı client sayısı
 calibrateScale();
// checkStream(_tcpServer,_tcpClient,/*sleepTimer*/sleepPulseCheck);
 ledDrivePercentage(calculatePercentage());
 WriteEPGross(sGrossWeight);

 if(sleepPulseCheck == false)
 {
   sleepPulseCheck = true;
  // sleepTimer.start();
   Serial.println("Sleep Fired");

 }
}

the neotimer library is wrong. it can't be included in more then one file

I deleted all includes and only included at communication.cpp but still getting this error

one half of your previous comment can't be true

I did it but still same

We cannot tell you more, because you didn't give us enough information. Juraj exactly wrote, what the compilation output, that you posted, tells us: The neotimer library was defined multiple times. You should show us your code and link to the used libraries. Then we can check in your code, where the problem is (curing the disease instead of trying to cure the symptom).

you include communication.cpp? usually you include a .h file not a .cpp file (though of course you can include anything you like the extension doesn't matter really) - try adding #pragma once to the top of the file you are including

I added my codes to first mention. Sorry i am new on this community and  can doing some basic mistakes. Thanks for advises.

The problem stems from the fact that the author of the Neotimer "library" defined the methods in the header file, see neotimer.h.
If you include this header in more than 1 source of your project, you will get these "multiple definition" errors.
To solve this issue you have (at least) these options:

Make Neotimer a correct library with separated header and source files. Compile the source into a library file. Since I'm not experienced with Arduino I don't know how other libraries do this.

Disadvantage: You're messing with 3rd-party code. Commonly this is discouraged. You'll have to maintain your copy of the library yourself, which renders some benefits of using libraries void.

Don't include neotimer.h in a header file of yours, include it only in one of your source files. If you need some declaration like the Neotimer type in other modules, add a forward declaration but don't include its header file.
Use another library that is better implemented.

You might say that you include neotimer.h in only one module. That's wrong. You included it in your own header file communication.h, which you include in both source files. This way it sneaks into both modules. You can't do anything about this with preprocessor "magic" because both modules are compiled independently from each other.

This is the class declaration of Neotimer as of 2020-01-12 18:40 UTC. Use as much as you need from it as forward declaration. You could even put this in decent header file.
class Neotimer{
    public:
    //Methods
    Neotimer();
    Neotimer(unsigned long _t);      //Constructor
    ~Neotimer();            //Destructor

    void init();            //Initializations
    boolean done();         //Indicates time has elapsed
    boolean repeat(int times);
    boolean repeat(int times, unsigned long _t);
    boolean repeat();
    void repeatReset();
    boolean waiting();          // Indicates timer is started but not finished
    boolean started();          // Indicates timer has started
    void start();           //Starts a timer
    unsigned long stop();           //Stops a timer and returns elapsed time
    void restart();
    void reset();           //Resets timer to zero
    void set(unsigned long t);
    unsigned long get();
    boolean debounce(boolean signal);
    int repetitions = NEOTIMER_UNLIMITED;

    private:

    struct myTimer{
        unsigned long time;
        unsigned long last;
        boolean done;
        boolean started;
    };

    struct myTimer _timer;
    boolean _waiting;
};

Can you explain forward declaration? How can i do that? I did search on internet and it is like a function prototyping.

Well, I'm tempted to send you back to your C++ book. ;-) But my edit might help you, though.

Thanks for the great help. I am new on C++ and embedded systems. I am try to deep dive and try write modular codes. But i got  your temp and will check c++  rules  :)


text:
Monitor serial0 while code is being uploaded
I'm trying to upload the sketch on a Mega 2560 via the serial port 0 using another microcontroller.
To better undestand the process, I decided to first observe what avrdude is doing while it is uploading a hex file. To do this, I'm using another arduino (ESP32) with the following sketch:
void setup()
{
    Serial.begin(115200);
    Serial2.begin(115200);
}

void loop()
{
    while (Serial2.available()) {
        Serial.print(Serial2.read(), HEX);
        Serial.print(":");
    }
}

ESP32's Serial(serial0) is connected to PC via USB, and Serial2 is connected to Mega's Serial(serial0), the one connected to PC via USB, used by avrdude.

According to this answer the first things avrdude is sending over the serial interface are:
STK_GET_SYNC / CRC_EOP  (0x30/0x20)

But this is not what I receive through ESP32:
1B:1:0:1:E:1:14:1B:2:0:C:E:10:C8:64:19:20:0:53:3:AC:53:0:0:31:1B:3:0:8:E:1D:4:4:0:30:0:0:0:33:1B:4:0:8:E:1D:4:4:0:30:0:1:0:35:1B:5:0:8:E:1D:4:4:0:30:0:2:0:37:1B:6:0:8:E:1D:4:4:0:50:0:0:0:56:1B:7:0:8:E:1D:4:4:0:50:0:0:0:57:1B:8:0:8:E:1D:4:4:0:50:0:0:0:58:1B:9:0:8:E:1D:4:4:0:58:8:0:0:59:1B:A:0:8:E:1D:4:4:0:58:8:0:0:5A:1B:B:0:8:E:1D:4:4:0:58:8:0:0:5B:1B:C:0:8:E:1D:4:4:0:50:8:0:0:54:1B:D:0:8:E:1D:4:4:0:50:8:0:0:55:1B:E:0:8:E:1D:4:4:0:50:8:0:0:56:1B:F:0:5:E:6:80:0:0:0:99:1B:10:1:A:E:13:1:0:C1:A:40:4C:20:0:0:71:C0:0:0:81:C0:0:0:7F:C0:0:0:7D:C0:0:0:7B:C0:0:0:79:C0:0:0:77:C0:0:0:75:C0:0:0:73:C0:0:0:71:C0:0:0:6F:C0:0:0:6D:C0:0:0:6B:C0:0:0:69:C0:0:0:67:C0:0:0:65:C0:0:0:63:C0:0:0:61:C0:0:0:5F:C0:0:0:5D:C0:0:0:5B:C0:0:0:59:C0:0:0:57:C0:0:0:56:C0:0:0:53:C0:0:0:51:C0:0:0:4F:C0:0:0:4D:C0:0:0:4B:C0:0:0:49:C0:0:0:47:C0:0:0:45:C0:0:0:43:C0:0:0:41:C0:0:0:3F:C0:0:0:3D:C0:0:0:3B:C0:0:0:39:C0:0:0:37:C0:0:0:35:C0:0:0:33:C0:0:0:31:C0:0:0:2F:C0:0:0:2D:C0:0:0:2B:C0:0:0:29:C0:0:0:27:C0:0:0:25:C0:0:0:23:C0:0:0:21:C0:0:0:1F:C0:0:0:1D:C0:0:0:1B:C0:0:0:19:C0:0:0:17:C0:0:0:15:C0:0:0:13:C0:0:0:11:24:1F:BE:CF:EF:D1:E2:DE:BF:CD:BF:0:E0:C:BF:22:E0:A0:E0:B2:E0:1:C0:1D:92:A9:30:19:1B:11:0:5:E:6:80:0:0:80:7:1B:12:1:A:E:13:1:0:C1:A:40:4C:20:0:0:B2:7:E1:F7:4C:D0:C2:C0:7B:CF:1F:92:F:92:F:B6:F:92:11:24:2F:93:3F:93:8F:93:9F:93:AF:93:BF:93:80:91:5:2:90:91:6:2:A0:91:7:2:B0:91:8:2:30:91:4:2:23:E0:23:F:2D:37:20:F4:1:96:A1:1D:B1:1D:5:C0:26:E8:23:F:2:96:A1:1D:B1:1D:20:93:4:2:80:93:5:2:90:93:6:2:A0:93:7:2:B0:93:8:2:80:91:0:2:90:91:1:2:A0:91:2:2:B0:91:3:2:1:96:A1:1D:B1:1D:80:93:0:2:90:93:1:2:A0:93:2:2:B0:93:3:2:BF:91:AF:91:9F:91:8F:91:3F:91:2F:91:F:90:F:BE:F:90:1F:90:18:95:78:94:84:B5:82:60:84:BD:84:B5:81:60:84:BD:85:B5:82:60:85:BD:85:B5:81:60:85:BD:80:91:6E:0:81:60:80:93:6E:0:10:92:81:0:80:91:81:0:82:60:80:93:81:0:80:91:81:0:81:60:80:93:81:0:80:91:80:0:81:60:80:93:80:0:80:91:B1:0:84:60:80:93:B1:0:80:91:B0:0:81:60:1B:13:0:5:E:6:80:0:1:0:84:1B:14:1:A:E:13:1:0:C1:A:40:4C:20:0:0:91:0:80:91:91:0:81:60:80:93:91:0:80:91:90:0:81:60:80:93:90:0:80:91:A1:0:82:60:80:93:A1:0:80:91:A1:0:81:60:80:93:A1:0:80:91:A0:0:81:60:80:93:A0:0:80:91:21:1:82:60:80:93:21:1:80:91:21:1:81:60:80:93:21:1:80:91:20:1:81:7A:0:80:91:7A:0:81:60:80:93:7A:0:80:91:7A:0:80:68:80:93:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:1B:15:0:8:E:1D:4:4:0:50:0:0:0:45:1B:16:0:8:E:1D:4:4:0:50:0:0:0:46:1B:17:0:8:E:1D:4:4:0:50:0:0:0:47:1B:18:0:8:E:1D:4:4:0:58:8:0:0:48:1B:19:0:8:E:1D:4:4:0:58:8:0:0:49:1B:1A:0:8:E:1D:4:4:0:58:8:0:0:4A:1B:1B:0:8:E:1D:4:4:0:50:8:0:0:43:1B:1C:0:8:E:1D:4:4:0:50:8:0:0:44:1B:1D:0:8:E:1D:4:4:0:50:8:0:0:45:1B:1E:0:3:E:11:1:1:19:

I can't find 30:20 anywhere. What am I missing?
The baud rate is 115200 everywhere which I believe is the right one. The link is good because if I send char 'A' from PC over the serial connected to Mega, I get 41: via ESP32 on the other side, which is correct.

Are both ESP32's serial ports implemented in hardware?  Do the research because if 1 is implemented in software the ESP32 may not be able to echo back everything it sees on the hardware serial port.

the bootloader responses on TX. and do you reset the board? the avrdude uses stk500 protocol, which is documented, no need to reverse engineer it

@st2000 According to online docs they are both hardware. It's also labeled on the board and when I send a random char from PC to Mega, I receive the correct value via ESP32, but when I look at what I receive during sketch upload, makes no sense. @Juraj I'm interested in what avrdude is sending first, which should be 0x30,0x20,  not 0x1B,0x01. I don't reset the board, the usb-to-serial chip already does it. The sketch upload from PC works. I just want to confirm the the first thing it sends is 0x30,0x20 to help me going.

Agreed, online it says the ESP32 has 3 hardware UARTs.  But when the Arduino development environment was ported to the ESP processor, did it actually use the hardware UARTs? And if it did, how well implemented is the firmware? For that matter, how well is the ESP's hardware implemented?  The type of problem I am concerned about occurs when many bytes are transferred rapidly. Of course the 1st byte, for such problems, should always make it through. Also, I agree with @Juraj. Use the existing documentation to develop you own programmer. Nothing says that what avrdude does is correct.

@Juraj In C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt I have mega.menu.cpu.atmega2560.upload.speed=115200. I have also tried 57600 and 9600. What baud rate you think is being used?

The answer you link to is about the Uno. The Mega uses a different bootloader and, IIRC, a different protocol.

@EdgarBonet Yeah, I just noticed that if select AVR ISP programmer and click Burn Bootloader I can see 30:20 multiple times on the other side at the ESP32. So the serial it's fine. But there are no replies from the bootloader. I'll have to find an alternative for Mega. Thanks!

and what is what you try to do? AVR ISP is a programmer (hardware) to flash without bootloader

@Juraj The same protocol that AVR ISP is using, Uno and many others that have optiboot, are using. Mega however is using wiring bootloader, that is why I see 1B:1:0:1:E:1:14 as the first message, which is wiring_open(). In the end I want to be able to program mega via WiFi through internet. I think I'll try adapt ESP8266AVRISP for ESP32.

you can use my ArduinoOTA library to remote upload to Mega, if the Mega can access the network with some Arduino library (WiFiNINA?) https://github.com/jandrassy/ArduinoOTA


text:
ESP32 WebSocketsServer - stream pots data to web browser
I would like to stream pots data to a web browser using websockets.  I'm using WebSocketsServer on a Huzzah but sendTXT isn't working, but does for Connected WStype.  Is there a way to do this?   Partial code:
  // New client has connected
case WStype_CONNECTED:
{
  IPAddress ip = webSocket.remoteIP(client_num);
  Serial.printf("[%u] Connection from client: ", client_num);
  Serial.println(ip.toString());
  webSocket.sendTXT(client_num, "Server says Client is connected \r\n");
}

void loop() {
int potValue =analogRead(A4);
//Serial.println(potValue);
webSocket.loop();
}

javascript:
/*----  WEBSOCKET SERVER CONNECTION    ------- --*/
connect();

function connect()
{

var socket = new WebSocket("ws://10.0.0.1:1337");

try
{
    message('
Socket Status: '+socket.readyState);

    socket.onopen = function()
    {
    message('
Socket open Status: '+socket.readyState+' (open)');
    }
    socket.onmessage = function(msg)
    {
     message('
Received: '+msg.data);
    }
    socket.onclose = function()
    {
    message('
Socket close Status: '+socket.readyState+' (Closed)');
    }
}
catch(exception)
{
    message('
Error'+exception);
}

/* ----SEND TO SERVER -----*/

$('.fan').click(function()
{
    var idClicked = $(this).attr('id');
    console.log(idClicked);

    sendTo(idClicked);

});

function sendTo(idClicked)
{
    socket.send(idClicked);
    message('
Sent: '+idClicked)
}

function message(msg)
{
    $('#pots').html(msg+'
');
}

please show the non-working code

how do you send the text?

do you have a java script web socket client in a page running in browser?


text:
Is there a way for keypad to stop the buzzer while it is running?
I am new to arduino, currently I am looking for a way to make the keypad able to stop the buzzer making a siren alarm when password are keyed in wrong and able to move into password screen by pressing any button on the keypad. From all the videos i have seen, only 1 fits the way i want it to work.
https://www.hackster.io/thehack904/motion-sensing-alarm-with-keypad-password-53f05c
Below is the code I have completed with but i want to try adding a siren alarm function that is able to stop using keypad. Can anyone please teach me how to use a keypad to stop the buzzer and move into master key screen.
//Libraries
#include <LiquidCrystal.h>
#include <Keypad.h>

/*-------------------------------KEYPAD---------------------------------------*/
const byte numRows = 4; //number of rows on the keypad
const byte numCols = 4; //number of columns on the keypad
char keypressed;
char keymap[numRows][numCols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
//Code that shows the the keypad connections to the arduino terminals
byte rowPins[numRows] = {2, 3, 4, 5};//Rows 0 to 3
byte colPins[numCols] = {6, 7, 8, 9};//Columns 0 to 3
//initializes an instance of the Keypad class
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

/*-------------------------------CONSTANTS------------------------------------*/
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5); //LCD
const int buzzer = 10;        //Buzzer/small speaker
int solenoidPin = 11;         //Solenoid

/*-------------------------------VARIABLES------------------------------------*/
String password = "0"; //Variable to store the current password
String master_key = "999"; //Variable to store the master key
String tempPassword = ""; //Variable to store the input password
int doublecheck;    //Check twice the new passoword
boolean armed = false;  //Variable for system state (armed:true / unarmed:false)
boolean input_pass;   //Variable for input password (correct:true / wrong:false)
boolean storedPassword = true;
boolean changedPassword = false;
boolean checkPassword = false;
int i = 1; //variable to index an array
unsigned char WrongAttempts = 0; //global variable to keep the number of wrong attempts done at the code.

/*----------------------------------------------------------------------------*/
void setup() {
  lcd.begin(16, 2); //Setup the LCD's number of columns and rows
  pinMode(solenoidPin, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
}

void loop() { //Main loop
  unlockTheDoor();
}
/********************************FUNCTIONS*************************************/
void unlockTheDoor() {
lockAgain: //goto label
  digitalWrite(solenoidPin, HIGH);       //Switch Solenoid OFF
  tempPassword = "";
  lcd.clear();
  i = 6;
  noTone(buzzer);
  while (!checkPassword) {
    lcd.setCursor(0, 0);
    lcd.print("Open the door:  ");
    lcd.setCursor(0, 1);
    lcd.print("PASS>");
    keypressed = myKeypad.getKey();   //Read pressed keys
    if (keypressed != NO_KEY) {   //Accept only numbers and * from keypad
      if (keypressed == '0' || keypressed == '1' || keypressed == '2' || keypressed == '3' ||
          keypressed == '4' || keypressed == '5' || keypressed == '6' || keypressed == '7' ||
          keypressed == '8' || keypressed == '9' ) {
        tempPassword += keypressed;
        lcd.setCursor(i, 1);
        lcd.print("*");       //Put * on lcd
        i++;
        tone(buzzer, 800, 200); //Button tone
      }
      else if (keypressed == 'A') {
        changePassword();
        goto lockAgain;
      }
      else if (keypressed == 'D') {
        break;
      }
      else if (keypressed == '*') { //Check for password
        if (password == tempPassword) { //If it's correct...
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Correct Password");
          lcd.setCursor(0, 1);
          lcd.print("Door is unlocked");
          tone(buzzer, 100);   //Play a tone while door is unlocked
          delay(100);        // ...for 0.1 sec
          noTone(buzzer);     // Stop sound...
          digitalWrite(solenoidPin, LOW);      //Switch Solenoid ON
          delay(5000);
          WrongAttempts = 0;
          changePassword(); {
            setLocked (true); ///.......to lock again
            tone(buzzer, 1000); // Send 1KHz sound signal...
            delay(100);        // ...for 0.1 sec
            noTone(buzzer);     // Stop sound...
            delay(1000);
            lcd.clear();
            goto lockAgain;
          }
          if (keypressed == '#') {
            setLocked (true); ///.......to lock again
            tone(buzzer, 1000); // Send 1KHz sound signal...
            delay(100);        // ...for 0.1 sec
            noTone(buzzer);     // Stop sound...
            delay(1000);
            lcd.clear();
            goto lockAgain;
          }
        }
        else {           //if it's false, retry
          tempPassword = "";
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("*Wrong Password*");
          tone(buzzer, 500, 200);
          delay(300);
          tone(buzzer, 500, 200);
          delay(300);
          WrongAttempts++;  //ADDED
          Attempts();
        }
      }
    }
  }
}

//Change current password
void changePassword() {
retry: //label for goto
  tempPassword = "";
  lcd.clear();
  i = 1;
  while (!changedPassword) {      //Waiting for current password
    keypressed = myKeypad.getKey();   //Read pressed keys
    lcd.setCursor(0, 0);
    lcd.print("CURRENT PASSWORD");
    lcd.setCursor(0, 1);
    lcd.print(">");
    if (keypressed != NO_KEY) {
      if (keypressed == '0' || keypressed == '1' || keypressed == '2' || keypressed == '3' ||
          keypressed == '4' || keypressed == '5' || keypressed == '6' || keypressed == '7' ||
          keypressed == '8' || keypressed == '9' ) {
        tempPassword += keypressed;
        lcd.setCursor(i, 1);
        lcd.print("*");
        i++;
        tone(buzzer, 800, 200);
      }
      else if (keypressed == '#') {
        break;
      }
      else if (keypressed == 'D') {
        goto retry;
      }
      else if (keypressed == '*') {
        i = 1;
        if (password == tempPassword) {
          storedPassword = false;
          tone(buzzer, 500, 200);
          newPassword();          //Password is corrent, so call the newPassword function
          break;
        }
        else {              //Try again
          tempPassword = "";
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("*Wrong Password*");
          tone(buzzer, 500, 200);
          delay(300);
          tone(buzzer, 500, 200);
          delay(300);
          WrongAttempts++;  //ADDED
          Attempts();
          goto retry;
        }
      }
    }
  }
}

String firstpass;
//Setup new password
void newPassword() {
retry: //label for goto
  tempPassword = "";
  changedPassword = false;
  lcd.clear();
  i = 1;
  while (!storedPassword) {
    keypressed = myKeypad.getKey();   //Read pressed keys
    if (doublecheck == 0) {
      lcd.setCursor(0, 0);
      lcd.print("SET NEW PASSWORD");
      lcd.setCursor(0, 1);
      lcd.print(">");
    }
    else {
      lcd.setCursor(0, 0);
      lcd.print("One more time...");
      lcd.setCursor(0, 1);
      lcd.print(">");
    }
    if (keypressed != NO_KEY) {
      if (keypressed == '0' || keypressed == '1' || keypressed == '2' || keypressed == '3' ||
          keypressed == '4' || keypressed == '5' || keypressed == '6' || keypressed == '7' ||
          keypressed == '8' || keypressed == '9' ) {
        tempPassword += keypressed;
        lcd.setCursor(i, 1);
        lcd.print("*");
        i++;
        tone(buzzer, 800, 200);
      }
      else if (keypressed == '#') {
        break;
      }
      else if (keypressed == 'D') {
        goto retry;
      }
      else if (keypressed == '*') {
        if (doublecheck == 0) {
          firstpass = tempPassword;
          doublecheck = 1;
          newPassword();
        }
        if (doublecheck == 1) {
          doublecheck = 0;
          if (firstpass == tempPassword) {
            i = 1;
            firstpass = "";
            password = tempPassword; // New password saved
            tempPassword = ""; //erase temp password
            lcd.setCursor(0, 0);
            lcd.print("PASSWORD CHANGED");
            lcd.setCursor(0, 1);
            lcd.print("----------------");
            storedPassword = true;
            tone(buzzer, 500, 400);
            delay(2000);
            lcd.clear();
            break;
          }
          else {
            firstpass = "";
            newPassword();
          }
        }
      }
    }
  }
}

void setLocked(int locked) {
  if (locked) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("*** LOCKED ***");
  }
  else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("*** UNLOCKED ***");;
  }
}

void Attempts() {
  if (WrongAttempts >= 3) { //UPS....
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("TO UNLOCK PLEASE");
    lcd.setCursor(0, 1);
    lcd.print("INPUT MASTER KEY");
    digitalWrite(buzzer, HIGH);
    delay (5000);
    master();
  }
}

void master() {
lockAgain: //goto label
retry: //label for goto
  tempPassword = "";
  lcd.clear();
  i = 6;
  noTone(buzzer);
  while (!checkPassword) {
    lcd.setCursor(0, 0);
    lcd.print("***MASTER KEY***");
    lcd.setCursor(0, 1);
    lcd.print(">");
    keypressed = myKeypad.getKey();   //Read pressed keys
    if (keypressed != NO_KEY) {   //Accept only numbers and * from keypad
      if (keypressed == '0' || keypressed == '1' || keypressed == '2' || keypressed == '3' ||
          keypressed == '4' || keypressed == '5' || keypressed == '6' || keypressed == '7' ||
          keypressed == '8' || keypressed == '9' ) {
        tempPassword += keypressed;
        lcd.setCursor(i, 1);
        lcd.print("*");       //Put * on lcd
        i++;
        tone(buzzer, 800, 200); //Button tone
      }
      else if (keypressed == 'D') {
        goto retry;
      }
      else if (keypressed == '*') { //Check for password
        if (master_key == tempPassword) { //If it's correct...
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("Correct Password");
          lcd.setCursor(0, 1);
          lcd.print("Door is unlocked");
          tone(buzzer, 100);   //Play a tone while door is unlocked
          delay(100);        // ...for 0.1 sec
          noTone(buzzer);     // Stop sound...
          digitalWrite(solenoidPin, LOW);      //Switch Solenoid ON
          delay(5000);
          WrongAttempts = 0;
          changePassword(); {
            setLocked (true); ///.......to lock again
            tone(buzzer, 1000); // Send 1KHz sound signal...
            delay(100);        // ...for 0.1 sec
            noTone(buzzer);     // Stop sound...
            delay(1000);
            lcd.clear();
            unlockTheDoor();
          }
          if (keypressed == '#') {
            setLocked (true); ///.......to lock again
            tone(buzzer, 1000); // Send 1KHz sound signal...
            delay(100);        // ...for 0.1 sec
            noTone(buzzer);     // Stop sound...
            delay(1000);
            lcd.clear();
            unlockTheDoor();
          }
        }
        else {           //if it's false, retry
          tempPassword = "";
          lcd.clear();
          lcd.setCursor(0, 0);
          lcd.print("*Wrong Password*");
          tone(buzzer, 500, 200);
          delay(300);
          tone(buzzer, 500, 200);
          delay(300);
          WrongAttempts++;  //ADDED
          Attempts();
        }
      }
    }
  }
}

Almost always for these types of questions the answer is to use a state machine.  Basically you endlessly loop checking if inputs have occurred which will move you to a different state.  And, as much as it might pain you, YOU SHOULD NOT USE DELAYS in a state machine.  State machines are not usually the 1st project a new programmer should tackle.  But if you want, I can make a more formal attempt at explaining a state machine in an answer below.

Yes, please. Thank you.

Ok, keep in mind not many here will write complete software solutions as an answer.  My self included.  What most will do is to explain or point to resources to answer the question.  I will essentially tell you to start over and completely define what you want to do then write your own code using a state machine.  Hence why I said this is not necessary the best approach for a new programmer.

I have to say, now that I read the questions several times, it is not clear what you want to do. I think, you want to stop the buzzer from ever making noise.  Hows about just removing it from the project?

you have the wrong idea about the interaction between a microcontroller, a keypad and a siren .... the siren is never controlled by the kepad ... it is always controlled by the microcontroller .... the keypad only supplies keypresses to the microcontroller ... what is done as a result of those keypresses is determined by the program ... so, all you need is to detect a sequence of kepresses .... whether the siren is active during those keypresses is irrelevant to the detection of the key sequence .... start by writing a key sequence detect program

My plan was to create a siren alarm using buzzer, and after 3 unsuccessful attempts the siren will activate until a keypad button was pressed. And it will stop the alarm and direct the screen to enter password function. Everything is working perfectly without the siren, but I do wish I could make it happen.

So ANY keypress should silence the alarm? Briefly, or indefinitely? It might make sense to silence the alarm to give the user a chance to enter a correct password, and then re-activate the alarm if they fail again. You need to describe what you want to do in detail before you can hope to implement it however.

Making it briefly is better like a count down of 10 seconds. If password incorrect just go back into alarm state again. I did not thought of this part.

Consider defining exactly what you want your Arduino application to do using a state machine approach.  Drafting a state machine diagram allows a developer to visualize the inputs to the state machine, the number & types of states necessary and the outputs of the state machine.  The following diagram from the above wikipedia.org link has two states:

A "Locked" and an "Unlocked" state.  You see that a "Coin" is necessary to change from the "Locked" to the "Unlocked" state.
For the number-coded-lock in the question there are likely many more state to consider.  For instance, there may be a state for each button number entered.  The correct number will advance to the next state.  The incorrect number will revert to the state where the state machine expects to see the 1st number in the code.  If all the numbers in the code have been entered correctly, the last state will likely be the state that unlocks the device. A buzzer may have a state of its own.  While in the buzzer state the buzzer will be making noise.  An input to the state machine indicating that 1/2 second has elapsed could be used to exit from the buzzer state.
In this way any desired behavior can be created.  In addition, by using a state diagram, the intentions of the final program are made clear.  And any logical errors are exposed before code creation.