text:
Merge two Arduino projects (change build process)
I'm working on a big software project consisting of several Arduino sketches.
I have one Arduino project providing general functionality, such as TCP/IP communication, parsing queries, handling errors, and some more. This part is fundamental for several devices, which extend this fundamental part by specific functionalities. E.g. one device needs to read temperature sensors and manage a loop to control the temperature and has its own sketch. Another device is driving a servo motor and measuring sun light and also has its own sketch. (And there are some other devices with specific sketches.)
I want to maintain the fundamental part in ONE sketch and the specific parts of the different devices each in OTHER sketches, so I can code both separately.
The problem is, those specific parts can not be compiled if not merged with the fundamental sketch, as this provides basic functions. So if I compile any specific part, I want the fundamental part to be added to the specific one and afterwards the whole code should be compiled.
Is there a way to manipulate the makefile used by the Arduino IDE? Then I could use whatever I want (bash or Python script) to merge in the desired way first.

Assuming that each separate hardware device (ESP32?) must run self-contained with both the fundamental parts, and the use-specific parts, then you would do well to separate out the fundamentals into a library, and then include that library in each use-specific sketch.
The Adafruit Unified Sensor Driver would be one project that shows this. Each of the sensor libraries based on this driver must #include the unified sensor driver library, and that provides some basic properties and interfaces, while each sensor's individual code handles the specifics for communicating to/from that particular unique hardware device.

Okay, that's a pretty simple approach. Don't know how that didn't come to my mind! Thanks for that! Thinks are a bit complicate in my scenario, but I think implementing specific code as a library should work...

In my opinion, you don't need another Arduino. Most of the time, Arduino is fast enough to handle all the things you mentioned. It highly depends on your programming skills. For example, don't make your Arduino do nothing while waiting for a communication to complete and so on. The techniques you require are:
1) No delay functions at all in your programming. Go Arduino's examples and look for 'blink without delay' sketch.
2) Organize your programming. Make use of creating your own functions. Your void loop() should be a to-do-list.


text:
Will I destroy my Arduino Uno if I connect a 600-mA DC motor to the +5V pin?
I know that if I connect an electronic component that consumes more than 20 mA, my Arduino Uno will be destroyed. I don't know if that refers only to digital pins or refers to +5V pins too.

My experience says you will. The 5V port I used to turn that motor it's now not providing the voltage steady, I mean, the voltage on that port fluctuates so that if I try to turn a white LED (using a resistor of course) it blinks or doesn't even turn on.

If you connect a motor to the +5V pin, it will always be on. Is that what you want?
The +5V pin on the Arduino Uno gets power from the on-board 5V linear voltage regulator OR from the USB jack, and thus the host computer. This allows the board to have a fixed 5V source even when applying 9 or 12 V to the barrel jack or the RAW pin, and to be powered by a USB host.
When you draw 600mA for your motor (ignoring what the other devices on the Arduino draw), you are drawing 600mA from the regulator's output. You are also drawing 600mA from the regulator's input, which supplies a higher voltage. Excess power is dissipated as heat. 5V * 600mA is 3W. If you power the board from 9V, you are discarding [(9V-5V)=4V] * 600mA = 2.4W of power. 2.4 Watts is probably too much for the little regulator to handle. It will get too hot and burn up.
If you do this, you will probably be able to still operate it powered by the USB port, as only the 5V regulator is damaged.
However, if you try to draw 600mA and power the board from a USB device like a computer, you may burn up the computer's USB chip and make it useless forever.
For high-power devices like motors, always power them from a sufficient external supply of the appropriate voltage. Be sure to connect the ground of the external power supply to the GND pin of the Arduino. Don't send high current through the Arduino board. The Arduino should handle signals, not power.
Use the signals to activate switching devices like MOSFETs, which are designed to control higher currents by low-power signals.

No, it shouldn't destroy it.  Although you are getting close to the current limit.
The on-board regulator (depending on the board version) can supply up to about 800mA to 1A.
However, the actual maximum current is dependent on the voltage you are supplying the board with - the higher the voltage the hotter the regulator gets and the lower the current that it can supply without shutting down (or burning out).
As long as you run the board from the lower end of the input voltage (7V, say) it should be fine.
It would be better, though, to use an external power supply for the motor anyway, just to reduce the amount of heat the regulator will pump out.
Powering from the USB won't be possible, however: the USB port has a 500mA fuse in the supply circuit.

Upvoted and removed my answer since it was wrong. I edited your answer to also remove the mention about my answer.

source: Stack Exchange

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

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

sort: votes


text:
Can't upload to my Nano after updating to Arduino AVR Boards 1.6.21
I recently had the Arduino IDE notify me of available boards updates, so I updated. Since then when I try to upload to my Nanos it fails:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x01

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I installed Arduino IDE 1.0.6 and found that I can upload to all my Nanos with that IDE version.
How can I upload to my Nanos using Arduino AVR Boards 1.6.21?

The latest version of the Arduino IDE for windows is 1.8.5. What version are you running? What does "not work" mean?

Does not work needs more clarification. Can you even open the IDE? Does a sketch compile, but fail to upload? Does it upload, but the Arduinio doesn't run/operate?

Provide the actual error messages

what i mean is, since i updated the IDE a few days ago! none of my boards will not work with the updated IDE. i am using 1.8.5 sorry all 5 boards would not work, i have even tried a new NANO board i received today, and even it still will not work!! with 1.8.5 out of the 6 boards i have, i have only been able to get 3 nano's and 1 chinese arduino uno to work and that is only because i have downloaded the IDE 1.0.6 my original arduino uno r3 and another Chinese board still will not work! thank's for getting back to me :-) much appreciated.

Define "Not work". That phrase covers a multitude of possible issues.

Sorry i see, the IDE starts up ok! but when i upload a sketch, it compiles the program no problem, then just keeps the green bar on for about a minute then it gives out the error: programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x8a
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
and that is with a brand new board!

Did you select the correct port in the IDE?

yes for both the nano and uno they both use com 3 but i have tried other com's and it just will not work, in IDE 1.0.6 'iv'e just tried it, it uploads no problem, and the lights on the board flash.

Please take a minute to read the question now that I have edited it. That is how you are supposed to ask a question. Not the sloppy garbage you wrote. Please make a better effort in your future use of Stack Exchange.

Arduino recently changed the bootloader they ship on their official Nano boards. This required a change in the hardware definition for the Nano, which was the sole reason for the Arduino AVR Boards 1.6.21 release.
The new Nano hardware definition is not backwards compatible with Nanos that use the previous ATmegaBOOT bootloader. For this reason a new menu option was added: Tools > Processor > ATmega328P (Old Bootloader). If you select that option the uploads to your Nanos will work again.

just tried ATmega328P (Old Bootloader) still does not work :-(

it works, when i changed it, it was on com port 1, i just changed it to com port 3 and it work's now, thank you very much, i thought i had done all my boards in lol really thanks. :-)

Just tried the (Old bootloader) option after uninstalling and installing Arduino IDE.  Really terrible problem.  Couldn't figure it out. All the other boards (pro micro, mkr zero, etc) were working but not Nano.  Really annoying but so glad I found this solution.  Thanks!

Check weather your arduino nano is Chinese having CH340G chip. If the chip is there then you have to install CH340G drivers in your computer..

I also had similar issues after upgrading my Ubuntu system.
Selecting 3.3V for the Mini board did the trick, For the Nano, the old loader worked.

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


text:
Detect button press inside a for() cycle
I was working on a project with an LED strip, where I'd like to cycle through various effects with just a press of a button. The problem is that I don't know how to detect the press of the button to change effect while in for() cycling colors to have a rainbow effect (so it's a multitasking problem, I think).
Could you help me? :)
#include <Adafruit_NeoPixel.h>

#define pin 5
#define led 15
#define button 7
Adafruit_NeoPixel strip = Adafruit_NeoPixel (led,pin,NEO_RGB+NEO_KHZ800);

int doggo=0;

void setup(){
 strip.begin();
 pinMode(button,INPUT);
}
void loop(){

 int buttonVal=digitalRead(button);

 if(buttonVal==HIGH){
  doggo++;
  delay(300);
 }
 if (doggo>2){
  doggo=0;
 }
 while (doggo==0){
  //whole strip red
  for (int i=0;i<led;i++){
   strip.setPixelColor(i,255,0,0);
   strip.show();
  }
 }
 while (doggo==1){
  //rainbow effect
  uint16_t i, j;
  int rainbowSpeed=10;
  for(j=0; j<256*5; j++) {

   for(i=0; i< strip.numPixels(); i++) {

    strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    strip.show();

   }

  }

 delay(rainbowSpeed);

 }

 while (doggo==2){
  //whole strip blue
  for (int i=0;i<led;i++){
   strip.setPixelColor(i,0,0,255);
   strip.show();
  }
 }

}

uint32_t Wheel(byte WheelPos) {
 WheelPos = 255 - WheelPos;

 if(WheelPos < 85) {
  return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
 }
 if(WheelPos < 170) {
  WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
 }
 WheelPos -= 170;
 return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

You could use the Bounce2 library.
Call the update() method regularly and then check the state with read().
e.g.
for (...) {
  button.update();
  if (button.read() == HIGH) {
     //change pattern
     break;
  }
  // Do strip stuff.
}

As an added bonus the bounce library will debounce your button.

You should use a hardware interrupt. Depending on your microcontroller, you have different pins available.
Here is a reference for more details and syntax

Thanks, I correctly implemented the hardware interrupt since it works with single colors (there is no digitalRead in loop, just a attachInterrupt() in setup). Still, it doesn't work with the rainbow effect :(

I finally solved!
I tried the Bounce2 library, but it acted really strange (the effects passed from the first one, then the third one, then the first one again for a fraction of second and automatically to the second one, plus other things :/ )
It looks like I just needed to add a normal digitalRead inside for() and a return, I don't usually make those errors xD


text:
Set up mesh network with RF Transceivers
I would like to set up a mesh network of Arduinos with the following features/capabilities:

No master node
Arduinos capable of bootloading other Arduinos through RFs
Capable of communicating over TCP/IP
More than 255 possible network addresses

Is this possible, or infeasible? If it is, what are some software packages that meet these requirements. I was looking at RF24Gateway, RF24Mesh, RF24Network, etc., but as far as I can tell these require having a master node, and they only support 255 IP addresses. Is this correct? I was also looking at an Optiboot clone that works with RF24 modules here but it seems like it requires the other Arduino to be connected to a USB.
Any suggestions/clarifications are appreciated. Thanks!

How far have you come in reading about what functionality the NRF24L01 can support (such as addressing, network topology, etc)?

You always can make your own 'protocol' with nRF24L01, you don't have to use the Master/Slave protocol which is built in. These do not work with IP addresses, but they use addressing, not sure how many.


text:
One of the LEDs on my Arduino is very dim
I made a vibration sensor using an Arduino. It is connected to an Android app. When the start button is pressed on the app, a red light LED turns on (stand by), and after 2 - 5 seconds, the red LED turns off and a green LED turns on (meaning the system is ready). The green LED turns off if the sensor detects a vibration. The green LED works perfectly. However, the red LED is always dim. I've tried testing the red LED separately, it works fine. I've tried changing the pin it's connected to, it's still dim. I've included my code below if it helps.
Thanks in advance.
int ledPin = 13;
int ledPin2 = 9;
int EP = 7;
int cal = 500;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(EP, INPUT); //set EP input for measurement
  Serial.begin(9600); //init serial 9600
}

void loop() {
  if (Serial.available()) {
    char c = Serial.read();
    if (c == '1') {
      cal = 100;
    }
    if (c == '2') {
      cal = 200;
    }
    if (c == '3') {
      cal = 300;
    }
    if (c == '4') {
      cal = 400;
    }
    if (c == '5') {
      cal = 500;
    }
    if (c == '6') {
      cal = 600;
    }
    if (c == '7') {
      cal = 700;
    }
    if (c == '8') {
      cal = 800;
    }
    if (c == '9') {
      cal = 900;
    }
    if (c == '0') {
      int randm = random(2, 6);
      int x = randm * 1000;
      digitalWrite(ledPin2, HIGH);
      delay(x);
      unsigned int tm = millis();
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin2, LOW);
      while (1) {
        long measurement = TP_init();
        char br = Serial.read();
        if (br == 'x') {
          break;
        }
        if (measurement > cal) {
          digitalWrite(ledPin, LOW);
          unsigned int out = millis() - tm;
          unsigned char i = out;
          Serial.print(out);
          break;
        }
      }
    }
  }
}

