text:
Temperature on two 7-segments displays
I'm new to the arduino board and my teacher gave us a project with little to no teaching about the language the board uses, or how to effectively program with it.
I'm trying to read temperature from a DHT11 and display it on two separate 7-segments displays. I've been trying to do this by editing a code he provided us that makes one display count from 0 to 9. I've been to hook up and read the DHT11 and split the temperature into two variables. But I have no idea how to make the variables display on the seven segment displays. My code is.
//DHT11 set up
#include <dht11.h>
dht11 DHT11;
void setup()
{
   DHT11.attach(4);
   for (int i = 0; i < 4; ++i)
    pinMode(i, OUTPUT);
   for (int i = 8; i < 11; ++i)
    pinMode(i, OUTPUT);
}
static int temp = DHT11.fahrenheit();
static int digit_0 = temp % 10;
static int digit_1 = temp - digit_0;
static int digit_2 = digit_1 / 10;
// Output pins.
static int output[] = {0,1,2,3};
// 8421 code lookup table.
static int segs_encoding[][4] =
  {{0,0,0,0},   //=0
    {0,0,0,1},  //=1
    {0,0,1,0},  //=2
    {0,0,1,1},  //=3
    {0,1,0,0},  //=4
    {0,1,0,1},  //=5
    {0,1,1,0},  //=6
    {0,1,1,1},  //=7
    {1,0,0,0},  //=8
    {1,0,0,1}}; //=9
// Outputs an 8421 decimal digit on the output pins from
// base to base + 3 in big endian order.
void show(int base, int num) {
 for (int i = 0; i < 4; ++i) {
   if(segs_encoding[num][i] == 1) {
     digitalWrite(base + 3 - i , HIGH);
   } else {
     digitalWrite(base + 3 - i , LOW);
   }
  }
}
// Output a 2 digit decimal value.
void show_2digit_decimal(int num) {
// force value to displayable range because show() doesn't do any sanity
  if (num < 0)
    num = 0;
  if (num > 99)
    num = 99;
  // display it.
  show(0, num%10);
  show(8, num/10);
}
void loop() {
  static int i = 0;
  show_decimal(i);
  delay(1000);
// Increases the counter.
  ++i;
  if (i == 10)
    i = 0;
}

Let me know if you guys need pictures of my breadboard set up, thanks for any help you guys can provide.

You need to at the very least tell us which IO pins the second digit of the display is on. The language the board uses is basically standard c with a few additions for controlling the IO pins.

I'm assuming you mean the pins on the arduino board? The second one is connected to pins 8, 9, 10, 11.

The show() function already has support for specifying the first pin of the display. So if the second digit is starting at pin 8 and connected in the same order then it should be as simple as:
// Output a 2 digit decimal value.
void show_2digit_decimal(int num) {
  // force value to displayable range because show() doesn't do any sanity checks
  if (num < 0)
    num = 0;
  if (num > 99)
    num = 99;
  // display it.
  show(0, num%10);
  show(8, num/10); // int/int always rounds down to the nearest int
}

You will also have to add the appropriate pinMode(<pin>, OUTPUT); commands to the setup() function to make the pins outputs.
----- update
To get the temperature to display first get rid of these lines, they aren't doing anything useful
static int temp = DHT11.fahrenheit();
static int digit_0 = temp % 10;
static int digit_1 = temp - digit_0;
static int digit_2 = digit_1 / 10;

And then change the loop function to being
void loop() {
  show_2digit_decimal(DHT11.fahrenheit());
  delay(500);
}

Although unless the teacher is completely incompetent you should have been able to work that out yourself, it's not exactly rocket science. If unsure take a guess and try it first before asking. The logic is simple enough that you should be able to work it out. For syntax errors the compiler error messages will normally tell you exactly what's wrong.

I added that to my code, but I'm getting a compiling error. My new code looks like

I edited my new code into the question.

What error are you getting. "a compiler error" is totally useless. 2) what happened to the rest of the code? Your loop() function has vanished. What is the program supposed to do after it's done the setup? Arduino has a hidden top level which in c would be written as main(){setup();while(1) loop();}. You need a loop() function if you want anything to happen.

I brought back the loop function and that fixed the error. I'm trying to get the first digit of the temperature to display on 7 segment display and the second digit to display on the second 7 segment display. I know that the code in the loop function wont do that, I just have no idea what to change it too to make it do that.

See the update in the answer

Okay the first display is correct but second one isn't lighting up. I assume it has something to do with my wiring. Thanks for all the help!

There are many issues with this code:

The compiler says “error: ‘show_decimal’ was not declared in this
scope”. Indeed, you named the function show_2digit_decimal(), so
you should call it by that name.
The compiler also said: “warning: ‘output’ defined but not used”.
There is no valid reason to leave something defined that you do not
use. Just remove it.
You also have a function named sertup() that you defined but never
used. It looks like a typo. You should remove the function, and put
it's current contents inside setup().
You have the variables digit_0, digit_1 and digit_2 that serve
no useful purpose. Remove them as well.
You wrote, at top level: static int temp = DHT11.fahrenheit(); Don't
do this. This kind of initialization happens before setup(), i.e.
before you had a chance to attach() the sensor to its pins.
Your array segs_encoding is not a 7-segment encoding, it's just
the binary encoding of the numbers. You don't need it: the processor
already knows how to count in binary, and you can replace
segs_encoding[num][i] by num>>i&1. If you really have 7-segment
displays, you need 7 pins for each, unless you multiplex them. Search
this site for “7 segment” to see how to drive them.
The section
if(segs_encoding[num][i] == 1) { digitalWrite(base + 3 - i , HIGH); ...
can be simplified to
digitalWrite(base + 3 - i , segs_encoding[num][i]); or, considering
the previous point, to digitalWrite(base + 3 - i , num >> i & 1);
The test if (num < 0) num = 0; if (num > 99) num = 99; can be
written more succinctly by using the function Arduino provides for
that: num = constrain(num, 0, 99);
In loop(), you are only displaying a counter. You probably should
display the temperature instead.

All the previous comments lead to the following version of the code:
#include <dht11.h>

const int units_base_pin = 0;  // units on pins 0..3
const int tens_base_pin = 8;   // tens on pins 8..11

dht11 DHT11;

// Outputs a number in binary on the output pins from
// base to base + 3 in big endian order.
void show(int base, int num) {
    for (int i = 0; i < 4; ++i) {
        digitalWrite(base + 3 - i , num >> i & 1);
    }
}

// Output a 2 digit decimal value.
void show_2digit_decimal(int num) {
    // force value to displayable range because show() doesn't do any sanity
    num = constrain(num, 0, 99);
    // display it.
    show(units_base_pin, num%10);
    show(tens_base_pin, num/10);
}

void setup() {
    DHT11.attach(4);
    for (int i = 0; i < 4; ++i)
        pinMode(i, OUTPUT);
}

void loop() {
    show_2digit_decimal(DHT11.fahrenheit());
    delay(1000);
}


text:
Float to integer conversion for control program crashes arduino
I have a program which estimates battery capacity, range as well as runs different control loops on an arduino MEGA2560 to control an eBike. I was using floating points which gave me quite a slow sampling frequency (10Hz). I now changed this to use integers by multiplying everything by at least 1000 so I can still keep a 3 decimal accuracy. However, as soon as the Arduino leaves setup and starts running loop, it crashes and restarts. I have a doubt that this could be due to the fact that my program takes too much RAM. How could I solve this?
Here is my code:
    #include <EEPROM.h>
    #include <memorysaver.h>
    //#include <TFT_HX8357.h> // Hardware-specific library
    #include <URTouch.h>
    #include <URTouchCD.h>
    #include <memorysaver.h>
    #include <UTFT.h>

    //TFT_HX8357 myGLCD = TFT_HX8357();       // Invoke custom library#include <TFT_HX8357.h> // Hardware-specific library
    //
    //TFT_HX8357 myGLCD = TFT_HX8357();       // Invoke custom library

    UTFT myGLCD(ILI9481,38,39,40,41);
    URTouch myTouch(6, 5, 4, 3, 2);

    int  buttonst, horn=5, throttle=8, powermode=1, alarmsystem=1, xtouch, ytouch, k1=0, k2=0,modechange,ncycles, p=9, divider=12, addresstd=0, kpow[3]={0,0,0}, kcur[3]={25,0,0}, ksp[3]={0,0,0};
    long pushed, pushedt, timesp, timespm1, powtimesm, factor, powtimesp, start, elapsed, powtime, powresttime, shuntvoltage, batvoltage, current, power, consumah, capacstore, consumwh, consumbatper, consumbatrange, distance, distanceint, throttlein, throttleout, distancedisp, Totaldist, velocity, Totaldistcheck;
    long throttlesmooth, capaccheck, capacactual,consumahstore, errorpower[2], errorpoweri, errorpowerli, errorcuri, errorcurrent[2], errorpowerl[2], diff, errorspeed[2], errorisp, outspeed, outcurrentctl, outspeedctl, elapsedtot, errorsmooth[2];
    float internresistance=0.00112;

    long batteryspec[6][56]={{4200,4000,3940,3900,3876,3860,3852,3844,3826,3809,3795,3783,3765,3744,3728,3710,3692,3672,3650,3631,3613,3591,3573,3556,3532,3508,3488,3463,3439,3417,3399,3380,3366,3352,3332,3312,3291,3273,3253,3237,3217,3196,3176,3150,3123,3087,3051,2994,2929,2868,2796,2727,2650,5261,2502},//5A discharge 18650GA SPEC
      {1,2,15,47,85,133,186,244,309,383,447,506,554,612,681,735,793,852,921,1007,1081,1150,1236,1300,1358,1438,1518,1587,1667,1747,1822,1888,1955,2014,2072,2152,2232,2317,2389,2466,2524,2594,2658,2722,2786,2847,2925,2983,3063,3133,3186,3245,3293,3330,3357,3368},
      {4200,4020,3980,3945,3927,3914,3904,3890,3874,3860,3843,3821,3797,3776,3756,3734,3713,3695,3675,3652,3634,3614,3593,3569,3543,3522,3500,3480,3459,3441,3419,3398,3378,3360,3339,3321,3301,3278,3254,3230,3199,3164,3128,3085,3037,2990,2937,2878,2837,2795,2746,2693,2648,2598,2549,2496},
      {0,7,33,84,151,223,294,377,457,521,574,646,718,785,851,931,1011,1091,1171,1251,1323,1397,1469,1547,1632,1701,1778,1853,1928,1994,2088,2175,2258,2333,2413,2487,2562,2634,2706,2775,2842,2908,2697,3023,3074,3116,3159,3205,3234,3261,3287,3314,3333,3352,3365,3379},//3A discharge 18650GA SPEC
      {4200,4131,4094,4073,4054,4038,4028,4015,4003,3985,3965,3945,3921,3894,3870,3850,3830,3811,3795,3775,3759,3739,3716,3692,3674,3648,3623,3601,3578,3561,3542,3522,3502,3486,3467,3445,3423,3401,3374,3350,3324,3291,3253,3210,3168,3123,3075,3026,2964,2897,2838,2781,2715,2652,2585,2502},
      {0,0,36,84,154,223,289,356,420,489,553,620,686,761,838,908,985,1054,1134,1214,1283,1358,1438,1523,1584,1667,1755,1835,1920,2002,2085,2170,2255,2327,2402,2482,2567,2644,2724,2791,2850,2908,2964,3015,3058,3095,3132,3167,3207,3245,3271,3295,3320,3336,3354,3365}}; //1A discharge 18650GA SPEC

    long cyclicspec[2][44]={{0,894,7151,16090,26400,37500,50950,61680,74190,85360,96540,107260,118880,130950,142120,154640,168040,182350,194860,208270,219890,234200,246700,262800,276200,291400,303900,317300,3271500,341500,354000,364000,374500,383460,395080,405800,418300,431700,444000,455900,468800,481900,491600,499700},
      {3441,3435,3342,3292,3235,3178,3121,3078,3014,2957,2921,2892,2842,2792,2750,2721,2679,2643,2607,2564,2543,2507,2479,2436,2407,2379,2357,2336,2336,2336,2336,2336,2336,2321,2300,2279,2271,2243,2229,2214,2193,2179,2164,2157}};

    extern uint8_t BigFont[];
    extern uint8_t SevenSegNumFont[];

    void EEPROMWritelong(int address, long value)
          {
          //Decomposition from a long to 4 bytes by using bitshift.
          //One = Most significant -> Four = Least significant byte
          byte four = (value & 0xFF);
          byte three = ((value >> 8) & 0xFF);
          byte two = ((value >> 16) & 0xFF);
          byte one = ((value >> 24) & 0xFF);

          //Write the 4 bytes into the eeprom memory.
          EEPROM.write(address, four);
          EEPROM.write(address + 1, three);
          EEPROM.write(address + 2, two);
          EEPROM.write(address + 3, one);
          }

    long EEPROMReadlong(int address)
          {
          //Read the 4 bytes from the eeprom memory.
          long four = EEPROM.read(address);
          long three = EEPROM.read(address + 1);
          long two = EEPROM.read(address + 2);
          long one = EEPROM.read(address + 3);

          //Return the recomposed long by using bitshift.
          return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
          }

    long pidcurrent_control() {

  long dt, outcurrent=0, outpower=0;
     int i=0, descurrent, despower;
     i++;
     dt=millis()-powtime;
     powtime = millis();
     if (powermode==1) { //Furo default mode
      if (current>40000) {
        descurrent=40000;
        errorcurrent[1]=descurrent-current;
        if (i>=2) {
          //Integrate the error
        errorcuri+=errorcurrent[1]*dt;

        outcurrent=(kcur[0]*errorcurrent[1]+kcur[1]*errorcuri+kcur[2]*((errorcurrent[1]-errorcurrent[0])/dt));
        }
        errorcurrent[0]=errorcurrent[1];
        return outcurrent;
        }
        if (((batvoltage*current)/1000)>2000000) {
         despower=2000000;
          errorpower[1]=despower-batvoltage*current/1000;
          if (i>=2) {
        //Integrate the error
        errorpoweri+=errorpower[1]*dt;
        outpower=kpow[0]*errorpower[1]+kpow[1]*errorpoweri+kpow[2]*((errorpower[1]-errorpower[0])/dt);
        }
        errorpower[0]=errorpower[1];
        return outpower;
        }
        }
      else { //Eco mode
       despower=550000;
       errorpowerl[1]=despower-batvoltage*current/1000;
          if (i>=2) {
          //Integrate the error
          errorpowerli+=errorpowerl[1]*dt;
          outpower=kpow[0]*errorpowerl[1]+kpow[1]*errorpowerli+kpow[2]*((errorpowerl[1]-errorpowerl[0])/dt);
        }
        errorpowerl[0]=errorpowerl[1];
        return outpower;
        }
        }

    void cyclescaling() {
    int j=1;
     if (ncycles<=499000) {
     while ((ncycles<cyclicspec[0][j-1])||(ncycles>cyclicspec[0][j])){
               j++;
        }
        factor=(cyclicspec[1][j-1]+(ncycles-cyclicspec[0][j-1])*(cyclicspec[1][j]-cyclicspec[1][j-1])/(cyclicspec[0][j]-cyclicspec[0][j-1]))/cyclicspec[1][0];
    }
    else {
        factor=(cyclicspec[1][41]+(ncycles-cyclicspec[0][41])*(cyclicspec[1][42]-cyclicspec[1][41])/(cyclicspec[0][42]-cyclicspec[0][41]))/cyclicspec[1][0];
    }
    }

    long pidspeed_control() {
    int isp, dtsp;
    isp++;
    dtsp=millis()-powtimesp;
    powtimesp = millis();
    errorspeed[1]=46000-velocity;
    if (isp>=2) {
        errorisp+=errorspeed[1]*dtsp;
        outspeed=(ksp[0]*errorspeed[1]+ksp[1]*errorisp+ksp[2]*((errorspeed[1]-errorspeed[0])/dtsp));
        }
        errorspeed[0]=errorspeed[1];
        return outspeed;
    }

    void throttlesmoothing() {
     int i=0, dtsm;
     i++;
    long currentmap=map(throttlein,800,3600,0,40000);
     dtsm=millis()-powtimesm;
     powtimesm = millis();
     errorsmooth[1]=currentmap-current;
          if (i>=2) {
          //Integrate the error
          throttlesmooth=kcur[0]*errorsmooth[1];//+kcur[2]*((errorsmooth[1]-errorsmooth[0])/dtsm);
        }
        errorsmooth[0]=errorsmooth[1];
    }

    void SOC() {
      int currentref=current/p, compbat=batvoltage/14;
      int j=1,l=1;
      long stateofc1=0, stateofc2=0;

      if (currentref<=1000){
        while (((compbat)>batteryspec[0][j-1])||((compbat)<batteryspec[0][j])){
               j++;
        }
        capacactual=(batteryspec[1][55]-(batteryspec[1][j-1]+(compbat-batteryspec[0][j-1])*(batteryspec[1][j]-batteryspec[1][j-1])/(batteryspec[0][j]-batteryspec[0][j-1])))*p;
        Serial.println("\n");
        Serial.println(current);
            Serial.println(batvoltage);
                Serial.println(batteryspec[1][j-1]);
      }

     if ((currentref>1000)&&(currentref<=3000)){
        while (((compbat)>batteryspec[0][j-1])||((compbat)<batteryspec[0][j])){
               j++;
        }
        stateofc1=(batteryspec[1][55]-(batteryspec[1][j-1]+(compbat-batteryspec[0][j-1])*(batteryspec[1][j]-batteryspec[1][j-1])/(batteryspec[0][j]-batteryspec[0][j-1])))*p;

         while (((compbat)>batteryspec[2][l-1])||((compbat)<batteryspec[2][l])){
               l++;
        }
        stateofc2=(batteryspec[3][55]-(batteryspec[3][l-1]+(compbat-batteryspec[2][l-1])*(batteryspec[3][l]-batteryspec[3][l-1])/(batteryspec[2][l]-batteryspec[2][l-1])))*p;
        capacactual=stateofc1+(currentref-1)*(stateofc2-stateofc1)/(3000-1000);
      }

       if ((currentref>3000)&&(currentref<=5000)){
        while (((compbat)>batteryspec[2][j-1])||((compbat)<batteryspec[2][j])){
               j++;
        }
    //    stateofc1=(batteryspec[3][55]-(batteryspec[3][j-1]+(compbat-batteryspec[2][j-1])*(batteryspec[3][j]-batteryspec[3][j-1])/(batteryspec[2][j]-batteryspec[2][j-1])))*p;

         while (((compbat)>batteryspec[2][l-1])||((compbat)<batteryspec[2][l])){
               l++;
        }
    //    stateofc2=(batteryspec[3][55]-(batteryspec[3][l-1]+(compbat-batteryspec[2][l-1])*(batteryspec[3][l]-batteryspec[3][l-1])/(batteryspec[2][l]-batteryspec[2][l-1])))*p;
        capacactual=(batteryspec[3][55]-(batteryspec[3][j-1]+(compbat-batteryspec[2][j-1])*(batteryspec[3][j]-batteryspec[3][j-1])/(batteryspec[2][j]-batteryspec[2][j-1])))*p+(currentref-1)*((batteryspec[5][55]-(batteryspec[5][l-1]+(compbat-batteryspec[4][l-1])*(batteryspec[5][l]-batteryspec[5][l-1])/(batteryspec[4][l]-batteryspec[4][l-1])))*p-(batteryspec[3][55]-(batteryspec[3][j-1]+(compbat-batteryspec[2][j-1])*(batteryspec[3][j]-batteryspec[3][j-1])/(batteryspec[2][j]-batteryspec[2][j-1])))*p)/(5000-3000);

      }

    if (currentref>5000) {
       while (((compbat)>batteryspec[4][j-1])||((compbat)<batteryspec[4][j])){
               j++;
        }
        capacactual=(batteryspec[5][55]-(batteryspec[5][j-1]+(compbat-batteryspec[4][j-1])*(batteryspec[5][j]-batteryspec[5][j-1])/(batteryspec[4][j]-batteryspec[4][j-1])))*p;
    }

    }

    void autonomy() {

      if (modechange==1) {
       consumah=0;
      }

        power=batvoltage*current/1000;
        SOC();

        if (capacactual!=capaccheck) {
          capaccheck=(capacactual+capaccheck)/2;
        }

      if (abs(capacactual-capacstore)>=100){
         EEPROMWritelong(8,roundf(capacactual));
         capacstore=capacactual;
      }

      consumah += 1000*current*elapsed/1000/3600;
      capaccheck -= 1000*current*elapsed/1000/3600;
      consumwh += 1000*current*elapsed/1000/3600*batvoltage;
      elapsedtot += elapsed;
      consumbatper = (capaccheck)/(batteryspec[1][55]*p)*100;
      if (distance==0) {
        switch (powermode) {
          case 1: consumbatrange=45*batvoltage*capaccheck/980;
          break;
          case 2: consumbatrange=35*batvoltage*capaccheck/550;
          break;
        }

      } else {
      consumbatrange = distance/consumah*(capaccheck);
      }
      myGLCD.printNumI(consumbatrange/1000, 2, 350,275);
      myGLCD.printNumI(power/1000, 2, 350,205);
      myGLCD.printNumI(current/1000, 1, 30,50);
      myGLCD.printNumI(ncycles/1000, 1, 30,50+16*2);
      myGLCD.printNumI(consumbatper,1,350,50);
      myGLCD.printNumI(batvoltage/1000,1,350,50+16*2);

      return 0;

    }

    void speedometer() {
    int sense=digitalRead(46);
    long sensecst=691150*3;//x1 000 000

    if (sense==LOW) {
       timesp=millis()-timespm1;
       timespm1 = millis();
       velocity=3600/1000*sensecst/(timesp);//m/h
       if (timesp>1000) {
           velocity=0;
       }
    } else {
      if ((millis()-timespm1)>2000) {
        velocity=0;
      }
    }
    }

  void setup() {
      // put your setup code here, to run once:
      Serial.begin(9600);
      start=millis();
     // pinMode(43, OUTPUT);//Speedo power
     // pinMode(46, INPUT);//Speedometer
      pinMode(A2, INPUT);//Throttle in
      pinMode(A7, INPUT);//Battery voltage
      pinMode(A4, INPUT);//Shunt
      pinMode(throttle, OUTPUT);
      pinMode(11, OUTPUT);
      pinMode(10, OUTPUT);
      pinMode(47, INPUT);
      analogWrite(10,255);
      analogWrite(11,255);

      myGLCD.InitLCD(LANDSCAPE);
      myTouch.InitTouch(LANDSCAPE);
      myGLCD.fillScr(0,0,0);
      myGLCD.setColor(VGA_WHITE);
      myGLCD.setBackColor(0,0,0);
      myGLCD.setFont(BigFont);
      myGLCD.print("FURO SYSTEMS",(480-16*12)/2,16);
      myGLCD.print("WELCOME",(480-16*7)/2,(320-16)/2);
      myGLCD.setDisplayPage(0);
      delay(2000);
      myGLCD.clrScr();
      myGLCD.print("FURO SYSTEMS",(480-16*12)/2,16);
      myGLCD.fillRoundRect((480-3*16-8)/2,320-16*2-4,(480-3*16-8)/2+3*16+6,228);
      myGLCD.print("ECO", (480-3*16)/2, 320-16*5);
      EEPROMWritelong(4,1000);
      ncycles=EEPROMReadlong(4);
      cyclescaling();

      for (int m=1; m<=5;m+=2) {
      for (int n=0; n<=55;n++) {
        batteryspec[m][n]*=factor;
        }
      }

      current=analogRead(A4);
      current=current/internresistance*5*1000/1023/75;

      batvoltage=analogRead(A7);
      batvoltage=batvoltage*5*1000*divider/1023;

      SOC();
      capaccheck=capacactual;
      capacstore=EEPROMReadlong(8);

      if (capacactual>capacstore) {
      ncycles+=1000;
      EEPROMWritelong(4,ncycles);
      EEPROMWritelong(8,roundf(capacactual));
      }

      if (capacactual<500) {
        powermode=2;
        myGLCD.fillRoundRect((480-4*16-8)/2,320-16*2-4,(480-4*16-8)/2+4*16+6,228);
        myGLCD.print("FURO", (480-4*16)/2, 320-16*5);
      }//3.21V per cell
      EEPROMReadlong(addresstd);
      Totaldist=EEPROMReadlong(addresstd);
      Totaldistcheck=Totaldist;
      digitalWrite(43,HIGH);
    }

    void loop() {
       throttlein=analogRead(A2);
       throttlein=throttlein*5*1000/1023;
       //throttlesmoothing();
       throttleout=throttlein/1000*255/5;
       analogWrite(8,throttleout);

       modechange=0;
        if (digitalRead(47)==LOW)
        {
          if (buttonst==1) {
          pushed = millis();
          }
          buttonst=0;

          if ((millis()-pushed)>=2000)
          {
           distancedisp=0;
          }
          }

         if (digitalRead(47)==HIGH) {
          if (buttonst==0) {
            modechange=1;
            pushedt=millis()-pushed;
            if (pushedt<1900){
           if (powermode==1)
          { powermode=2;
           myGLCD.clrScr();
           myGLCD.print("FURO SYSTEMS",(480-16*12)/2,16);
           myGLCD.fillRoundRect((480-4*16-8)/2,320-16*2-4,(480-4*16-8)/2+4*16+6,228);
           myGLCD.print("FURO", (480-4*16)/2, 320-16*5);
          }
          else
          {
            powermode=1;
            myGLCD.clrScr();
            myGLCD.print("FURO SYSTEMS",(480-16*12)/2,16);
            myGLCD.fillRoundRect((480-3*16-8)/2,320-16*2-4,(480-3*16-8)/2+3*16+6,228);
            myGLCD.print("ECO", (480-3*16)/2, 320-16*5);
          }
          }
          }
          buttonst=1;
         }

    batvoltage=analogRead(A7);
    batvoltage=batvoltage*5*divider*1000/1023;
    //speedometer();
    current=analogRead(A4);
    current=current/internresistance*5*1000/1023/75;
    elapsed = millis() - start;
    start = millis();

    if (modechange==1) {
       distance=0;
    }
    distanceint = (velocity/3600*elapsed/1000);//m
    distance += distanceint;
    distancedisp += distanceint;
    Totaldist += distanceint;

    if (abs(Totaldist-Totaldistcheck)>=100) { //later do it upon switch off
      EEPROMWritelong(addresstd,round(Totaldist));
      Totaldistcheck=Totaldist;
    }

    autonomy();

    if (velocity>45000) {
    outspeedctl=pidspeed_control();
    outcurrentctl=pidcurrent_control();
    long throttleout1=min(outspeedctl,outcurrentctl);
    throttleout=min(throttleout1,throttlesmooth);
    //analogWrite(throttle, map(throttleout, 0,5,0,255));
    } else{
    outcurrentctl=pidcurrent_control();
    throttleout=min(throttlesmooth,outcurrentctl);
    //analogWrite(throttle, map(throttleout, 0,5,0,255));
    }

    myGLCD.setFont(SevenSegNumFont);
    myGLCD.printNumI(velocity, (480-32*3)/2, (320-50)/2);
    myGLCD.setFont(BigFont);
    myGLCD.printNumF(distancedisp, 1, 30,175);
    myGLCD.printNumI(Totaldist, 30,175+2*16);

    }

emmm, you should maybe jut READ the battery value and not guest it...

Your program does nothing: save for the #includes, everything is inside a big comment that starts on line 10 with /*. Please edit the question and post your actual code.

That is a lot of code to look at. Not sure anyone will. So some helpful pointers instead. Break down your code (into many functions?).   Start by calling only a few bits of it, then add more until the problem occurs.  Also, at this complexity, it might be worth it to abandon the Arduino paradigm and use real Atmel debugging hardware / software so that you can single step through your code.

@EdgarBonet Sorry about that just edited it.

Actually just solved it, it was a mistake with the UTFT library! Using printnumI instead of printNumF

Please write your own anwser and set this question as resolved.

I actually solved this issue and noticed a few things for those interested: the printNumI() function was making the arduino crash as it was badly initiated with an extra argument. Once I solved this and replaced all my printNumF with printNumI I noticed a significant increase in sample rate of about 3-4ms per line changed. In addition, going from float to int calculation didn't change much as the TFT screen takes enormous amounts of computing power: takes me from 333Hz of sampling frequency to about 10Hz with the screen.

source: Stack Exchange

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

sort: votes


text:
Long run data wire
I need to connect the data of a LED strip (WS2812) to a pin but the strip is 10 meters away using AWG 22.
I use a 12V DC power supply.
Should I expect some misbehaviour, like the LED not getting the right color ?
If so, what could I do ?

What kind of LED strip? What gauge wire? How are you powering it? What signals does it use? etc, etc...

Is the power supply with the LED strip or the Arduino?

What kind of environment are you in?

Both, in a parallel circuit

It can't  be, unless you are bending the fabric of space-time.

The cables coming out my 12 dc transformer who is plug into 220V plug are divided into 2 branches, one for the arduino the other to the LED sttrip

If you are planning to power the LED strip from 12V then you can expect all the LEDs to explode. The WS2812 LEDs require 5V, not 12V.
If you have a large number of WS2812 in your strip, and you are powering them from the Arduino's 5V, then you can expect the Arduino to get extremely hot and go into thermal shutdown, or the voltage regulator to melt.
If you are in a noisy environment (electrically) then you can expect the data to get corrupted over that kind of distance.
What you should do:

Provide 5V to the LED strip from a power supply or regulator that can cope with the amount of current your LED strip needs.
Have another small Arduino next to the LED strip to drive the LEDs and communicate with that Arduino from your master Arduino through a suitable serial protocol that can cope with longer distance communications, or a wireless system.

LED strip has buck regulator, I could not have a 5V supply due to voltage drop so decided to have 12v and a LDO regulator. I unfortunatly cannot put any arduino near the LED strip, oonly small components

How small? You can get some pretty small Arduino boards...

Something as big as an ATtiny

I'm sure you could fit an ESP8266 in there if you tried...

Point of load regulation is a good idea, but you probably want a switching regulator not a linear one unless it is a short LED strip.  An ATtiny may be sufficient, and plenty of other processors including the ATmega come in small packages, the real question is where you LED patterns come from - program logic, an SPI flash, and sdcard, an external signal?  Of course you can also use a line driver and line receiver to accommodate a lengthy wire run between the MCU and the first LED.

I'm using 1 meter 60 Leds and planning on using internal memory of a controller with neopixel library. Line driver and receiver seems to be interesting could you  elaborate ?

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


text:
Testing for bad WS2812B?
I bought a 100 pack of WS2812S SMDs last year (product link) and wired most of them together for a string of Christmas lights for a tree. It was more work, but way cheaper (at the time) than buying a strip.
I had a few left over that I kept stored away until tonight when I decided to work up a little circuit to enhance my wife's Halloween costume. Problem is, I can't get them to light. Initially I had 3 soldered together, making sure that the voltage and data were going in the right direction, but when I plugged them into my Arduino Uno with a very basic NeoPixels based sketch, none would light. Figuring I had a bad one, I desoldered them all and tried, one by one, on a breadboard. Still no joy.
I tested and confirmed with a multimeter that I was getting the required voltage from one LED to another and reading voltage on the DIN/DOUT pins, but never any light. If I put the Christmas strand from last year on the same pins it works great.
Is there anyway to tell if these are just bad LEDs, or have I missed a step somewhere? I figured if the multimeter showed no voltage on one or more of the pads, that would be an obvious sign to trash it, but since all three show voltage, both when wired together and separately, I can't figure a reason they shouldn't light. Is there more I can do to test?

Have you tried using different libraries? My personal favorite is light_ws2812

No, but seeing as how the larger string of LEDs works, I very much doubt changing libraries will make a difference.

Decoupling capacitors in place?

Your product link does not work.  You might edit your question and fix this.  Assuming you ordered WS2812Ss on PCBs you might inspect the PCBs closely for signs of cold joints or corrosion.  I don't believe the "voltage direction" is important.  However, if you have ever connected  the WS2812Ss in revers polarity, there is no telling if they will ever work again.  These are not simply 3 LEDs but LEDs connected to a rather complex 3 channel PWM controller. Note, data direction is very important.  As well as specifying the number of WS2812Ss connected.

Also, timing the control signal to the WS2812Ss is super critical.  You might try swapping out Arduino controllers to make sure they are not the source of the problem.


text:
Using Arduino project migrated to breadboard with 12 MHz crystal instead of 16 MHz
I am moving my Arduino Uno project from Uno to Bread and as we know, this requires two 22 pf capacitors and 16 MHz on the breadboard (and the other things too like the power-but my question is about the crystal frequency so I'll focus on that).
If I replace the 16 MHz crystal with a 12 MHz crystal then the project will work as expected on a breadboard-is that correct?
It seems that the fuse setting to use 16 MHz crystal is the same as for the 12 MHz crystal for Arduino Uno-so I guess a change to the fuse setting or bootloader is not required. Am I missing anything?
I guess it's as simple as replacing a 16 MHz crystal by a 12 MHz crystal.

You will need to change your compile settings so that baud rates and delays are calculated for 12 MHz.  This used to require a unique entry in the boards file but it can possibly now also be supported as a menu choice, you may have to do some research on your own to find the current state of things, but I bet a web search will find you an example boards file entry for 12 MHz, too.

You can also program the ATmega using ISP, and thus not needing a bootloader at all.

@Gerben So how would that differ (versus using a bootloader) for setting up a 12 Mhz crystal?

@yabbadabba you don't need to burn a 12MHz version of the arduino bootloader. Your code still needs to set the correct F_CPU so delay etc. work correctly.

Some of the code running on the microcontroller needs to know the clock speed it's running at for correct timing. For this reason the macro F_CPU is set with this value. In the Arduino IDE this value is commonly defined in the boards.txt build.f_cpu property. If you're using a bootloader(which is used for uploading sketches over serial) it also needs to know the clock speed so that it can get the baud rate of the upload correct. The bootloader is not compiled in the Arduino IDE so it is not affected by your setting in boards.txt. You can recompile the bootloader with the correct clock speed setting and then install the compiled file on your microcontroller using an ISP.
There is a much more simple solution. All the hard work has already been done for you in MiniCore:
https://github.com/MCUdude/MiniCore
You only need to:

Install MiniCore following the instructions at https://github.com/MCUdude/MiniCore
Tools > Board > ATmega328
Tools > Variant > 328P / 328PA
Tools > Clock > 12 MHz external
Tools > Burn Bootloader

Yes it will work correctly IF you change the compile setting so that everything is in sync. This is because when you select an Arduino UNO from the IDE, it will process that as if your Arduino has 16Mhz. Here is a link for more information..

Im going to leave in the 16 MHz crystal upon to the very last moment Ive got everything on breadboard working (so the baud rate isnt affected when downloading a sketch). And for the compiler setting-I looked up the code-I think you mean change FCPU then it will define the real world time correctly from the frequency. Is that all that required for the changes?

at the last moment ill plug out the 16mhz crystal and replace it with the 12mhz


text:
ESP01 connected to Arduino can't read from UART while connected from external power source
I have an Arduino Uno connected to a NodeMCU ESP01 module, communicating via serial pins. The NodeMCU is powered from the Arduino's 3.3V pin. My idea is that the ESP01 receives MQTT messages, sends them to the Arduino via serial and wait for the Arduino to reply and then publish MQTT messages back.
If I power the Arduino from my computer's USB, everything works fine.
If I use an external power supply 12V/1A, the ESP01 can publish and receive "standard" MQTT messages (meaning, it does not send messages to the Arduino and does not expect a reply). It just receives and directly replies (no Arduino involved).
The problem occurs if the ESP needs to query the Arduino for a result.
The Arduino is able to read and write (I see the correct text in the console) to the serial port, but the NodeMCU ESP01 has problems publishing MQTT messages. Sometimes it does not publish anything (the ESP probably is unable to read what Arduino sends over serial), sometimes it publishes destroyed characters (random text).
It looks like the current needed by the ESP module is not high enough, but it does not make sense for me, since the external power supply should be able to provide more current than USB. Any ideas?
This is my schematic:

Code:
In my ESP01 I have the following MQTT onMessage listener, If the topic is a query for the Arduino (topic is validated by the handleQuery function), then the topic is sent by UART to the Arduino, which listens for specific strings in the loop function. When the Arduino receives a string, it does some logic and writes a reply back to the ESP via UART (Serial.print()).
After the ESP sends a message to the Arduino, it sets listeners for strings, that end with character %. If the reply from the Arduino is received, then it publishes an MQTT message with the result.
function onMessage(client, topic, message)
    if handleQuery(topic.."+"..message) then
        uart.write(0,topic.."+"..message)

        uart.on("data","%", function(data)
            if data=="quit%" then
                uart.on("data") -- unregister event
            end

            if data ~= "quit%" then
                client:publish(topic.."/response","REPLY:"..data,0,0)
            end
        end,0)
    else
        client:publish(topic.."/response","REPLY: Invalid query",0,0)
    end
end

The reply from the Arduino has the following message format:
 REPLY:<value>%
 quit%

This solution works if the Arduino is connected to my desktop computer's USB. It does not work if it is powered from an external power supply. It seems like the ESP is not able to read what the Arduino wrote to UART with Serial.println() if powered from an external power source.
I have no idea why, because power supply should be able to deliver more current.
Edit:
I use the following Arduino clone: eBay link
I tried to connect the ESP01 to the Arduino's 5V output with a voltage regulator (5V should deliver more current), and again, if the USB is connected, the ESP reads UART messages with no problem. If the Arduino is powered from an external power source, the ESP reads damaged characters. The only difference is that those damaged characters seems to be always the same. So perhaps some coding problems(?) or something like that.
So far it looks like a low current value is not a problem.
Edit 2
I removed from my code print() statement from the ESP/LUA code that I used for "debbuging". It printed to serial some messages for me. It seems that it cleaned traffic on Serial line a little bit.
Now I get most of the time correct characters, but the first character is missing, so instead of:
LOW% I get OW%
HIGH% I get IGH%
29.53% I get 9.53%
And from time to time I get String =]�quit%.
Perhaps some input buffer has a problem(?).

Please post a circuit diagram or schematic. Also include your code.

3.3v pin on the Uno is only rated for 50mA. You should provide a power supply that can provide at least 200mA.

@gre_gor but why it works when Arduino is powered from USB?

As @gre_gor mentioned, the Arduino UNO is incapable to provide more than 50mA The fact that it is working on most of USB-TTL is that those one can deliver more than 300mA.

You cannot electrically connect Arduino pins 0 and 1 to both the ESP8266 and the serial monitor at the same time.  You'll have to chose on or the other, or move the ESP8266 to other pins.

@ChrisStratton I dont want to use serial monitor regularly, only for "debuging". Then I see at serial monitor only what Arduino prints to ESP01, I do not enter any commands there.

The arduino outputs and should receive a 5v I/O signal.  The esp8266 uses 3.3V i/o signals.  The 3.3 v output from the esp8266 may not be adequate for this.  I also agree with others that the arduino 3.3v supply to the 8266 is not sufficient. The wifi seems to draw quite a bit of juice. In my latest project I used a esp8266 adapter that I found on amazon.  It converts the supply 5V to 3.3 as well as the i/o voltage to and from the 8266, as well as giving breadboard compatible pins.  Look for esp01 adapter.  Around $5 if I remember correctly.

Another thought....  on the esp8266 I had to change the baud rate to get it do get proper data.  After you can see esp8266 in the serial monitor at 115200, command to change baud is: AT+UART_DEF=9600,8,1,0,0

From a Arduino Pro Mini I can power a NodeMCU, a small OLED display, an external RTC DS3231, a DHT 22 and a LED. That works for days, no problems.

Yours is a comment, not an answer. Use the link "add a comment" under the question.

Can I just check when you plug your 3.3V ESP into a 12V power supply it stops working?  Is there a burning smell when you do this?  Are you using anything to drop the voltage to 3.3V?
You also say you are connecting the ESP to the Arduino's 5V supply.  Normally that's not a good idea either.
Also have you tied the ground of the Arduino to the ESP/12V PSU?  If the two devices don't share a common ground then they won't agree what 0V and so won't be able to talk to each other over serial.  Just run a wire from the Gnd on the Arduino to the Gnd on the ESP and they will jump into life.

Use a proper level shifter on the RX and TX lines. You probably are marginal as far as signal level.
The problem is not the voltage into the ESP8266. It is the level out of the TX of the ESP8266 not being high enough for the Uno CPU. This marginal voltage can cause messed up characters. Often we can get away with it at this level but it is really a marginal situation. It is not a reliable thing to do.
Specification for Vin high is 0.7xVcc. 0.7 x 5.0v = 3.5 volts !!!!
Using a 3.3 volt level signal will often work into 5 volt logic but not always. I had learned this the hard way. I designed a medium run product that used a 3.3v derived TX signal into the 5 volt logic RX input. Worked fine in 30 prototypes. But about 20% failures when running a production order. Different batch of chips resulted in different high trip point.
Just because the practice of using 3.3volt logic into 5 volt CPUs is common it is NOT guaranteed to work. Read the spec sheet! Do the math.

there is a voltage divider to esp8266 RX pin on fritzing in Question. it is enough

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

Uno will read 3.3 V as HIGH. always. official shields use it. for example Ethernet Shield for Wiznet chip and for SD card SPI MISO

@Juraj  It does NOT always work. It often works. It is a very poor practice that marginally works.

sorry, you are right. and the Ethernet shield has level conversion for MISO lines

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


text:
IRemote with PulseSensor
I have a problem with these two modules. I am trying to create a pulse sensor but also want to use a remote for some further functionality (menu system).
I have the code separated into two files, one for the main menu and the other for the pulse sensor. They work as expected individually but when i combine the code it only displays the pulse readings and doesnt allow me to use the main menu functionality.
ISR(TIMER2_COMPA_vect) {                        // triggered when Timer2 counts to 124
  cli();                                      // disable interrupts while we do this
  Signal = analogRead(pulsePin);              // read the Pulse Sensor
  sampleCounter += 2;                         // keep track of the time in mS with this variable
  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise

  //  find the peak and trough of the pulse wave
  if (Signal < thresh && N > (IBI / 5) * 3) { // avoid dichrotic noise by waiting 3/5 of last IBI
    if (Signal < T) {                       // T is the trough
      T = Signal;                         // keep track of lowest point in pulse wave
    }
  }

  if (Signal > thresh && Signal > P) {        // thresh condition helps avoid noise
    P = Signal;                             // P is the peak
  }                                        // keep track of highest point in pulse wave

  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT
  // signal surges up in value every time there is a pulse
  if (N > 250) {                                  // avoid high frequency noise
    if ( (Signal > thresh) && (Pulse == false) && (N > (IBI / 5) * 3) ) {
      Pulse = true;                               // set the Pulse flag when we think there is a pulse
      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS
      lastBeatTime = sampleCounter;               // keep track of time for next pulse

      if (secondBeat) {                      // if this is the second beat, if secondBeat == TRUE
        secondBeat = false;                  // clear secondBeat flag
        for (int i = 0; i <= 9; i++) {       // seed the running total to get a realisitic BPM at startup
          rate[i] = IBI;
        }
      }

      if (firstBeat) {                       // if it's the first time we found a beat, if firstBeat == TRUE
        firstBeat = false;                   // clear firstBeat flag
        secondBeat = true;                   // set the second beat flag
        sei();                               // enable interrupts again
        return;                              // IBI value is unreliable so discard it
      }

      // keep a running total of the last 10 IBI values
      word runningTotal = 0;                  // clear the runningTotal variable

      for (int i = 0; i <= 8; i++) {          // shift data in the rate array
        rate[i] = rate[i + 1];                // and drop the oldest IBI value
        runningTotal += rate[i];              // add up the 9 oldest IBI values
      }

      rate[9] = IBI;                          // add the latest IBI to the rate array
      runningTotal += rate[9];                // add the latest IBI to runningTotal
      runningTotal /= 10;                     // average the last 10 IBI values
      BPM = 60000 / runningTotal;             // how many beats can fit into a minute? that's BPM!
      QS = true;                              // set Quantified Self flag
  // QS FLAG IS NOT CLEARED INSIDE THIS ISR
    }
  }

  if (Signal < thresh && Pulse == true) {  // when the values are going down, the beat is over
    Pulse = false;                         // reset the Pulse flag so we can do it again
    amp = P - T;                           // get amplitude of the pulse wave
    thresh = amp / 2 + T;                  // set thresh at 50% of the amplitude
    P = thresh;                            // reset these for next time
    T = thresh;
  }

  if (N > 2500) {                          // if 2.5 seconds go by without a beat
    thresh = 512;                          // set thresh default
    P = 512;                               // set P default
    T = 512;                               // set T default
    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date
    firstBeat = true;                      // set these to avoid noise
    secondBeat = false;                    // when we get the heartbeat back
  }
  Temp = Thermistor(analogRead(tempPin));
  Sweat = analogRead(moisture);

  sei();                                   // enable interrupts when youre done!
}

I think the problem is with the actual header file. When the IRemote is initialised, it calls sei() which then turns on the global interrupts.
Is there a way to solve this issue? I was thinking about something along the lines of each interrupt should be unique and shouldnt be dependent on the other, and is there a way to tell the compiler about a hierarchy of interrupts.
Thanks in advance.

Showing only partial code is not helpful.

ISR should be as short as possible. Set flag and let the main program to handle it.
Global interrupt flag is handled automatically (on AVR platform), so you don't have to call cli().
Enabling interrupts in ISR handler might cause more problem than you can even imagine. Usual one is stack overflow caused by going deeper and deeper by another ISRs (or the same one, if it's longer than ISR period).


text:
Where to connect BLK and GRN pins of Openlog board on my Uno?
I have the following SD card reader on the left side from Sparkfun. In the tutorial they have it connected directly into an Arduino Mini, which has BLK and GRN pins> I would like to connect it to an Arduino UNO. Where do I connect these pins or can I ignore them? Thanks for your help.

This must be one of the weirdest connection diagrams ever. If you flipped one of the boards over, none of the wires would cross. This is by design, as you are supposed to physically plug one into the other.

If you read the page about the OpenLog board you can see (on the schematic link) what the pins mean:

I've added the labelling on the board in blue.  The GRN pin (DTR in the schematic) is actually an input, which resets the chip:

Thus:

GRN should be connected to RESET on your Uno, so that when you reset the Uno, you rest the OpenLog.
TXO (transmit out) on the OpenLog would be connected to serial input on the Uno (ie. digital pin D0 - labelled RX).
RXI (receive input) on the OpenLog would be connected to serial output on the Uno (ie. digital pin D1 - labelled TX).
You can see that GND and BLK are both ground pins, and thus should be connected to ground.
VCC (RAW on their schematic) is the voltage input to the 3.3V very-low-dropout voltage regulator MIC5205 on the OpenLog. This will accept input voltages in the range 3.3V to 12V. (The datasheet seems to suggest a maximum of 16V, but it might get rather hot if you did that). Connecting VCC to +5V on the Uno would be satisfactory.

It quite simple and stupid that they named the pins with those name. You simply connect:
BLK > ground
GRN > RESET
The weird pin abreviations can cause quite a bit of confusion.
Extra links for help.

Your link is to a guide for connecting an Arduino and an FTDI, which is not what this is.  The correct guide is at https://learn.sparkfun.com/tutorials/openlog-hookup-guide and while it is unclear if it will matter in practice the official recommendation (ie, from the people who designed the openlog) is different from yours.

Well, Its written at the bottom of my link what BLK and GRN means. Well I think the issue is resolved so yeah. You are welcome to write your own anwser.

"Its written at the bottom of my link what BLK and GRN means" again, your link is not about the board in question.  If you go by your link, GRN is an output but on the board this question is actually about, GRN is an input.


text:
Arduino motor shield
I'm making a soccer car with arduino. And I have this undocumented motor control shield. So I don't know how to program it. I've tried to code it as if it be an H bridge, but is not working. Someone know which are the pins that I have to use?
The plate is from DK Electronics, and says motor control shield for arduino.
Don't know why but the image can't be upload from my phone.
As I can't show more this way I have published on my Twitter account the image, if you can I'll be grateful.
Link: https://twitter.com/ricardovaras_99/status/789249497322889216
This is the code I used guided by some internet articles about the Arduino's original motors control shield.
 pinMode(8,OUTPUT);       //Channel A Brake Pin Initialize
 pinMode(9,OUTPUT);       //Channel B Brake Pin Initialize
 pinMode(12,OUTPUT);      //Channel A Direction Pin Initialize
 pinMode(13,OUTPUT);      //Channel B Direction Pin Initialize

No one will be able to assist you until we have more information. The photo may help, but more importantly is the documentation which begs the question:why did you buy a product with no documentation?

would it be this in any case?? http://www.oddwires.com/motor-shield-for-arduino/

You are going to have to try harder. A shield which you don't have a photo of, combined with code you haven't posted, and you are asking for help?

@canadiancyborg yes is exactly that one

@NickGammon Done, please, help me :'D

@ambitiose_sed_ineptum Done, the code is there, and an image I've posted on twitter because my phone, or my internet are sad or something.

That link doesn't lead me to an image. Get to a PC or something and get the image into this post. I have long since cancelled my Twitter account because they were driving me mad with spam. Even afterwards, so I had to make an automatic email rule to send all their stuff directly to the spam folder.

Judging by the fact that you agree it looks like this, a search reveals it is a knock-off of the Adafruit V1 motor shield.
Their page shows how to connect to it, and has example code and a library.
I don't really want to post a link-only answer, but the alternative would be to parrot the Adafruit page, which isn't really fair to them because this board wasn't even purchased from them.


text:
Utilizing 3G/4G connection as gps
Is it possible to get GPS data without using a GPS, but instead using the internet provided from a 3G or 4G connection to get GPS data?
Maybe if you used the HTML5 geolocation API somehow?
I have already used a GPS module together with a GSM modem, but i only used the GSM modem for SMS and not potential internet capabilities.
The beneftis from this , besides cost, would be a smaller program, intended for arduino nano, as TInyGPS and TinyGPS++ libraries are already big enough.
So my question really is twofold:
1. Is there any way to utilize the internet connection from GSM modems (besides the obvious SMS/call function)?
2. Is there a way to utilize the internet connection to get GPS data, without using an actual GPS module?

Step 1: read the manual for the modem.

Regarding the GPS library, check out NeoGPS.  It's faster and more robust than other libraries, and it can be configured to be really small, depending on how many GPS "fields" you really need (not all, I bet).  The examples are structured correctly, and can be modified without breaking them.

You cannot get GPS data without getting GPS data. That's like wanting to get milk from a cow without using a cow.
Some GSM modem modules also include a GPS chip. If yours does you can use that. If not then the closest you can get is:

Country (or maybe city) the IP address is registered in
Cell ID and location of the tower you are communicating with

Both of those are only very rough "somewhere within this square few miles" or "somewhere in this country" kind of data. Any more than that and you need GPS.
Mobile phones augment the GPS / Cell data with WiFi data by matching BSSIDs with an online database (within Google etc) to get rough location information.

Thanks! Do you know a reference where i can browse a list with available GSM modems that include GPS to find one i can use?


text:
Use interrupts with analog pins in arduino or another possible solution?
I have a very simple circuit, but my program is some what complicated.
Here is the circuit diagram:

Here is the code:
/*
  01 - GND -------- GND
  02 - +5V -------- 5V
  03 - V0  -------- Potentiometer Middle
  04 - Reset ------ 9
  05 - Read/Write - GND
  06 - Enable ----- 8
  07 - Data0 ------ NC
  08 - Data1 ------ NC
  09 - Data2 ------ NC
  10 - Data3 ------ NC
  11 - Data4 ------ 10
  12 - Data5 ------ 11
  13 - Data6 ------ 12
  14 - Data7 ------ 13
  15 - +LCD ------- 5V
  16 - -LCD ------- GND
*/

//include LCD library
#include <LiquidCrystal.h>

//Initialize an LCD object
/*Pins should be mentioned in this order:
  Reset
  Enable
  Data4
  Data5
  Data6
  Data7
*/
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int onTimePin = A0;
int onTime = 0;
int offTimePin = A1;
int offTime = 0;
int ledPin = 13;

void setup()
{

  pinMode(onTimePin, INPUT);
  pinMode(offTimePin, INPUT);

  pinMode(ledPin, OUTPUT);

  //Begin the LCD interface
  lcd.begin(16, 2);

  lcd.print("ON  TIME : ");
  lcd.setCursor(0, 2);
  lcd.print("OFF TIME : ");

}

void loop()
{
  onTime = map(analogRead(onTimePin), 0, 1023, 1, 3);
  lcd.setCursor(11, 0);
  lcd.print(onTime);

  offTime = map(analogRead(offTimePin), 0, 1023, 1, 9);
  lcd.setCursor(11, 1);
  lcd.print(offTime);

  digitalWrite(ledPin, HIGH);
  delay(onTime * 1000);

  digitalWrite(ledPin, LOW);
  delay(offTime * 1000);
}

The above code works. But there is a small problem:
When I turn the potentiometer wiper, there is a delay.
It's obvious because when the loop completes, the changed value of potentiometer is displayed. So, I decided to do the same thing using interrupts. But only digital pins have interrupts.
I would like to know the solution for using interrupts on analog input.

There's a delay because you're delaying.

I'd put the led blinking inside a timer(-interrupt). Or use the technique described in blink without delay

@IgnacioVazquez-Abrams I know that there is a delay and I get the expected output. In short I want to have an led blinking as per the values given by potentiometer.

Avoid delay.
Very simplistic alternative:
unsigned long lastLedToggleTime;
unsigned long currentLedToggleInterval;

void loop() {
  ...

  unsigned long now = millis();

  if ( (now - lastLedToggleTime) > currentLedToggleInterval) {
    lastLedToggleTime = now;
    // We need to toggle the LED now.
    if ( digitalRead( ledPin ) == LOW ) {
      // LED was LOW, so we set it HIGH and setup next toggling after onTime.
      digitalWrite(ledPin, HIGH);
      currentLedToggleInterval = (onTime * 1000);
    } else {
      // LED was HIGH, so we set it LOW and setup next toggling after offTime.
      digitalWrite(ledPin, LOW);
      currentLedToggleInterval = (offTime * 1000);
    }
  }
  ...
}

Notice that we're dealing with 32 bit unsigned integer values here, which is why this code will work even if/when millis() rolls over to 0. Specifically, not only will now - lastLedToggleTime always return a positive value (because it is cast into the unsigned data type), it will also return the correct value due to two's complement representation and modulo arithmetic base 2^32.
Example: Let's just look at an 8 bit value for simplicity:
Say, lastLedToggleTime was at the last tick of the 8 bit timer value, i.e. lastLedToggleTime == 255. In the next timer tick, now will overflow to 0, so next we have now - lastLedToggleTime = 0 - 255 = -255. In two's complement, this value would need (at least) 9 bits to represent (binary: 1 0000 0001), but because we only have 8 bits of storage, the sign bit (MSB) is just discarded resulting in 0000 0001 binary = 1. We can see that 1 is the correct value for the number of ticks to get from 255 to 0; it's exactly one tick.

Your solution will fail when millis() rolls over. Although this may not be a very serious issue, there is no reason to keep the bug, especially since it is very easy to avoid. See the Blink Without Delay Arduino tutorial for the proper way to write the code.

millis() "will overflow (go back to zero), after approximately 50 days."

This is why I say “this may not be a very serious issue”. But yet, there is no valid reason to show buggy code in an answer, when it is just so easy to avoid the bug. The pseudo-code in the page you link to is also correct.

@EdgarBonet You did notice that the OP has both variable and independent on and off times?

@EdgarBonet Since it seems to be really bugging you as it was, I edited your proposed solution in now.

Thank you. I have verified the code sample and it works fine.

@EdgarBonet It will fail with the Blink Without Delay Code as well. Once millis() rolls over the pin in the example given will never go HIGH again. It will stay low. You will never get a result again greater than interval once rolled over. You need the absolute value of the interval... abs(interval)

@FredHendricks, You don't understand the roll over. read https://arduino.stackexchange.com/questions/12587/how-can-i-handle-the-millis-rollover

@FredHendricks Notice that we're dealing with unsigned 32 bit integers here which means we implicitly have modulo arithmetic. That's why now - lastLedToggleTime will always return the correct value, even when lastLedToggleTime is greater than now because now overflowed back to 0.

You are looking for the bad solution for a simple problem. As Ignacio
Vazquez-Abrams puts it, the problem is you using delay(). The simplest
solution is to manage the timings with millis(). See the Blink
Without Delay Arduino
tutorial.


text:
Gnd pins at the power pin strip VS Gnd pin at the IO pin strip
I noticed there are two Gnd pins at the lower pin strip, and another on the upper strip.
Is there a difference in their purpose?

In short, all the UNO ground pins are the same.
They are just there to make your life easier. At the end of the day, GND is GND. There is no technichal difference. Just note that is is sometimes better if you share the 3 GND ports. Overloading a port might damage it. Check the datasheet for current limitations of the pins.

EDIT
The pins (literal pins of the IC) themselves are also different on the ATmega IC.

Your last statement is confusing. The ATmega has several ground pins, but they are all connected together on the PCB, just like all the GND header pins are connected together. At the end, all grounds are a single electrical node. Also, I doubt you can overload a GND header pin : you will very likely burn the regulator or the USB fuse before.

@EdgarBonet, well I prefer to specify it!

You linked to the wrong datasheet. The question is about the GND pins of the headers on the board, not about the pins of the microcontroller. This makes your answer misleading, as a naive reader may assume that the current sinked by the GND header pins goes into the GND MCU pins.

So, @EdgarBonet, considering I was indeed referring to the headers on the board, what's the truth here?

@Dor: As already stated, all the GND pins are connected together, so they are equivalent. My previous comment is just pointing out that the linked datasheet is irrelevant to your question.


text:
Where can I find the Arduino Mega core code?
I am looking to modify the receiving hardware serial buffer size for the Arduino Mega. To do so I need to redefine it in HardwareSerial.h in the core code. However, I can't seem to find a copy of the Arduino Mega core code. A search for HardwareSerial.h on my computer returns no results. I am using Windows 10.

And how / where on your computer did you search? Did you look inside the Arduino software itself?

Here https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.h

Arduino Mega is part of the Arduino AVR Boards core. The location of that core depends on whether you are using the core version included with the Arduino IDE or have updated the core version using Boards Manager(in which case there will be multiple copies of the core installed on your computer but only the updated version will be used). The easiest way to find it is:

Tools > Board > Arduino/Genuino Mega or Mega 2560
File > Examples > EEPROM > eeprom_clear
Sketch > Show Sketch Folder
Move up folder levels until you reach the avr folder.
If there is a version number folder in the avr folder then open that folder.
HardwareSerial.h and the rest of the core files are located in cores/arduino.

Remember that you will need to redo any changes to the core after any Arduino IDE and/or Arduino AVR Boards updates.


text:
Stepper motor with HCSR-04 sensor
I want to make a stepper motor increase and decrease speed working with a HCSR04 sensor. The idea is that if the sensors detects an object the stepper motor is going to decrease, and stop as close as possile to the object.
I have made some code, and it is sorta working..
My current code looks like this:
if (distance > 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(500); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(500); // Wait
}

if (distance > 20 && distance < 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(2000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(2000); // Wait
}

if (distance > 10 && distance < 20)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(10000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(10000); // Wait
}

if (distance > 1 && distance < 10)
{
  //digitalWrite(13,HIGH); // Output high
  //delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
}

But I thought it could be easier, So I made a function:
void velocity()
{
 digitalWrite(13,HIGH); // Output high
 delayMicroseconds(500); // Wait
 digitalWrite(13,LOW); // Output low
 delayMicroseconds(500); // Wait
}

Now my question is: Can I manipulate the delayMicroseconds to change if the distance changes? Is there a formula to do so?
Entire code:
int trigPin = 11;
int echoPin = 10;

void setup()
{
pinMode(trigPin, OUTPUT); //Sensor
pinMode(echoPin, INPUT); //Sensor
pinMode(6,OUTPUT); // Enable
pinMode(13,OUTPUT); // Step
pinMode(12,OUTPUT); // Dir
digitalWrite(6,LOW); // Set Enable low
digitalWrite(5,LOW); // Set Step low
Serial.begin(9600);
}

void loop()
{
//rotateleft();
//Serial.println("ik draai nu exact een rotatie linksom");
//delay(1000);
//rotateright();
//Serial.println("ik draai nu exact een rotatie rechtsom");
//delay(1000);
//velocity();

 //sensor
 long duration, distance;
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(5);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 Serial.print ("cm ");
 Serial.print (distance);

//eigen creatie

if (distance > 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(500); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(500); // Wait
}

if (distance > 20 && distance < 30)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(2000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(2000); // Wait
}

if (distance > 10 && distance < 20)
{
  digitalWrite(13,HIGH); // Output high
  delayMicroseconds(10000); // Wait
  digitalWrite(13,LOW); // Output low
  delayMicroseconds(10000); // Wait
}

if (distance > 1 && distance < 10)
{
  //digitalWrite(13,HIGH); // Output high
  //delayMicroseconds(1000); // Wait
  digitalWrite(13,LOW); // Output low
}

//Own functions
}

void velocity()
{
 digitalWrite(13,HIGH); // Output high
 delayMicroseconds(500); // Wait
 digitalWrite(13,LOW); // Output low
 delayMicroseconds(500); // Wait
}

void rotateleft()
{
 digitalWrite(12,HIGH); // Set Dir high
 for(int x = 0; x < 200; x++) // Loop 200 times
  {
    digitalWrite(13,HIGH); // Output high
    delayMicroseconds(1000); // Wait
    digitalWrite(13,LOW); // Output low
    delayMicroseconds(1000); // Wait
   }
  }
  void rotateright()
  {
   digitalWrite(12,LOW); // Set Dir high
   for(int x = 0; x < 200; x++) // Loop 200 times
   {
     digitalWrite(13,HIGH); // Output high
     delayMicroseconds(1000); // Wait
     digitalWrite(13,LOW); // Output low
     delayMicroseconds(1000); // Wait
   }
 }

You might look into using the constrain() function to establish a distance beyond which you will run at full speed, and then use the map() function to turn that into an inverse relationship between distance and delay.  Beware of possible hesitations while measuring, and the fact that ultrasonic sensors have a minimum distance, so make sure you don't go to full speed when something is closer than the minimum!

Assuming you have a distance variable containing the distance measured from your sonar sensor in cm. You can use that value to adjust the delay times in between your steps.
EDIT Modified code to increase speed when distance increases
int time = 0;
int timeWait = 1000; //interval in milliseconds between each distance reading
int maxDelay = 1000;

void velocity(int speed){
   int trim = 10;
   digitalWrite(13,HIGH); // Output high
   delayMicroseconds(maxDelay - speed*trim); // Wait
   digitalWrite(13,LOW); // Output low
   delayMicroseconds(maxDelay - speed*trim); // Wait
}

int readDistance(){
 //code to read distance
 return distance;
}

void setup(){
time = millis();
}

void loop(){
   if(millis()-time > timeWait){ //only read distance if 1000ms has elapsed since the last reading
     time = millis();
     int distance = readDistance(); //your distance reading code;

   }
   velocity(distance);
}`

EDIT 2
You'll also need something to handle upper and lower limits for delays (i.e. you don't want delayMicroseconds(0) or any negative numbers and  you don't want to include extraneous distance readings)

This looks to increase the delay (ie, move slower) longer distance, which seems to be the opposite of the goal.

I'll edit to subtract from the maximum delay which should increase speed when distance increases.


text:
Power Arduino Over 9V automatically after being disconnected from USB 5V
Am wondering if there is some way the Arduino can automatically power itself using through the 9v port in case the USB is disconnected, and afterwards if the USB is connected again it stop feeding from the 9v Input.

The anwser is somewhat.
If you connect a 9V battery to Vin, I'll "take over" the power wheter if the USB is connected or not. Note tought that some problems may occur when both are connected at the same time (personnal opinion). See this link for more info.
So in conclusion, if you have a USB, remove the 9V for power efficiency. Once you include the 9V though, it will take over control of the power on the ARDUINO.

Actually the opposite is the case. The USB takes over if the 9V is removed. If 9V is there it is used for power regardless of whether USB is there or not.

@Majenko, good point! I've modified the anwser!

I need the Arduino to power itself when the USB is removed, but not use the 9V if its connected. And this need to be done automatically and not manually.

@Majenko IF I connect Both USB and Power Jack, it's going to choose the power from the power jack over 5Volts. Yet will the serial be available?

@The_Little_Cousin Yes and yes.

@Majenko Powering both USB and 9V Jack won't burn the Arduino. You 100% Sure?

Positive. The Arduino is designed specifically to work like that.

Bro my life gonna be easier ^^ It's gonna open a new world to my Home-Automation project :D Like some post wrote it can burn your Arduino :| But it doesn't according to you :D

If you do home automation, connect use a 5V wallplug. Its more efficient then a 9V battery

@Majenko The Jack input not working, am using the adapter which came with the arduino and its not working at all. :| Its not turning on, nothing connected to it, its powering over USB and I upload a Led Blink sketch this works fine on USB but on the jack alone its not working.

there is one way you can make it.
you can use a temporary capacitor(with a voltage output near to 9v)(or a lipo battery) connected to arduino's voltage input pin and 9v battery connected to arduino with a transistor.
whatever program you are uploading to arduino, you can add a code that reads the serial port, and if serial port is not available then it opens the transistor's gate so as the capacitor gets discharged very quickly the 9v battery takes the job.when it gets the serial port again it closes the transistor's gate and arduino stops feeding upon battery and takes power from USB port.

A lipo connected to Vin is impossible. Vin is connected to the input of the V regulator which needs a voltage more then 7V to operate proprelly.


text:
Serial communication between NodeMCU and Arduino doesn't work when I try to use the DC jack or Vin
I have a unidirectional communication from NodeMCU (ESP8266) -> Arduino UNO. The communication works when I power both the devices to my computer. Note that since it is from NodeMCU to Arduino only, I don't use a voltage regulator. However, when I use a battery supply 9V and connect to DC jack or 9V battery, the serial communication doesn't work. I tried even with the voltage regulator.
It is mentioned that I use something between 9V-12V in the spec. Is it not working because 3.3V/5v from NodeMCU is not sufficient? How do I fix this problem?

Currently for the voltage regulator "high", I am supplying 5V from
Arduino. Should I provide another supply to pass 9v?
Does it power on if I provide 5V to DC jack or Vin?

Please rephrase you question into something understanteble

9V "transistor" (PP3) batteries are very weak. They barely provide enough current to power the Arduino, let alone a power hungry device like an ESP8266.
You're basically trying to tow a caravan with a skateboard.

What should I use? 9V is sufficient to power arduino for a simple blink program

AA batteries or Lithium ion.


text:
Single pin as input and output
Is there a way to set an Arduino pin as being both an input, and an output?
I was looking at tristates, I'm not sure if that is related, or if there is some other method.
Perhaps I can try switching states rapidly. on one pin. I'm just not familiar with how to do it, and I don't see anything about it on the Arduino site.
This is a function of other microcontrollers, such as PICs, but I'm not sure about AVRs and Arduino types.

The source code for the 1-Wire protocol is a great place to start when learning how to use a single pin for both input and output.
See also chap. 18. I/O-Ports in the ATmega328p datasheet.
Cheers!

Does it mater that the device isnt a 1-wire protocol item? Its NeoPixel Rings. such as https://www.adafruit.com/products/1643

@j0h: Why do you need to connect that as an input? The output from those is usually only useful for chaining them together.

A tri-state pin is not both an input and an output, rather each pin can be in 1 of 3 states (High, Low, High Impedance). These are typically used on a bus, where many similar devices are connected.
AFAIK the Arduino does not support tri-state, but it is possible to implement a bus. This was done by using open collector/drain devices with a resistor pull-up.
This was a common method of implementing computer busses (more than 40 years ago with RTL logic), but suffers from slow speed, and low fan-out, due to capacitance.
It is still used for low speed short busses such as I²C and 1-wire.
In practice all devices are set as Input. When a device wants to communicate it is configured as Output.

The three states are "High", "Low", and "High-Impedance"; a tri-state pin is always an output.

@IgnacioVazquez-Abrams True - brain fade on my part.

All the I/O pins of an AVR-based Arduino are four-state: not only do they support the three states you mention, they also have a fourth INPUT_PULLUP state, which is a weak pull to Vcc. You can connect a pin to an open-collector bus directly and then just switch between INPUT (i.e. HiZ, to either read or write 1) and OUTPUT LOW (to write 0).


text:
ADC port manipulation
I was modifying this ADC Touch implementation, namely switching analogRead and pinMode to what I thought would be port manipulation equivalents.
I get very different readings (better and more stable in my case).
So, what I think is equivalent is actually quite different. Can someone point the differences to me?
Original:
    pinMode(ADCChannel, INPUT_PULLUP);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    pinMode(ADCChannel, INPUT);
    _value += analogRead(ADCChannel);

Modified:
    DDRC &= ~(1 << ADCChannel);
    PORTC |= (1 << ADCChannel);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    DDRC &= ~(1 << ADCChannel);
    _value += analogRead(ADCChannel);

Your modified code doesn't disable the pullup on the pin.
PORTC &= ~_BV(ADCChannel);


text:
Pointer to Hardware Differences Documentation For Arduino Boards?
I hope this question isn't overly broad although it is more of a search for consolidated information.
BACKGROUND:
I am new to the Arduino universe and am drawn in by the open hardware concept. After years of doing electronics projects with PICs, I have tired of iterative hardware prototyping and DIY printed circuit construction for small one-off projects. The lure of buying off-the-shelf hardware and doing minimal wiring on protoboards / shields is a powerful concept that I welcome.
The availability of the hardware from multiple sources (and it seems multiple designers) does present a small problem I have discovered. There appear to be small but important differences between Arduino boards from multiple sources.
As an example, I have found that the hardware PWM isn't always the same from one Arduino Board design to another. I find that the arduino.cc pages (including the Forums) appear to indicate that hardware PWM runs at about 487 Hz. However, my testing shows that on the Arduino 101, two of the four hardware PWM outputs run at 487 Hz while the other two run at 975 Hz. I did not find such details when researching board choices and comparisons. I am assuming that this difference may also exist on other board designs although I have only Uno, 101, and Mega2560 boards to play with at the moment.
A second example is that for at least the Arduino Uno and Arduino 101 board I have, the DC power input jack is 5.5mm/2.1mm, a very common size. However, the Arduino Mega2560 I have (third party) uses a 5.5mm/2.5mm DC input jack -- a standard albeit less common size.
Another difference is the well known differences in (TTL) RS232 port interface chips used. At least these are generally made known and documented so that you can plan in advance for differences that may or may not affect you.
Finally, I have found that on the Arduino 101, plugging in or unplugging (or turning on or off) DC power at the DC input jack (or Vin pin) forces a reboot of the Curie module on the board. I think this is caused by the use of the power management chip and power switching circuitry on the board. The Mega2560 does not show this reboot behavior whenever DC power is changed. (This reboot happens even if the USB source remains connected at all times.)
These sorts of minor differences can affect the choice of board one makes for a given project -- especially, if you develop an application on one board and plan to deploy it on another. (Example: develop on a Mega2560 yet intend on deploying on a Uno later to save cost.)
QUESTIONS:
1) Has anyone come across a Website / page that details many of the minor design differences between Arduino boards?
[Edit] I should have used the word designs rather than boards in this question. I realize each vendor may have tweaks to a board but was more interested in detailed differences in the "official" design. Things like above would be interesting to know -- does the board reboot on application of DC input power? Are all PWMs running at the same default frequency, etc?
2) Are there any Web resources that might at least list other "oddities" with the different board choices? (i.e. PWMs at frequencies other than 487 Hz)?
Any pointers would be much appreciated.

You won't find an exhaustive list of differences between all "Arduino" boards from every vendor ever. 2) If minor software differences exist (e.g. a different default PWM frequency on different pins) then either their core or their board description for the IDE has a bug and this should be reported to the appropriate organization.

Ignacio, I should clarify the intent of question 1. I did not mean to find documentation from all vendors in one place. That would indeed be unreasonable. The question was meant to attempt to find documentation for the the different board designs i.e. Uno, Mega256, 101, Pro, Pro Mini, Micro, etc. I will edit the question to make the intent more clear.

You may find this helpful: PTD0001 Arduino Comparison Rev 0 - PDF - 245 KB.
Screenshot of above:
Credit: Payne Technologies Limited
That compares some models in a way you might find useful.

I have found that the hardware PWM isn't always the same from one Arduino Board design to another

The PWM frequencies can be changed over quite a wide range. I have a page about timers which describes a lot of their features.
According to the Arduino reference page about analogWrite:

The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz. Pins 3 and 11 on the Leonardo also run at 980 Hz.

By changing the hardware register you can change those frequencies. The frequency of 980 Hz is because of the compromise needed to get an approximate 1 ms interrupt for use by the millis() function:
16e6 / 64 / 256 = 976.5625 Hz

In other words the clock speed of 16 MHz is prescaled by 64 and then counted to 256, giving that frequency.
Note that this is almost 1 ms. The code behind millis() and micros() functions compensates for that so that you get a reasonably accurate result.
By changing the prescaler, and "count to" point you can get lots of other frequencies. However if you do that to Timer 0 on the Uno (and similar boards) then you will throw out the calculations for the millis() and micros() functions (you can compensate for that, of course).

This only partly answers your question, but hopefully will provide a nudge in a useful direction.

Nick, thanks for the pointer to that chart. That is exactly the type of reference I was looking for. It would be nice if other differences were documented (as well as other Arduino designs like the 101), but I knew the chances of finding a comprehensive comparison all in one place was pretty low.

If others know of similar charts out there, please do post additional answers with pointers. I will be building my own similar chart incorporating what I have learned from direct experimentation as well as any other sites that are pointed out. I sort of suspect that many other really helpful charts or comparisons are scattered about the 'net -- many buried deeply on vendors' Websites like the one Nick linked.


text:
Methods to prevent Accelerometer values changing from current spikes
I've connected an Arduino Uno to a MAX7219 IC, which is connected to only one standard 8x8 LED matrix, and an ADXL355 3-axis accelerometer. I use the matrix initially, and turn on all LEDs, while taking the "rest" values for the accelerometer to base all other calculations on. However, what happens is the current spike the LEDs create messes up the values - they become closer to 300, instead of the 230 they settle on when the spike is over. I've tried preventing this by adding up to a 5-second delay between the LEDs turning on and the rest values being measured. However, the problem still persists, though to a somewhat lesser extent.
Are there any methods to prevent this more effectively?

It seems to be a voltage drop issue. Potential solutions: add decoupling caps in your circuit, if not enough, use distinct power supply for MAX7219.

Adding a distinct power supply for the MAX7219, as suggested by @jfpoilpret, solved the issue.

I think you can just run the accelerometer from the 3.3V supply. The 3.3V should remain pretty stable, even if there is some voltage droop on the 5V.

@Gerben My particular accelerometer was in fact rated for 3.3V, so it was already connected there. The spike was still, IMO, unacceptable.

Weird that the noise or drop propagated to the 3.3V. You could also try adding some more capacitors. That is, unless you're okay with adding a second power-supply, of course.


text:
Simulation of IoT based systems in Software
Thank you for reading this.
Generally there are libraries for GSM and Ultrasound sensors for the software called Proteus and you can simulate them along with you MCU and the interfacing peripherals and simulate .
I have big problem at my hand , I want to simulate ESP8266 or any other relevant wifi module with my Arduino (Simulation Libraries for Arduino are available ) and get the data from sensor , all in software . Then , I want the wifi device (in software ) to show an ip address , so that I can log the data to an online cloud .
The software and module does not have to be specific , I want to know , If there are any professional software that let you simulate IoT based systems.
I'am new to IoT designing and I'am always comfortable with simulating everything.
If you have any other similar guide on how to design and simulate IoT systems , Let me know .
Have a great day

Possible duplicate of Can I program for Arduino without having a real board?

no mate . I already have a virtual arduino running in proteus . I wanted a much advanced featured soft. part

Sounds like the sort of thing you might use Matlab for, but equally, maybe you could just write some C-code on a PC.

There are tools to simulate Arduino, but it's not meant for anything beyond basic (i.e. simple circuit). Support is limited, you can't just simulate any and every sensor and shields (e.g. LAN, Wireless). Furthermore, ESP8266 is so cheap that hardly anybody has actual use-case to simulate them. I suggest you work on a real device =)
If you need to simulate data stream into your cloud or IoT platform, I suggest you just spin up a machine and run some code to generate data.

I don't know of any simulators, but you might be able to do it yourself.
What you could do is to add a hardware abstraction layer to your code.  When you are running on hardware this just passes the calls to the hardware, i.e. HAL_digitalRead(D0) calls digitalRead(D0).  When you want to simulate the hardware then you #ifdef the simulated code in and it calls {return DigitalPins[GetIndexFromPinName('D0')]; }
The theory is very simple but I don't think its an easy task.  I am surprised someone hasn't done it already, because debugging in Visual Studio or GDB in pure software would be much easier than doing it on the hardware.
I've never use Proteus, so I don't know if that will fit in with how that works at all.


text:
What is the best type of Arduino board for simple delivery robot?
I'm new to arduino, and I want to design a Simple Delivery Robot for Data Center, which has an arm to move items, and it follows line while moving.
I have no idea if there is a special arduino board for these types of robot or I can buy any arduino board.

This is presently unanswerable, as you cannot pick hardware (or at least not limited hardware like an Arduino) until you have determined how the robot will function.  In your case that seems to be mostly an issue of navigation and safety.

ANWSER
I would suggest you to use the Arduino UNO for all the shields that it has. Most Arduinos are so similar that it wont make a difference but the UNO has many shields to it, including a motor/servo shield which is going to be great for your project.
But at the end of the day, it's your project and you can pretty much use any of the boards listed below. They are just advantages and disadvantages of many popular board. Hope it helped you!
The summary has been removed for the sake of respecting Stack Exchanges rules.

This is a re-used answer, and copy-and-pasting answers (even your own) is inappropriate on stack exchange sites (see http://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions ) this is especially true in this case where the posting does not even really address any aspects of the question.  If this were the answer, the question would need to be closed as too broad, opinionated, or a duplicate of an existing question on which arduino to start with.

@ChrisStratton, is it better now?

Arduino UNO is the best arduino board for simple projects.
but if you want to add modules like LCD screen and some wireless sensors like bluetooth and RF and you want to make it with more motors then you should probably use Arduino Mega. It is better to use simple DC geared motors.


text:
getting error while trying to compile code for soil moisture sensor
I think the below logic should work but its throwing error
void setup() {
  Serial.begin(9600);
}

void loop() {
  int soil_moisture = analogRead(A0); // read from analog pin A3
//  int soil_moisture = pinMode(AO);
  Serial.print(“analog value: “);
  if (soil_moisture < 30) {
    Serial.println(“Dry soil”);
  }
  if ((soil_moisture > 300) && (soil_moisture < 700)) {
    Serial.println(“Humid soil”);
  }
  if ((soil_moisture > 700) && (soil_moisture < 950)) {
    Serial.println(“water”);
  }
}

error i get is
Arduino: 1.6.12 (Mac OS X), Board: "Arduino/Genuino Uno"

analog_soil_moisture_v02.ino:16: error: stray '\342' in program
   Serial.print(“analog value: “);
   ^
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:16: error: stray '\342' in program
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
     Serial.println(“Dry soil”);
     ^
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\235' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
     Serial.println(“Humid soil”);
     ^
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\234' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\235' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
     Serial.println(“water”);
     ^
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\234' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\235' in program
/Users/ciastro/Documents/Arduino/analog_soil_moisture_v01/analog_soil_moisture_v02.ino/analog_soil_moisture_v02.ino.ino: In function 'void loop()':
analog_soil_moisture_v02.ino:16: error: 'analog' was not declared in this scope
   Serial.print(“analog value: “);
                   ^
analog_soil_moisture_v02.ino:18: error: 'Dry' was not declared in this scope
     Serial.println(“Dry soil”);
                       ^
analog_soil_moisture_v02.ino:21: error: 'Humid' was not declared in this scope
     Serial.println(“Humid soil”);
                       ^
analog_soil_moisture_v02.ino:24: error: 'water' was not declared in this scope
     Serial.println(“water”);
                       ^
exit status 1
stray '\342' in program

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

It is because you declared NONE of your variables (int, floats) (except soil_moisture)
You must declare them. This is not Python where you can simply name a variable without declaring its type. Arduino language is based on C/C++.

Where did you get that Arduino language comes from JavaScript? I have known C and C++ for over 20 years, JavaScript for about 10 years and I don't see where Arduino language could be based on the latter.

My bad, its Java (not JavaScript). It's actually the function printf() from Java which translates to Serial.print(F())

printf is initially a standard C function, long before Java.

The actual error you are seeing is caused by the use of incorrect quotes in your program. You most likely copied and pasted the code from a website which has replaced the proper quotes with typeset-standard quotes:
    Serial.println(“Humid soil”);

should be:
    Serial.println("Humid soil");

Note the subtle difference in the quite shape. The first set are typesetter's open- and close-quote characters. The latter are just plain double-quotes (shift-2 on a UK keyboard).
There are other special characters in your program that need replacing with the standard ASCII equivalent, as well.


text:
Arduino & ESP8266
I connect my ESP to Arduino to my PC.
If I send AT commands from my serial monitor, I receive full response. I use 115200 and both NL & CR in my serial monitor.
ESP TX is connected to TX Arduino, same for RX.
The problem is when I try to send commands from my Arduino code. I don't receive any response. I use same 115200 both for serial and for ESP8266.
I user this code:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(0,1);

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

void loop()
{
    sendCommand("AT+GMR\r\n");
}

String sendCommand(String command, const int timeout, boolean debug)
{
    String come = "";

    while(esp8266.available())
    {
        char c = esp8266.read(); // read the next character.
        Serial.write(c);
        come += c;
    }
    Serial.println(come);
    return come;
}

I can't see what is wrong here and why that works with just the Serial Monitor.

Where is the godsbedamned website which is telling people to use SoftwareSerial on pins 1 and 0 so I can wipe it of the face of the earth?!?!

You connected Tx>Tx and Rx<Rx. You have no V dividers. HOW DOES IT WORK?!?!?!?! (me confused af) please post a picture of your circuit

@Majenko a search for "SoftwareSerial esp8266(0,1);" shows it literally everywhere.  I'm generally negative on the canonical question idea, but that and duplicate closes might be warranted.

@Dat Ha - Yes, TX to TX and RX to RX in certain cases can be correct. See my answer.

When you are using Arduino board just as USB --> RS232 converter then you have to, as you said, connect TX to TX and RX to RX. But when you want communication between microcontroler and ESP then you have to connect TX to RX and RX to TX. Here I explained that in details.

Make a choice:

Are you using pins 0 and 1 for communicating with the PC, or
Are you using pins 0 and 1 for communicating with the ESP8266?

You cannot do both.
Move the ESP8266 onto some other pins.

For esp8266 like in my code up

@Corneliu then your Arduino cannot communicate with the PC, which means you will need to remove the Serial.xxx lines and find some other way of telling if your program works.  That path is not recommended.  Rather, move your ESP8266 to different pins.

Ok. I move esp to pin 2 and 3; I set : ESP8266.begin(115200);  And in my loop i have :  ESP8266.println("AT\n");   And in my serial monitor i got : ƒÿ

Have you got it wired right? Your nominated TX pin through a voltage divider to ESP8266 RX, and ESP8266 TX to your nominated RX?

Are you sure the baudrates of both devices (and serial monitor) are set right? If one is wrong, it's very likely to receive weird characters