long TP_init() {
  delay(0);
  long measurement = pulseIn (EP, HIGH);
  //wait for the pin to get HIGH and returns measurement
  return measurement;
}

try pinMode(ledPin2, OUTPUT)

You need to add this line for the other LED pin:
pinMode(ledPin2, OUTPUT);

You need this same line for the other LED pin:
pinMode(ledPin2, OUTPUT);

This should have been a comment to the other answer; to fix his typo.

@Blair Fonville - If you hover your mouse over the timestamp at the end of Juraj's comment, you notice a "tool tip" popup with the UTC timestamp of that event. If you compare that to the timestamp of CrossRoads answer, you will see that Juraj's comment gave the correct answer before CrossRoads. If anyone deserves credit for the first correct answer, it's Juraj.

Irrelevant. ....

If it would make you feel any better, you could just down-vote my answer. It will only cost you 1 rep.

Crossroads answered only 19 seconds after Juarj's comment. I doubt he had time to read the comment, and type in his own reply, in 19 seconds. Comments under the question are not for answering it. That's why we have answer boxes. Please don't start bickering about this sort of thing. If you like an answer, vote it up, if you dislike it, vote it down, otherwise ignore it, or maybe make a comment explaining why it is wrong.


text:
Problem using Optiga Trust X I2C
Did someone ever used the Infineon Optiga Trust X module with Arduino using any I2C library ?
Here is the technical documentation of the Trust X module.
I'm trying to get the I2C_STATE register data but I don't receive anything after the Wire.requestFrom().
I also tried with the DSS Circuits I2C Master Library, same results.
Thanks
Full code :
#include <Wire.h>
#define PIN_RST 8
#define PIN_VDD 9

void setup() {
  pinMode(PIN_RST, OUTPUT);
  pinMode(PIN_VDD, OUTPUT);
  digitalWrite(PIN_RST,LOW);
  digitalWrite(PIN_VDD,LOW);

  Serial.begin(115200);
  delay(2000);
  Wire.begin(); // join i2c bus (address optional for master)

  digitalWrite(PIN_VDD,HIGH);  // sartup the Trust X module
  digitalWrite(PIN_RST,HIGH);

  delay(15);  // startup min delay
}

long val = 9999;

void loop() {
  Wire.beginTransmission(48); // transmit to device #48 (0x30)
  Wire.write(byte(0x82));            // sends instruction byte
  Wire.endTransmission();     // stop transmitting

  Wire.requestFrom(48, 4);
  while(Wire.available()==0){}

  val = Wire.read(); // Reads the data from the register
  Serial.print("val = ");
  Serial.println(val);

  delay(5000);

}

Testing a new sensor always starts with the i2c scanner https://playground.arduino.cc/Main/I2cScanner Use the address that the i2c scanner finds. Avoid that the sketch stops in the while statement. Test if 4 bytes are received, but don't use the while.

Hi and thank you for your answer. I have already tried the scanner and it did not found any device. The problem is I think at the startup of the Trust X module as specified in the documentation. But i can't see what I'm doing wrong.

If the i2c scanner does not find it, then no other code will work. What was the result of the i2c scanner? it was not 48. Adapt the i2c scanner to set the pin levels in the setup(). You could make the time after the reset 1 second instead of 15ms and also add a long delay between setting the pins vdd and reset high. You could show a photo of the wiring. I trust Infineon that they use the standard i2c. The first thing to do is to make the i2c scanner work. After that you can start to write good code, for example removing the while and reading 4 bytes.

What value are the pull up resistors you are using on the two I2C lines?

@Jot The i2c scanner answered with "No device". I know I will receive 4 bytes by reading the 0x82 register but as it didn't worked I just wanted to receive at least 1 byte this is why I used the while loop. I'll try to add longer delays and if it still not work, I will share a photo of the wiring. Thank you for your answer.

@CodeGorilla I'm using the Arduino internall pull up resistors, I assumed that the internal resistors were compliant with the i2c protocol (~5K). I have an example code that works fine with the Raspberry Pi 3 without adding external resistors so i tought that it will work the same with the Arduino.
So i will try to add external pull up resistor and disable the internal resistors. Unfortunately I do not have the equipment to visualize the signal. Thank you for your answer

I'm now using the Trust X EVAL KIT that I think should have the pull up resistor included and I still can't receive anything. The I2C scanner can't even find the device.

You need 4.7k pull-ups on both the data and clock lines.  It the scanner doesn’t show the device then can you try a different device.  I once spent hours chasing a fault which turned out to be I had wired the ic backwards.

@CodeGorilla I have tried with external pull up resistor (4.7K) and nothing changed.Today,  I have finally been able to read a register. Honestly i don't know what changes made it possible. I'll post my code if it can help someone

So I finally succeeded to read a register value. I don't really know where was the problem. Here is the code if it can help someone (the scanner still does not work btw) :
#include <Wire.h>

#define DEVICE_ADDRESS 0x30

#define PIN_RST 8
#define PIN_VDD 9

void printOutput(byte *out, int out_len){
   int y=0;
  Serial.print("out = ");
  for(;y<out_len;y++){
    Serial.print(out[y],HEX);
  }
  Serial.println("");
}

void coldReset(){
  pinMode(PIN_RST, OUTPUT);
  pinMode(PIN_VDD, OUTPUT);
  digitalWrite(PIN_VDD,LOW);
  digitalWrite(PIN_RST,LOW);
  delayMicroseconds(2000);
  digitalWrite(PIN_VDD,HIGH);  // sartup the Trust X module
  digitalWrite(PIN_RST,HIGH);
}

int I2C_get(byte reg, byte *out, int out_len){
  int i=0, nbSend=0, nbAvailable=0, ret=0;
  Wire.beginTransmission(DEVICE_ADDRESS); // transmit to device #48 (0x30)
  nbSend=Wire.write(reg);            // sends instruction byte
  Wire.endTransmission();     // stop transmitting
//  Serial.print("nb send = ");
//  Serial.println(nbSend);

  delayMicroseconds(50);
  Wire.requestFrom(DEVICE_ADDRESS, out_len);

//  nbAvailable=Wire.available();
//  Serial.print("nb available = ");
//  Serial.println(nbAvailable);

  if(Wire.available()==out_len){
    for(;i<out_len;i++){
      out[i]=Wire.read();
    }
  }
  else ret=-1;

  return ret;
}

void setup() {

  Serial.begin(115200);
//  Wire.begin(); // join i2c bus (address optional for master)
//  coldReset();
//  delayMicroseconds(15000); // Startup time
}

void loop() {
  int y=0, out_len, ret;
  byte res1[]={0x00,0x00,0x00,0x00};

  Wire.begin(); // join i2c bus (address optional for master)
  Wire.setClock(400000);
  coldReset();
  delayMicroseconds(15000); // Startup time

  out_len=4;
  ret=I2C_get(byte(0x84),res1,out_len);
  if(ret!=-1){
    printOutput(res1,out_len);
  }
  else{
    Serial.println("Error I2C_get");
  }

  Wire.end();
  Serial.println("");
  delay(5000);
}

It looks like the answer is a bit delayed, but if somebody else sees this issue once again.
It might not be directly visible in the documentation (Datasheet or Solution Reference Manual), but here what you can find in the Trust M Datasheet Annex B (Section 11):
"The OPTIGA™ Trust M will not acknowledge the slave address sent by a host if it is either busy or in idle state. Hence the host must retry or repeat the transaction until it is successful or timed out for 100 milliseconds (extreme case).
The specified guard time must be applied between each attempt of write / read operation by the Host I2C driver."
The chip always goes into an idle or sleep state if no command is issued in a defined time period, unless a Sleep Activation Delay isn't changed.


text:
No Matching Function for call to Ultrasonic:Ultrasonic(int,int)
Good Day! I am trying to code the distance of Ultrasonic Sensor but the problem is it gives me this error. Any idea? Please help.
#include <Ultrasonic.h>

// HR-SC04 SENSOR
#define TRIGGER_PIN   5
#define ECHO_PIN      6

Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);

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

// Global variables
int lastDistance = 0;
int thisDistance = 0;

void loop()
{
  // Copy over last distance
  lastDistance = thisDistance;

  // Get new this distance
  thisDistance = ultrasonic.Ranging(CM);

  if (outlierCheck(lastDistance, thisDistance)) {
    Serial.println("Outlier found: " + String(thisDistance));
  } else {
    Serial.println(String(thisDistance) + " cm");
  }

  delay(10);
}

// Check for significant jumps and outliers in sensor reading
bool outlierCheck(int lastDistance, int thisDistance) {

  // if the difference between measures is greater then 20cm, outlier found
  if ((lastDistance - thisDistance) > 20) {
    return true;
  } else {
    return false;
  }
}

look at the demo code that comes  with the library

I did already but it still give me this error "Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);"

the error messages tell you where the problem is ..... take another look at the demo code

You are very likely to have confused the libraries.
When using your code with the library at https://github.com/JRodrigoTech/Ultrasonic-HC-SR04, the code compiles perfectly fine. The constructors match up with your code.
//Constructor 1
Ultrasonic(int TP, int EP);
//Constructor 2
Ultrasonic(int TP, int EP, long TO);
//methods.. (used in your source)
long Timing();
long Ranging(int sys);

I think you have installed this Ultrasonic library: https://github.com/ErickSimoes/Ultrasonic. It has the same header file and class name but the class is constructed differently
//Constructor 1
Ultrasonic(uint8_t sigPin) : Ultrasonic(sigPin, sigPin) {};
//Constructor 2
Ultrasonic(uint8_t trigPin, uint8_t echoPin, unsigned long timeOut = 20000UL);
//Note that a constructor with only 2 arguments is not directly visible

You should go into the Arduino IDE and uninstall your current "Ultrasonic" library from the library manager. Then download the zip file from the first given github repository and add that ZIP file to your libraries.
Alternatively of course, you can use the second library and its correct example code.
Also note that your Arduino IDE 1.0.6 is extremely outdated, current one is 1.8.5


text:
How to get location of the hand indoors
I made a glove that tracks the positions of the fingers, but I don't know how to get the location of the hand relative to the person using them. Any suggestions? It should be quite accurate but I would really like to make even a rough prototype of it.
Ps. I'm using a Arduino Nano (atmega328p) to send and process the positions of the finger to a Java application through serial if you wanted to know.

Are you talking about a person and their own hand/fingers?

Yes. It reads the positions using a pressure sensors.

I think the easiest option is to measure the angles of the shoulder, elbow and wrist. Then use some math to calculate the position of the hand, with respect to the shoulder.

The only way to check the relative position is, first to define, what is the absolute position of a person, is it his other hand, his heart, his head, his foot?
When you defined the absolute position of the person, then you need to use a sensor at that absolute position that can measure the current position, e.g. GPS (if outside), but this is not accurate.
You also can use a gyroscope or device similar to what you use for the glove. When you initially keep them together you now the relative position (around 0.0). Than you can track movement differences of both the glove and the absolute position, send it to the glove (or vice versa) and calculate the difference. There might be calibration issues.
Another way is to use a camera and continueously check for a line of sight signal (IR, led), but this also can have issues (like distance measurement, what if there is no line of sight etc).

I tried using visual tracking but it might be quite impractical. Leap Motion has done some good work with hand tracking but I have no idea how they have accomplished it.

GPS would be way too for hand location. Ultrasonic sensing might work but I guess it might bounce from every object and create false readings.

I also don't have experience with this. I had a similar problem. Tracking the relativie position of a moving person and a static object, but even that is hard (line of sight, MPU6650 seems unreliable after half an hour, but maybe there are better gyroscopes. But you have two moving 'objects' (hand + absolute position). Also you can use one static object, and two relative positions (glove + absolute person) and send changes to the static object, but it will have also cons.

And ultrasonic does not work when line of sight is not present.


text:
Get UUID from Arduino Nano, ATmega328
I need to know how to obtain the UUID from an Arduino Nano ATmega328 for a project.

Why not program a UUID in EEPROM once? There is no hardware UUID. https://stackoverflow.com/questions/21559264/unique-machine-id-for-arduino-project

You don't have a UUID.
You only get a UUID in the USB-enabled chips, like the ATMega32U4.
You would have to create your own UUID and store it in EEPROM, or embed it within your sketch.


text:
Is it possible to use LCD (the 16 pins) without potentiometer?
look, I don't have any potentiometer lying around, and I don't have any variable resistor.
So is it possible to instead use a fixed resistor for the LCD display ?

Use regular resistors like Majenko said. But if you want to get extra fancy, you could use one of the PWM pins to set the contrast in software

Sure. You can use two resistors in series to be a "fixed value" potentiometer.
The "wiper" of the potentiometer is the junction between the two resistors.
I can't tell you what values to use, so you'll have to experiment. You want them to add up to somewhere in the tens of kilo-ohms though, ideally, though the value isn't that critical - it's the ratio between the two values that is of interest, and it's that which gives you your contrast setting.


text:
this code is not printing anything on the serial moniter. the code is in setup()
Serial.println("CLEARDATA"); //clears up any data left from previous projects
Serial.println("LABEL,time,load reading(gm),microwave output,CO sensor,sound data,magnetic sensor "); //always write LABEL, so excel knows the next things will be the names of the columns (instead of Acolumn you could write Time for instance)
Serial.println("RESETTIMER"); //resets timer to 0

//pinMode(AOUTpin, INPUT);//sets the pin as an input to the arduino
// pinMode(ledPin, OUTPUT);//sets the pin as an output of the arduino
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");

Please include the entire setup() function.

Serial.begin(9600); is missing

There can be different reasons, among:

The speed of the serial port does not match with the serial 'monitor'
The speed of the serial port is not set at all (can cause first problem)

I don't see this before the print statements:
Serial.begin(9600); // or some other speed
That will prevent anything from printing.


text:
Is there a equivalent to #define DEBUG 0 declare by VS2017 with VisualMicro (arduino) project?
Especially on ESP32*/8266, when you select debug (debug/release) :  as a target, VisualMicro detect it and start the simple debugger (without JTAG).
Do you know if when target is debug, is there a #define created somewhere by VS that could be use with #ifdef for example?
*ESP32 WROOM not ESP32 WROVER able to debug through USB double chanel

the documentation for visual micro is here. the relevant section is "defines" about halfway down the page.

Ok but strange behaviour, need to be tested...

_DEBUG is define by VMicro in project parameter for each target with Define _DEBUG Constant set to 1 (0 by default)

Visual studio Debug/release compilation target switch has no effect during compilation but affect intellisense #ifdef _DEBUG is grayed or not. So it is not easy to follow the real compile target.
I suggest to set Define _DEBUG Constant to 1 in VS 'debug' compilation target project configuration and compilation will follow intellisense. But:
Another source here

Another advise, clean the compiled file because VS doesn't detect Define _DEBUG Constant like another "standard" #define and your .cpp affected are not recompiled.


text:
Sending Data from ESP8266 to PHP
I want to display the RFID tag value to a html file.
I am using ESP8266 ESP-01 module, EM-18 Reader Module, Arduino Uno and Xampp for hosting PHP.
Right now, I am getting a value of "255" in Arduino whenever I scan a RFID tag. But I am supposed to get the 12-digit alphanumeric RFID tag value.
I have attached the Arduino and also the output screen of the Serial Monitor.
I have my college submission next week so it's urgent. Any help would be appreciated.
#include "SoftwareSerial.h"
String ssid ="Home";
String password="****";
SoftwareSerial esp(2, 3);// RX, TX
String data;
String server = "192.168.0.182"; // www.example.com
String uri = "/testget.php";// our example is /esppost.php
int DHpin = 0;//sensor pin
byte dat [12];
String tag;

void setup() {
  pinMode (DHpin, OUTPUT);
  esp.begin(9600);
  Serial.begin(9600);
  reset();
  connectWifi();
}

//reset the esp8266 module

void reset() {
  esp.println("AT+RST");
  delay(1000);
  if(esp.find("OK") )
    Serial.println("Module Reset");
}

//connect to your wifi network

void connectWifi() {
  String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";
  esp.println(cmd);
  delay(4000);
  /*
  if(esp.find("OK")) {
    Serial.println("Connected!");
  }
  else {
    connectWifi();
    Serial.println("Cannot connect to wifi"); }*/
}

byte read_data () {
  byte data;
  for (int i = 0; i < 13; i ++) {
    if (digitalRead (DHpin) == LOW) {
      while (digitalRead (DHpin) == LOW); // wait for 50us
        delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'
      if (digitalRead (DHpin) == HIGH)
        data |= (1 << (12-i)); // high front and low in the post
      while (digitalRead (DHpin) == HIGH);
// data '1 ', wait for the next one receiver
    }
  }
  return data;
}

void start_test () {
  digitalWrite (DHpin, LOW); // bus down, send start signal
  delay (30); // delay greater than 18ms, so DHT11 start signal can be detected
  digitalWrite (DHpin, HIGH);
  delayMicroseconds (40); // Wait for DHT11 response
  pinMode (DHpin, INPUT);
  while (digitalRead (DHpin) == HIGH);
    delayMicroseconds (80);
  // DHT11 response, pulled the bus 80us
  if (digitalRead (DHpin) == LOW);
    delayMicroseconds (80);
  // DHT11 80us after the bus pulled to start sending data
  for (int i = 0; i < 13; i ++)
    // receive tag value data, the parity bit is not considered
    dat[i] = read_data ();
  pinMode (DHpin, OUTPUT);
  digitalWrite (DHpin, HIGH);
  // send data once after releasing the bus, wait for the host to open the next Start signal
}

void loop () {
  start_test ();
  // convert the bit data to string form
  tag= String(dat[12]);
  data = "tag=" + tag;// data sent must be under this form //name1=value1&name2=value2.
  Serial.println(data);
  httppost();
  delay(1000);
}

void httppost () {
  esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.
  if( esp.find("OK")) {
    Serial.println("TCP connection ready");
  }
  delay(1000);
  String postRequest =
  "POST " + uri + " HTTP/1.0\r\n" +
  "Host: " + server + "\r\n" +
  "Accept: *" + "/" + "*\r\n" +
  "Content-Length: " + data.length() + "\r\n" +
  "Content-Type: application/x-www-form-urlencoded\r\n" +
  "\r\n" + data;
  String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.
  esp.print(sendCmd);
  esp.println(postRequest.length() );
  delay(500);
  if(esp.find(">")) {
    Serial.println("Sending..");
    esp.print(postRequest);
    if( esp.find("SEND OK")) {
      Serial.println("Packet sent");
      while (esp.available()) {
        String tmpResp = esp.readString();
        Serial.println(tmpResp);
      }
      // close the connection
    esp.println("AT+CIPCLOSE");
    }
  }
}

Output :

tag= String(dat[12]); doesn't do what you think it does. Also you are trying to read 13 bytes into an array of 12 bytes and cram 13 bits into a byte. And for some reason using pin 0 for the sensor while still using serial.

Please can you help me with the code? I am new to Arduino and I'm really struggling with my grades on the line!

change <13 to <12 and properly convert the byte(/char) array to a String

I did that and I'm getting 254 now. I wrote this: String myString = String(myByteArray); to convert.

Your example code doesn't have myByteArray, so saying you tried that doesn't help anyone understand the context in which you tried it. You can edit your question to include updated code you have tried, etc.

I got it working using the code below:
#include "SoftwareSerial.h"
String ssid ="Home";

String password="%Qwerty@123%";
char input[12];
int count = 0;
SoftwareSerial esp(2, 3);// RX, TX

String data;

String server = "192.168.0.182"; // www.example.com

String uri = "/testget.php";// our example is /esppost.php

int DHpin = 0;//sensor pin

byte dat [12];

String temp;

void setup() {

pinMode (DHpin, OUTPUT);

esp.begin(9600);

Serial.begin(9600);

reset();

connectWifi();

}

//reset the esp8266 module

void reset() {

esp.println("AT+RST");

delay(1000);

if(esp.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network

void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";

esp.println(cmd);

delay(4000);
}

byte read_data () {

byte data;

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

if (digitalRead (DHpin) == LOW) {

while (digitalRead (DHpin) == LOW); // wait for 50us

delayMicroseconds (30); // determine the duration of the high level to determine the data is '0 'or '1'

if (digitalRead (DHpin) == HIGH){

data |= (1 << (7-i)); // high front and low in the post
 }
while (digitalRead (DHpin) == HIGH);

// data '1 ', wait for the next one receiver

}

} return data; }

void start_test () {

digitalWrite (DHpin, LOW); // bus down, send start signal

delay (30); // delay greater than 18ms, so DHT11 start signal can be detected

digitalWrite (DHpin, HIGH);

delayMicroseconds (40); // Wait for DHT11 response

pinMode (DHpin, INPUT);

while (digitalRead (DHpin) == HIGH);

delayMicroseconds (80);

// DHT11 response, pulled the bus 80us

if (digitalRead (DHpin) == LOW);

delayMicroseconds (80);
while(count<12){
input[count] = Serial.read(); // Read 1 Byte of data and store it in the input[] variable
      count++;          // increment counter
      delay(5);}
// DHT11 80us after the bus pulled to start sending data

//for (int i = 0; i < 4; i ++)

// receive temperature and humidity data, the parity bit is not considered
/*for(int x=0;x<12;x++)
for(int i=0;i<12;i++)
//dat[i] = read_data ();
dat[x]=input[i];*/

pinMode (DHpin, OUTPUT);

digitalWrite (DHpin, HIGH);

// send data once after releasing the bus, wait for the host to open the next Start signal

}

void loop () {

start_test ();

    count = 0;      // Reset the counter to zero
    temp = "";
    // convert the bit data to string form
for(int i=0;i<13;i++)
temp += input[i];
Serial.println(temp);
//Serial.println(temp);

data = "tag=" + temp;// data sent must be under this form //name1=value1&name2=value2.

httppost();

delay(200);

}

void httppost () {

esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

if( esp.find("OK")) {

Serial.println("TCP connection ready");

} delay(100);

String postRequest =

"POST " + uri + " HTTP/1.0\r\n" +

"Host: " + server + "\r\n" +

"Accept: *" + "/" + "*\r\n" +

"Content-Length: " + data.length() + "\r\n" +

"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.

esp.print(sendCmd);

esp.println(postRequest.length() );

delay(500);

if(esp.find(">")) { Serial.println("Sending.."); esp.print(postRequest);

if( esp.find("SEND OK")) { Serial.println("Packet sent");

//while (esp.available()) {

//String tmpResp = esp.readString();

//Serial.println(tmpResp);

//}

// close the connection

esp.println("AT+CIPCLOSE");

}

}}

You can follow this awesome tutorial if you want to connect your RFID RC522 module to PHP. Source Code and a step by step tutorial are provided. You only need NodeMcu and RC522 RFID module.
https://devcraze.com/tutorials/connecting-rfid-scanner-to-php-using-nodemcu-wifi-module/


text:
Strange behavior on bitwise operation
i am trying to write a simple program that writes the outputs of an accelerometer (which comes down to 3 analog inputs) onto an SD-Card.
I got the hole thing working fine (sending the values as simple strings), however i wanted to increase the frequency at wich the data is taken and therefore tried to send the data to the SD card encoded in binary, and therefore i am doing some bitwise manipulation.
Unfortunately some (as i think) strange things happen. When i add a simple bitwise manipulation the data on the SD card is pretty messed up. (I was unable to detect a pattern but it seems some Bytes are missing or or are there twice without any regularity):
Here is an example of a working version:
// Get raw accelerometer data for each axis
unsigned int rawX = analogRead(A0);
unsigned int rawY = analogRead(A1);
unsigned int rawZ = analogRead(A2);

byte b1 = (byte) (rawX>>2);
byte b2 = (byte) (rawY>>4);
b2 = b2 + (byte) (rawX<<6);
byte b3 = (byte) (rawZ>>6);
b3 = b3 + (byte) (rawY<<4);
byte b4 = (byte) (rawZ);
b4 = (byte)b4*4;
//b4 = (byte)b4<<2;

// get pressure
//temp = BMP180_getTemp();
//float a = 0;
//float a = pressure.altitude(BMP180_getPressure(), baseline);

unsigned long t = millis();

byte writeB[] ={
    b1,
    b2,
    (byte) (rawZ>>6), //replacing this with '(byte) ((rawZ>>6)|(0b11110000 & rawY))' will cause the error
//also replacing with b3 creates the error as well
    b4,
    (byte) (t>>16),
    (byte) (t>>8),
    (byte)t, (byte)0};

dataFile.write(writeB,8);

dataFile.flush();

As mentioned as a comment in the code changing the way the byte is calculated messes up my data on the SD card. I tried several other things however it seems that the following operations are causing the error: | & << >>  (However i am using some of them to calculate e.g. b2)
What i don't get is how changing how a byte is calculated affect the data output.
Maybe (probably) i overlooked some easy mistake but i cant figure out what is happening. Any help would be greatly appreciated since im working on this since quite a while.
(I am aware that the program does currently not transmit all necessary data but i startet from scratch and programmed step by step to locate/identify the error)

Please include a minimal program that compiles and demonstrates your problem. Ideally include actual and expected output.

It is unclear what you do with the code. If you try to use the whole memory by sharing the bits of a byte,you cannot use the arithmetic + operator. Instead use the | (bitwise or) operator

i indeed try to share the bits of a byte. i tried the bitwise or operator as well. However why can i not use add (in case e.g. i know the 4 last bits are filled with 0 and the first 4 i could add this to another byte from wich i know the first 4 bits are zeros.)

why can i not use add .... how do you know that you cannot? .... you have not shown the data, so it is impossible to guess what it happening

Your computation of b3 seems sane to me. “the data [...] is pretty messed up” is not a useful description of the problem. Please, edit your question to add: 1. the values of rawX, rawY and rawZ, 2. the values of b1, b2, b3 and b4 you would expect, and 3. the values of b1, b2, b3 and b4 you get instead.

Sorry for being unclear about how the data is messed up. The problem was not the computation of the values. I did not even checked them. I saw the data was not as expected because i was expecting a 0x00 every 8th byte, which was not there or only sometimes. To me it seemed as if some Bytes where lost or interchanged. Since the problem did vanish once i tried to send dummy values (eg every byte 0x11) i was unable to figure out how the data is mixed up.

Your way of sharing the bits between the three values seems a bit confusing. Your code for saving the bits is correct in the meaning of that you save all relevant information. Your bytes are shared in this way (H means high portion of value, L is the low portion of value):
     ____HX_____
b1: | 0000 0000 |
     _LX_ ___HY___
b2: | 00 | 000000 |
     __HZ__ __LY__
b3: | 0000 | 0000 |
     __LZ____
b4: | 000000 | XX |

This is a rather complex way of dividing the space. Also, since you are not using the remaining 2 bits of b4 you don't have to shift there.
When you are getting garbled values from your SD card, it wildly depends on how you are reading the bytes (you haven't shown us the code for that). As a suggestion I will explain how I would do it.

We have 3 values from analogRead(), which each have 10 bits. So in total we have 30 bits, which can be transmitted in 4 bytes (or 32 bits). When adding bits from another value, I think you can use the + operator (opposing to my comment) if the bits of the different values don't overlay (which should be anyway). For my part I like to use the bitwise or | to show more clearly, what is done there and to easier check for errors in alignment (easy to see in binary representation). Do as you like. I will use the | operator for now.
// Get raw accelerometer data for each axis
unsigned int rawX = analogRead(A0);
unsigned int rawY = analogRead(A1);
unsigned int rawZ = analogRead(A2);

byte b1 = rawX & 0xFF;
byte b2 = rawY & 0xFF;
byte b3 = rawZ & 0xFF;
byte b4 = (rawX & 0x0300) >> 2
          | (rawY & 0x0300) >> 4
          | (rawZ & 0x0300) >> 6;

The low portion of the values are saved in the bytes b1 to b3. The upper 2 bits of every value is saved left-aligned to b4 (The & 0x0300 isolates the upper portion, bit 9 and 10, in the values.).
You can read these values in this way:
rawX = b1 | (( b4 & 0b11000000) << 2);
rawY = b2 | (( b4 & 0b00110000) << 4);
rawZ = b3 | (( b4 & 0b00001100) << 6);

b1 to b3 are the start for our retrieved raw values. Then we add the other 2 bits to the raw values. For this we first isolate the bits from b4 from the positions we used in the upper code. Then we shift them to the left, until they are directly above the 8 bits of the start values.

Thanks for the detailed description! I am reading the data by opening the datafile with notepad++ using the HEX-Editor. The reason why i am sure the data is wring is simply because the 8th byte should always be 0x00. This is however not the case. I agree that using the | operator is more readable and i normally use it. Since it seemed to cause the error i tried to avoid it. I like your way of storing the data since the pattern is easier to understand. I tried your solution and it worked! Thanks a lot. I am still a little bit curious to why my code did behave so strange.


text:
Digital Pins reads 1 when configured with internal_pullup
I work with Arduino DUE. I would like to configure few of my digital pins as INPUT pins. When the µc sets these particular 4 pins , the DUE must be activated. Something like a DATAREADY pin in the SPI,where the data will be sent to the slave only,when it sets the pin to 1.
According to the datasheet , the external µC would set the pin state from 0 to 1. I tried this program for experimenting the effect of digital pins,
int RDY = 52;
void setup() {

 Serial.begin(9600);
pinMode(RDY,INPUT_PULLUP);
pinMode(50,INPUT);
digitalWrite(RDY,HIGH);

}

void loop() {

digitalRead(RDY);
digitalRead(50);
digitalRead(11);
digitalRead(12);

Serial.println(digitalRead(RDY));
Serial.println(digitalRead(50));
Serial.println(digitalRead(11));
Serial.println(digitalRead(12));

delay(100);
}

Results obtained are; 1,1,0,0 as expected. I cannot find a proper way to detect the change of state of the pin (from 0 to 1). To make detect changes, I connected/disconnected the 5V output pin of DUE to the particular digital pins. The results never changed with connection and disconnection of the 5V wire for any pin.
Is there any possible way to detect the change of the pin state as in INPUT mode in Arduino DUE?
Most examples are dealing with switches,but in my case I need a pin as a input.
Thanks

I connected/disconnected the 5V ... your experimentation lacks some steps.

Should i add the ground?

if you are doing "experiments" by applying a logic 1 (+5V), why did you not apply a logic 0 (gnd)? ....  if you were a biologist that is studying how frogs react to coloured light, would you use blue light only?

https://www.electronics-tutorials.ws/logic/pull-up-resistor.html

pinMode(50,INPUT); digitalWrite(RDY,HIGH);  with this I tried pinMode(50,INPUT); digitalWrite(RDY,LOW); Then later I realised ,that Input will always only stay high(becoz of oull-ups) , as writing LOW on the input is not affected.  I realised I had messed it !

There is no difference between a switch and a "pin" for input. All are either HIGH or LOW. You tie it HIGH with the pullup, and then try giving it a HIGH with +5V (Caution: The Due is a 3.3V device, not 5V!).
At no point do you ever give it a LOW signal (connect the input to GND), so how can it ever read LOW?

So should I add ground to the external µc too??

You mean connect the grounds of both MCUs together...? Erm.... yes?   https://hackingmajenkoblog.wordpress.com/2016/12/06/the-importance-of-sharing-grounds/

Oh that link was excellent,and I was silly ! So for experiment , I connected the pin 52 with GND from the DUE board. It read 0 when connected. I will connect the DUE's GND with the external µc's GND , for the actual program.


text:
This error is shown continuosly after first time it compiles successfully
I got this error:
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"
Multiple libraries were found for "LiquidCrystal.h"  Used: C:\Program
Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal
Not used:
C:\Users\siddh\OneDrive\Documents\Arduino\libraries\libraries readlink
C:\Users\siddh\OneDrive\Documents\Arduino\libraries\SimpleDHT\SimpleDHT.cpp:
The system cannot find the file specified. Error compiling for board
Arduino/Genuino Uno.

This report would have more information with "Show verbose output
during compilation" option enabled in File -> Preferences.

This is the code i use:
//We'll start by adding our libraries

 #include <LiquidCrystal.h>

 #include <SimpleDHT.h>

//Declaring digital pin no 6 as the dht11 data pin

int pinDHT11 = 6;
SimpleDHT11 dht11;

//Declaring the lcd pins

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// Don't forget to choose 9600 at the port screen

  Serial.begin(9600);

//Telling our lcd to start up

  lcd.begin(16, 2);

}

void loop() {

  //These serial codes are for getting readings on the port screen aswell as the LCD display, since they'll offer us a more detailed interface

  Serial.println("=================================");
  Serial.println("DHT11 readings...");
  delay(2000);

  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;

  //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor
  if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("No reading , err="); Serial.println(err);delay(1000);
    return;
  }

  Serial.print("temp: ");
  Serial.print((int)temperature); Serial.print(" Celcius, ");
  Serial.print("humidity:");
  Serial.print((int)humidity); Serial.println(" %");

  //Telling our lcd to refresh itself every 0.75 seconds
  lcd.clear();

 //Choosing the first line and row

 lcd.setCursor(0,0);

//Typing Temp: to the first line starting from the first row
  lcd.print("Temp: ");

//Typing the temperature readings after "Temp: "
  lcd.print((int)temperature);

//Choosing the second line and first row
  lcd.setCursor(0,1);

//Typing Humidity(%): to the second line starting from the first row
  lcd.print("Humidity(%): ");

//Typing the humidity readings after "Humidity(%): "
  lcd.print((int)humidity);

  delay(750);
}

You should post your entire output, not just the last couple of lines. The error itself is invariably one of the first things printed, not the last. Als you should do as it suggests and turn on verbose output.

There is a bug that causes this error when you use the Arduino IDE with files located under OneDrive.
The simplest solution is to move any files that will be used with the Arduino IDE out of OneDrive to any other convenient location on your computer. It looks like you have your sketchbook folder located in the OneDrive so you will want to change that via the Arduino IDE's File > Preferences > Sketchbook location. The Arduino IDE does not automatically move the files from the previous sketchbook folder to the new folder so you will need to either move any files to the new sketchbook folder or else reinstall them.
There are some possible workarounds if you want to to continue using the Arduino IDE with OneDrive listed in the issue report:
https://github.com/arduino/arduino-builder/issues/254

I have had this problem as well and I concur with per1234 that the solution (for now) is that you have to move your sketches out of the OneDrive folder.
You used to be able to have your sketches within OneDrive (I did for many years). Since release 1.6.6 things have changed and you can no longer compile files that you once used to be able to compile inside a OneDrive folder.
In addition to per1234's great answer (ie move the sketches outside of the Ondrive folder) there are 2 other options. Firstly you could download and install version 1.6.5 which was before the Arduino Builder was incorporated. The other option is to use the Beta V1.9.0 avalable from the Beta Channel.

UPDATE:
The issue with OneDrive folders has been resolved as of version 1.8.6.
https://www.arduino.cc/en/Main/ReleaseNotes

ARDUINO 1.8.6 2018.08.23
[ide]

Updated arduino-builder to 1.4.0:

parallel build (improve compile speed)
better reuse of already compiled files
Windows: fixed build for sketch stored under OneDrive cloud folders

Simply update to a newer version of the Arduino IDE and you will be able to compile and upload your sketch.


text:
Button isn't working properly
I am new in arduino trying to make race game. My problem is that my button (all buttons) is working sometimes and sometimes not. I am pretty sure that it's because of my code. Could you please help me with it?
Here is my code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pausebetween = 1;
int spaceBetween = 1;
int maxElemnets = 4;
int obstacleArray[4][2];
int obstacles[4] = {3,3,2,3};
bool gameStart = false;
byte player[8] =
{
 B00000,
 B00000,
 B10100,
 B11110,
 B11111,
 B11110,
 B10100,
 B00000
};
byte obstacle[8] =
{
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111,
 B11111
};
byte enemy[8] =
{
 B00000,
 B00000,
 B00101,
 B01111,
 B00101,
 B00000,
 B00000
};
byte empty[8] =
{
 B00000,
 B00000,
 B00000,
 B00000,
 B00000,
 B00000,
 B00000
};
byte fire[8] =
{
 B00000,
 B00000,
 B00000,
 B11111,
 B00000,
 B00000,
 B00000
};
int mat[2][24] = {
  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
  {1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  };
int up = 0;
int down = 0;
int reset=0;
int atack=0;
void setup() {
 pinMode(9, INPUT);
 pinMode(8, INPUT);
 pinMode(7, INPUT);
 pinMode(6, INPUT);
 Serial.begin(9600);
 lcd.createChar(0, player);
 lcd.createChar(1, empty);
 lcd.createChar(2, enemy);
 lcd.createChar(3, obstacle);
 lcd.createChar(4, fire);
 lcd.begin(16, 2);
}
void loop() {
  up  = digitalRead(9);
  down  = digitalRead(8);
  atack  = digitalRead(7);
  reset  = digitalRead(6);
  if(atack){
    for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
            if(mat[j][i]==1){
              mat[j+1][i]=4;
              Serial.println(mat[j+1][i]);
            }
        }
      }
  }
  if(reset){
    clearStage();
    gameStart = true;
  }
  if(gameStart){
    generateObstacles();
    redrawGame();
    moveObstacles();
  }
  delay(1000);

 }

void generateObstacles(){
  int obscount = random(1,4);
  int types[4][2] = {{1,3},{2,1},{1,1},{2,1}} ;
  int type = random(0,4);
  for(int i = 0; i< obscount; i++){
    mat[0][16+i] = types[type][0];
    mat[1][16+i] = types[type][1];
  }
  int spacecount = random(2,5);
  pausebetween = obscount + spacecount;
}
void redrawGame(){
   for(int j = 15; j >= 0; j--){
    for(int i = 0; i < 2; i++){
      lcd.setCursor(j,i);
      lcd.write(mat[i][j]);
    }
  }
}
void clearStage(){
  for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
            if(i!=1 && j!=1){
               mat[i][j] =1;
          }
        }
      }
}
void moveObstacles(){
   for(int i = 0; i<2;i++){
        for(int j = 0; j<23; j++){
           if(mat[i][j]!=0){
            mat[i][j] = mat[i][j+1];
          }else{
            mat[i][j-1]=1;
          }
          if(mat[i][j]==4){
            mat[i][j-1]=0;
            mat[i][j-2]=1;
           }
        }
      }
}

Scheme:

I have two suggestions.

Get rid of the delay(1000); in the loop and replace it with code from the BlinkWithoutDelay example that comes with the Arduino IDE: https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay.
Debounce the buttons. There are several libraries on Github that simplify this, for example: https://playground.arduino.cc/Code/Bounce.


text:
How can I declare global array with its length stored in EEPROM?
I am working with Arduino UNO connected with BV4612 display.
I am working on a simple code that controls several water pumps. Each pump has several modes it can run in. I store these modes in an array.
The number of water pumps may vary, and I'd like to store that value in EEPROM (either arduino's or display's).
When the pump count is fixed, I use fixed value, defined by macro:
#define     PUMP_COUNT      18      //How many pumps we have

uint8_t pumpModes[PUMP_COUNT];

void setup(){...}
void loop(){...}

I'd like to get rid of fixed defined value of PUMP_COUNT, and rather load it from EEPROM, or save the new pump count into the EEPROM if needed.
However, I can't declare an array if I can't read from EEPROM before setup() function like this (from address 32 for example):
uint8_t pumpModes[EEread(32)];

void setup(){...}
void loop(){...}

Is there a solution to get the value from EEPROM so I can declare global array's length with it?
Thanks.

You can't create variable length arrays in C. That's not how C works.
Instead you have to create an array that is big enough to store the maximum number of pumps you want to be able to deal with.
The array "size" is then just a number in a variable obtained from wherever you like (including EEPROM).
It doesn't matter if you don't use all of the array. The rest just sits there twiddling its metaphorical thumbs.
The other option, if you are only going to define the array once at startup, or very rarely change the size, is to use malloc():
uint8_t *pumps;
uint8_t nPumps = 0;

void setup() {
    nPumps = EEPROM.read(32);
    pumps = (uint8_t *)malloc(nPumps);
}

You can change the array size then with:
nPumps = 8; // for example
pumps = realloc(pumps, nPumps);

And dispose of the array with:
nPumps = 0;
free(pumps);

It's best to try not to change the array size once created, since that can make swiss cheese of your heap, and is not a friendly thing to do on a small microcontroller. If you can decide the array size once in setup and keep it the same all the time the program is running this is a safe operation. Otherwise it becomes risky.

Thanks, that's what I thought and I used exactly this as a solution so far. I was just trying to save as much RAM as possible, but this has to suffice.

You could use a pointer and use malloc() and free() to change the array size instead. I'll detail it in my answer.

@MiragePV, save RAM for what? is there something that can use the extra RAM if there are less pumps?

Trying to save ram could be a problem, as you could en up with a program that works with 14 pumps, but as soon as you add a 15th the program runs out of RAM and you program starts behaving weirdly. By allocating the maximum number pumps needed, you’ll immediately notice if you run out of memory.

@Juraj: The less RAM used by static data (globals and heap), the more is available for the stack. Static data is assigned from the bottom of RAM upward; the stack starts at the top of RAM and builds downward during execution. What is left in the middle at any point during execution is the free RAM. If you only use malloc() and free() at most once, in setup(), then the top of static data doesn't change. The bottom of the stack changes frequently, building downward with each function call, and retreating upward again when the function returns.

and can the code for less pumps profit from more stack space?

It is possible to use a dynamically allocated array, with malloc and free.
To create such an array use:
uint8_t* pumpModes;

Somewhere in setup (preferably):
pumpModes = malloc(sizeof(uint8_t) * PUMP_COUNT);

Freeing the memory is not needed if you need it throughout the entire program, otherwise you can use
free(pumpModes);

However, take in mind that if you continuously malloc and free memory in the loop() function, you can get memory 'gaps' and you run out of memory really quickly since the Uno has only a few KB of RAM memory.


text:
4WD rover not moving
I am trying to make a 4WD vehicle. I have uploaded the code, all connections are OK and I have used L298N and HC-05. But when running the Bluetooth app, the motors do not rotate. I tried with both an Uno and a Nano and nothing happens. Could anyone help me spot the errors?
I used this code in Arduino Uno:
#include <SoftwareSerial.h>

SoftwareSerial BT(0, 1); //TX, RX respetively
String readvoice;

void setup() {
  BT.begin(9600);
  Serial.begin(9600);
  pinMode(4, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
}
//-----------------------------------------------------------------------//
void loop() {
  while (BT.available()) {  //Check if there is an available byte to read
    delay(10);              //Delay added to make thing stable
    char c = BT.read();     //Conduct a serial read
    readvoice += c; //build the string- "forward", "reverse", "left" and "right"
  }
  if (readvoice.length() > 0) {
    Serial.println(readvoice);

    if (readvoice == "*forward#")
    {
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(100);
    }
    else if (readvoice == "*back#")
    {
      digitalWrite(3, LOW);
      digitalWrite(4, LOW);
      digitalWrite(5, HIGH);
      digitalWrite(6, HIGH);
      delay(100);
    }
    else if (readvoice == "*left#")
    {
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(800);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(100);
    }
    else if (readvoice == "*right#")
    {
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(800);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(100);
    }
    else if (readvoice == "*stop#")
    {
      digitalWrite(3, LOW);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(100);
    }
    else if (readvoice == "*keep watch in all direction#")
    {
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(100);
    }
    else if (readvoice == "*show me Garba#")
    {
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);

      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(400);
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH);
      digitalWrite(5, LOW);
      digitalWrite(6, LOW);
      delay(600);
      digitalWrite(3, LOW);
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, LOW);
      delay(500);
      digitalWrite(3, HIGH);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
      digitalWrite(6, HIGH);
      delay(500);
    }
    readvoice = ""; //Reset the variable
  }
}

This is the wiring diagram of the rover:

First try it without the bluetooth.  What power source are you using for the motor?   The L298 is a horribly lossy part and you'll need an extra AA cell or two just to offset its losses.  Meanwhile the small 9v batteries wouldn't have the current capability for a motor project.  And where are the other two motors to make this 4wd?

Sir i have used a 9v battery and i have connected the other 2 motor with the other motor and connected their positive and negative terminal together and please also tell me that the code is correct or not and if there is problem with L298N then what should i use..

Do not use 9v batteries for motor projects.  Try 6 or 7 AA cells - with the absurdly lossy L298, maybe even 8 AA's.

Thank you sir it worked without bluetooth but what is then the problem coming with bluetooth connection.???

Well, for one, you shouldn't use software serial on pins 0 and 1, those are hardware serial.  Did you decide to do that on your own, or are you following directions written by someone who didn't know what they are doing?

I tried it myself sir and then where to connect the tx and rx pins instead of 1 and 0 serial pins.....

Possible duplicate of Arduino 4wd rover

If you have the wiring right, which you have probably checked 100 times by now, then its probably the fact that you aren't supplying enough current to break the stall of the motor. Search the web for the motor's datasheet and look up the "Stall current" then see if you are supplying enough current.
Have you checked the motor without the gearbox attached, if that's possible?
The motor will have both voltage and current requirements. You are using a 6V motor but we also need to know the running current and stall current so you can workout if your batteries are capable of supplying that. Are you trying to run one motor or 4? Get one motor working first and then move up to 4 when you need to supply 4 times the power.
Also can I just check that you have the batteries in series (to give you 7.4V). This probably isn't enough if the motors require exactly 6v because of the 2V drop through the IC.
Measure the voltage into the bridge and into the motor, as shown in the web page. Also measuring the current would help, but you will have to search to see how best to do that.

Sir i have also used a 3.7 volt battery with 7800Mah for the gear motor....

Yes sir I have tried without gear and it still vibrates....

Please can you check the rest of the things in the answer too?


text:
GPS(Incorrect time showing)
Anyone help? It shows incorrect time. Please help.
  /* Conexion pines
     Arduino        GPS
        D3           RX
        D4           TX
  */

  #include <SoftwareSerial.h>  //incluimos SoftwareSerial
  #include <TinyGPS.h>         //incluimos TinyGPS

  TinyGPS gps;  //Declaramos el objeto GPS
  SoftwareSerial serialgps(10,11);      //Declaramos el pin 4 (Tx del GPS) y 3 (Rx del GPS)

  //Declaramos la variables para la obtención de datos
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long chars;
  unsigned short sentences, failed_checksum;

  void setup()
  {
   Serial.begin(9600);  //Iniciamos el puerto serie
   serialgps.begin(9600); //Iniciamos el puerto serie del gps

   //Imprimimos en el monitor serial:
   Serial.println("");

  }

  void loop()
  {
   while(serialgps.available())
   {
    int c = serialgps.read();
    if(gps.encode(c))
    {
     float latitude, longitude;
     gps.f_get_position(&latitude, &longitude);
     Serial.print("Latitud/Longitud: ");
     Serial.print(latitude,5);
     Serial.print(", ");
     Serial.println(longitude,5);
     gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
     Serial.print("Date: "); Serial.print(day, DEC); Serial.print("/");
     Serial.print(month, DEC); Serial.print("/"); Serial.print(year);
     Serial.print(" Time: "); Serial.print(hour, DEC); Serial.print(":");
     Serial.print(minute, DEC); Serial.print(":"); Serial.print(second, DEC);
     Serial.print("."); Serial.println(hundredths, DEC);
     Serial.print("Altitud (metros): "); Serial.println(gps.f_altitude());
     Serial.print("Rumbo (grados): "); Serial.println(gps.f_course());
     Serial.print("Velocidad(kmph): "); Serial.println(gps.f_speed_kmph());
     Serial.print("Satelites: "); Serial.println(gps.satellites());
     Serial.println();
     gps.stats(&chars, &sentences, &failed_checksum);

     delay(10000);
    }
   }
  }

how far was it off?

nope its not :(

I meant what was the time when you ran that code? What time should it have shown.

it should be 10:15 pm

And what time zone are you in?

GPS time is in UTC, not UTC+8, where you seem to live (not accounting for daylight savings time)

UTC +8 . how can i do it? :(

http://www.instructables.com/id/Adjusting-GPS-Date-and-Time-to-your-Time-Zone/

I already try that but it give me error "'setTime' was not declared in this scope"

Like Majenko's comments suggested, you must shift the UTC time to your local time.  The Time library can help you do this.
There are some other problems:

You cannot wait 10 seconds without processing the characters. The Arduino receive buffer only has room for 64 characters. The GPS device could have sent 10000 characters during that time, so most of them will get dropped. This prevents the GPS library from parsing a GPS data successfully.  It will eventually "see" a complete set of data, sometime after the 10 seconds.  You may see data once every 11 seconds, not 10.
You are printing the several values even though they may not be valid.  For example, if you are not moving, or you do not have good satellite reception, the GPS device may not provide a speed.
The Arduino millis() clock will not be synchronized with the GPS clock. You could use the GPS updates as an exact 1-second clock. Simply count 10 fixes as they arrive, and this will mean that 10 seconds have elapsed.
You should use a different serial port and/or library. This answer describes the various choices: HardwareSerial (i.e. Serial on pins 0 & 1), AltSoftSerial (8 & 9 on an UNO) or NeoSWSerial (any two pins).

Here is a NeoGPS version of your sketch that addresses these issues:
#include <NeoSWSerial.h>
#include <NMEAGPS.h>

NMEAGPS gps;  //Declaramos el objeto GPS
gps_fix fix;  // all GPS fields, including date/time, location, etc.
uint8_t fixCount;
NeoSWSerial serialgps(10,11);

void setup()
{
 Serial.begin(9600);  //Iniciamos el puerto serie
 serialgps.begin(9600); //Iniciamos el puerto serie del gps

 //Imprimimos en el monitor serial:
 Serial.println( F("Test") );

}

void loop()
{
 // Check for GPS characters and parse them
 if (gps.available( serialgps ))
 {
  // Once per second, a complete GPS fix structure is ready.  Get it.
  fix = gps.read();

  // Count elapsed seconds
  fixCount++;

  if (fixCount >= 10)
  {
    fixCount = 0; // reset counter

    // adjust from UTC to local time
    if (fix.valid.time)
      adjustTime( fix.dateTime );

    printGPSdata();
  }
 }
}

void printGPSdata()
{
  Serial.print( F("Latitud/Longitud: ") );
  if (fix.valid.location) {
    Serial.print( fix.latitude(), 5 );
    Serial.print( F(", ") );
    Serial.print( fix.longitude(), 5 );
  }
  Serial.println();

  Serial.print( F("Date: ") );
  if (fix.valid.date) {
    Serial.print( fix.dateTime.date  ); Serial.print('/');
    Serial.print( fix.dateTime.month ); Serial.print('/');
    Serial.print( fix.dateTime.year  );
  }

  Serial.print( F(" Time: ") );
  if (fix.valid.time) {
    Serial.print( fix.dateTime.hours ); Serial.print(':');
    if (fix.dateTime.minutes < 10)
      Serial.print( '0' );
    Serial.print(fix.dateTime.minutes); Serial.print(':');
    if (fix.dateTime.seconds < 10)
      Serial.print( '0' );
    Serial.print( fix.dateTime.seconds );
    Serial.print('.');
    if (fix.dateTime_cs < 10)
      Serial.print( '0' );
    Serial.print( fix.dateTime_cs );
  }
  Serial.println();

  Serial.print( F("Altitud (metros): ") );
  if (fix.valid.altitude)
    Serial.print( fix.altitude() );
  Serial.println();

  Serial.print( F("Rumbo (grados): ") );
  if (fix.valid.heading)
    Serial.print( fix.heading() );
  Serial.println();

  Serial.print( F("Velocidad(kmph): ") );
  if (fix.valid.speed)
    Serial.print( fix.speed_kph() );
  Serial.println();

  Serial.print( F("Satelites: ") );
  if (fix.valid.satellites)
    Serial.println( fix.satellites );
  Serial.println();
  Serial.println();
}

//--------------------------

void adjustTime( NeoGPS::time_t & dt )
{
  NeoGPS::clock_t seconds = dt; // convert date/time structure to seconds

  // Offset to the local time
  const int32_t          zone_hours  = +8L;
  const NeoGPS::clock_t  zone_offset = zone_hours * NeoGPS::SECONDS_PER_HOUR;
  seconds += zone_offset;

  dt = seconds; // convert seconds back to a date/time structure

} // adjustTime

If you want to try it, NeoGPS, AltSoftSerial and NeoSWSerial are available from the IDE Library Manager, under the menu Sketch -> Include Library -> Manage Libraries. NeoGPS is smaller, faster, more reliable and more accurate than all other GPS libraries.
Even if you don't use it, there are many suggestions on the Installation and Troubleshooting pages.


text:
What does the term "9g" in servo's rating mean?

I frequently see 9g mentioned in servos. I searched the web but couldn't find any worthwhile answers. At first I thought it meant 9grams but the weight of the servo isn't 9 grams, so have to be something else.

I'm voting to close this question as off-topic because it is not at all about Arduino.

If servos isn't an integral part of Arduino, then what is? I don't expect arduino to rotate a wheel from thin air.

The idea of servo weight seems irrelevant to me as I see servos measured in kilograms. I tend to think this measurement have to do something with servo's power, like how big things it can move.

According to Flite Test web site, the 9g reference is the weight without the wire lead. They measured one model at 8 grams rounded down. I suspect the weight also ignores the horn as well as the wire.
The article referenced on the web site calls the weight reference as a standard, which means that it more likely allows for heavier or lighter servos as long as the size of the servo matches.
If you purchase a servo for a model known to use a 9g servo, you know the hole you have to build for it to fit. If you purchase a 5g servo, it will be a different hole and you may have a 6 or 7 gram weight, but the servo fits as it should.

So the "9g" is a standardized case size for servos?

I should have put standard in quotes, as anybody can state a standard, but it's the consistent use of 9g for servos of a particular size, regardless of weight that makes it work in this sort of circumstance.

From a model airplane perspective...
The "9g" is supposed to mean 9 grams in weight. Each vendor has their own way to define their weight.

with wires
without wires
with or without control horns
"about the same as a competitor's 9 gram servo"

Most are not accurate.
It is not a standard for size, and has nothing to do with hole size or screw spacing

According to the link it is.
However, if you look at this more detailed datasheet, it shows 14.7 g.
Probably it's the weight of the motor part itself, not the plastic enclosure around it.
Btw, most websites (without actually using data sheets), mention a weight of 9 g.


text:
ESP8266 doesn't detect WiFi
I try to connect my NodeMCU Amica to my WiFi network, but it doesn't detect any networks around. I chose Board "NodeMCU 1.0 (ESP - 12E Module)", upload speed of 115200 and I have the correct port selected.
When I try the blink sketch, it works perfectly, but when I try to use the WiFiScan example, I only get the message "no networks found" and I don't.
I did pay attention that the upload speed in the sketch and monitor are always the same as the one I selected. Also, I tried out different upload speeds, without any succes either.
I already changed my network to 2.4 GHz, and also tried to downgrade the libraries to older versions, but nothing helped till now.
About any help, I would be really glad.

try to erase the flash with esptool to clear sdk settings if you changed  firmwares and arduino package versions

Ok, finally managed to get it running, but it still doesn't find any networks. By erasing the flash you just meant basically esptool.py --port /dev/tty.SLAB_USBtoUART erase_flash, am I right?

Firstly try to set it up as AP and check whether is it working ? If not, there is issue with power supply. Because WiFi Scan requires more current... than normal WiFi connection operation.

Make sure you have entered correct ssid and password for that.
It is very much case sensitive.
Second reason for this can be insufficient amount of power supply supplied to it so make sure you are using good quality of power adapter for it.
3.https://tttapa.github.io/ESP8266/Chap07%20-%20Wi-Fi%20Connections.html
Then try refering this link step by step...
Hope this will help
Thanks


text:
How to connect to LCD and communicate via serial usb simultaneously? (UNO)
Pretty simple home automation project I am working on. I'm trying to hook my arduino which has a 16x2 LCD, DHT22 temp/humidity sensor to my Pi via usb. I want to be able to maintain the values on the LCD and send the values to the Pi via serial usb.
I am in Arduino IDE currently and can see the serial values in the monitor...however the LCD is all scrambled. Can someone take a look at my code and tell me what I am doing wrong?
#include <LiquidCrystal.h>
#include "DHT.h"

#define DHTPIN 8
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

void setup() {

  lcd.begin(16, 2);
  dht.begin();
  Serial.begin(9600);
}

void loop() {
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    lcd.print("Failed to read from DHT sensor!");
    return;
  }

  lcd.setCursor(0,0);
  lcd.print("Temp = ");
  lcd.print(f);
  lcd.setCursor(0,1);
  lcd.print("Humidity = ");
  lcd.print(h);
  lcd.clear();

  Serial.println(f);
  Serial.println(h);
}

First try a (demo) sketch only for the LCD to see if it works without your own code and the added additional components.

pin 1 is TX of Serial, you can't use it for lcd

So I just need to change the pin 1 out?


text:
Arduino Serial Output Gone Wild!
I'm having a slight problem that I'm unable to work out. I am using an arduino Uno to print an incremental, but predefined wheel circumference. This is all working beautifully except it gives a negative reading during execution, and then runs into the positive etc. Without being exact, the output is something like the following:
1.85, 3.71, 5.56, 7.41, 9.27, 11.15....
When this multiple reaches 32.00 or greater, it then counts negatively back down to zero, then positively up to 32.00 again.
I can't quite work out why this would be, so hoping that one of you guys would be able to shed some light. The code is as follows:
#include <Arduino.h>

int InterruptPin = 2;
int circ = 1854; //mtrs
int km = 0;

void calculate(){
    km = km + circ;
    //float temp = km / 1000;
    float temp = (float)km / (float)1000;
    Serial.println(temp);
}

void setup(){
    pinMode(InterruptPin, INPUT);
    attachInterrupt(digitalPinToInterrupt(2), calculate, RISING);
    Serial.begin(9600);
}

void loop(){

}

km is never reset but continously incremented.
km = km + circ;

This leads to an overflow of the value after some time.
When you declare int km;, then int  on an Arduino Uno is int16_t, it thus has a maximum positive value of 2^15 - 1 = 32767. Since circ is constant 1854, after executing the ISR a total of CEIL(32767 / 1854) = 18 times, km becomes greater than that maximum positive value. Thus an integer overflow occurs which takes you back to the maximum negative value of the int16_t. (See https://en.wikipedia.org/wiki/Integer_overflow)
You might want to use uint32_t or similiar from stdint.h if you want to cover a greater value range. I think however your underlying algorithm is flawed, since even then km will  overflow after some later time. You must reset it at some point or only store the number of revolutions, which is a much smaller number. If you want to get the traveled distance then, you take the number of revolutions and multiply it by the circumference.
Also you should not not use any Serial printing within in interrupt service routine! And you should also declare your used interrupt variables as volatile. Read this article for more info.

I would recommend unsigned long for large integer values. (it is uint32_t on 8-bit AVR)

Thanks, some very constructive critisism and a brilliant explanation.


text:
Fail to retrieve the value from gsm sim 900A by using AT Command to PHP script
I am currently trying to establish a connection between my gsm sim900A to one of my test server. The connection seems pretty good so far, though I'm a little bit confused why there are no values retrieved by my php file. Even so, the insert query works although it insert empty value into the database. So my question is how to retrieve it properly? I already change the method in php script to POST, both of it doesn't return any good signs.
Arduino Code:
void postData()
{
  sim900a.println("AT+HTTPINIT");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPPARA=\"CID\",1");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPPARA=\"URL\",\"test.my/demo/writedata.php\"");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPDATA=12,10000");
  delay(1000);
  printSerialData();

  sim900a.println("strBoton=999");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPACTION=1");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPREAD");
  delay(1000);
  printSerialData();

  sim900a.println("AT+HTTPTERM");
  delay(1000);
  printSerialData();
}

PHP Code:
<?php
$servername = "test.my";
$username = "****";
$password = "****";
$dbname = "test";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$Boton = $_GET["strBoton"];

$sql = "INSERT INTO test VALUES ('$Boton')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>

Output:
AT+HTTPINIT
OK

AT+HTTPPARA="CID",1
OK

AT+HTTPPARA="URL","test.my/demo/writedata.php"
OK

AT+HTTPDATA=12,10000
DOWNLOAD
OK

AT+HTTPACTION=1
OK

AT+HTTPREAD
OK

AT+HTTPTERM
+CME ERROR: operation not allowed

AT+SAPBR=0,1
OK

I am not sure but, in this tutorial at page 8, it does almost the same code pattern like yours. You might want to check it. Sorry but I don't know PHP, I can't help you with it.
But I am confused with AT+HTTPACTION, since AT+HTTPACTION=0 is the read and AT+HTTPACTION=1 is the post. Check the tutorial and optimize your commands.
Also check this one. It writes WAIT=6 after AT+HTTPREAD before terminating it.

my references are both the link that u provide in the first paragraph and this one, https://electronics.stackexchange.com/questions/231224/posting-to-php-server-using-sim900-gprs-with-at-commands . I am still learning how to arduino by the way so i'm having a hard time swallowing the flow of the codes.

i will try to modify the codes and differentiate between AT+HTTPACTION=0 and 1 for now, as for the WAIT=6, I believe that is the delay time after the execution. Thanks for reminding me.

I will check the link you send. I will command on it if anything necessary. Thanks for the link by the way.

I'll change it to AT+HTTPACTION=0 and remove certain lines of codes and it works! Thank you sir. :)

Your welcome, always happy to help a fellow ;-)


text:
Problem for control speed of a DC motor with a L298N
(Not native english speaker here, feel free to edit my sentences)
I try to control the speed of a DC motor with a L298N shield but it doesn't work very well. Here is my scheme :

The power comes from a transfo with an adjustable voltage of ~7v 1.0 Amp. I don't care about the sens of rotation, so I set IN1 to 5v and IN2 to the ground, is it right to do it like that ?
Now here is the code I'm using :
#define CONTROL_M   9  // To Enable input

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

void loop ()
{
    test_analog_motor();
}

void test_analog_motor()
{
    for (int i; i < 250; i=i+25)
    {
        Serial.println(i);
        analogWrite(CONTROL_M, i); // Any value between 0 and 255
        delay(500);
    }
}

With that code, the speed of my motor should progressively increase and then goes back to 0. I'm aware that, maybe if the value is too low, the motor will have trouble to start so I "help" it manually.
If I doesn't use the Enable output of my Arduino and just use the jumper instead, the motor turns with a good torque. This prooves at least that my shield isn't damaged.

Now here is the problem I have : With the scheme I've shown above, it simply doesn't work, nothing happens when I set the grounds in common, why ? Then if I remove the cable that goes to the arduino ground, it works but the motor has a very low torque, it seems also that there is a kind of latency in regards to what display the Serial monitor.
I feel a bit stupid with what I did with the grounds, it seems wrong t me  but I don't know what to do instead :/ What can I do ? My goal is to have the best possible control of the speed of that DC motor in term of reactivity, does a L298N is suited for that ?
EDIT
I did tested the PWM with an oscilloscope and a multimeter, the arduino PIN I was using worked correctly. I don't know why but now, the shield works too, I mean : Problem solved. One theory is that I adjusted the tension of my power supply under 5V. In that cas the shield doesn't nothing Arduino is magic sometimes...

Your delay is probably too long - your code will take over 2 minutes to reach full speed.  Also the L298 is an obsolete, antiquated, lossy part.  FET drivers have been the norm for over a decade, but people keep putting these obsolete designs on ecommerce sites for the unsuspecting to buy.

could you cite the names of some good FET drivers example ?

@ChrisStratton  By the way, my code will not take over 2 min to reach its full speed. look, it's i = i + 25 so 10 step of 500 ms period is about 5 secondes

for (int i; i < 250; i=i+25)? You might want to initialize the variable i, like so for (int i=0; i < 250; i=i+25).

Are you sure you don't need to supply 5V to the board?

@Gerben I can use the board without Arduino, if Enable Jumper is set, my motor will turn. the problem comes from PWM

You do need the ground wire. The reason it 'works' without it is that enable input effectively then has an aerial connected and is responding in the same was as if you touch the input jack on an amplifier and hear a buzzing sound.
There is a link behind the blue connectors that enables the onboard 5v regulator. I assume you have this fitted, or it wouldn't work with the jumper as you describe.
There is a tutorial here : http://www.instructables.com/id/How-to-use-the-L298-Motor-Driver-Module-Arduino-Tu/
I can't see anything different from what you're doing that would cause it to fail, but perhaps you have a problem with pin 9 from your board - you might have damaged it by misconnection, as certain ways of wiring that schematic could put 12V on the arduino pin.  You could also try using pin 13 : the arduino LED should then be lit in sympathy with the PWM signal and you'll know it's working.

Yes what you say about buzzing sound makes sence. indeed, I'm wondering if I'm not damaging the pins of my arduino with that assembly. so what's weird is that the board doesn't seems to do anything when grounds are common. I will test the PWM separately to see if they work as expected


text:
Cannot connect to mBot after using Arduino IDE
Today I bought an mBot (from Makeblock) the one that uses 2.4G serial connection. After assembling it, I connected to it using mBlock (software based of Scratch) and I could control it using keyboard triggers. Then I went in Arduino IDE and used it to run some scripts on the mBot.
Next I tried to switch back to mBlock software, but now it cannot connect to the mBot anymore. Whatever Scratch-like scrips I build, they don't run anymore in mBlock.
Did I miss anything? Is there anything I can do so I can start using mBlock again?

There's probably some default firmware on the "mBot" (whatever that is) that is controlled by these scripts. Since you replaced that with Arduino code you're pretty much stuffed unless you can replace that original firmware.

I received some really good piece of advice on the official forum and it solved my problem, it now works:

When you go back to using the mBlock (Scratch) environment you will
  need to reload the firmware (Upgrade firmware from the Connect menu
  item). At least that’s what I’ve had to do. Oh, and make sure that you
  have shut down the Arduino environment to release the serial port.