Timer for Control Motor using Limit Switch

There is no need to do a complex thing like using extra timers for this. You can use non-blocking code with the millis() function, like in the BlinkWithoutDelay example of the Arduino IDE (You should really try it and understand how it works). The millis() function returns the number of milliseconds since the Arduino has powered up and it will overflow after about 50 days (and with the code from the mentioned example this wouldn't be a problem either).

Basically you save a timestamp of the last event and check, if it is time to do something. For your case I would add a boolean, indicating, that the motor should be off and that the state of the switch doesn't matter anymore. Then (I assume that you want to disable the motor again by switching to OFF and ON again) you would have to reset this variable, when the switch goes to OFF state again. Something like this:

boolean state=true; // on by default
unsigned long timestamp=0;

void loop(){
  if(switch_on() && state){
    state=false;
    // switch off the motor here
    timestamp = millis();
  }
  if(switch_off()){
    state=true;
  }
  if(!state && millis()-timestamp > INTERVAL){
    //switch on the motor here
  }
}

Be sure to have a good code for checking the switch state, since most mechanical buttons need debounce code. In the above code I replaced this with simple functions to illustrate the timing functionality.


Dave X is absolutely right.

I never assigned the senRoll pointer to an object. Then when I tried to dereference it, it went to some random address. I guess there are very few memory protections, so rather than causing a seg fault it just caused erratic behavior.

Thanks for the help.


How to read sound sensor readings and light up sensor with water sensor if the readings is above threshold & when water is detected for 2 mins?

You set a timestamp when the sound first exceeds the threshold and only set the output high when millis() - firstDetect > 2*60*1000

//add to globals
bool wasOver;
unsigned long firstDetect;

//replace if else
if ((ssanalogread > threshold)){
   if(!wasOver){
       firstDetect = millis();
   }
   if(millis() - firstDetect > 2*60*1000){
      digitalWrite(led,HIGH); //turns led on if the sensor reads more than threshold
   } //end if
   wasOver = true;
} else {
   wasOver = false;
   digitalWrite(led,LOW);
}


Arduino development vs nRF51 development

First, there are various ports of the Arduino environment to the NRF51822, but I'll leave that aside for the moment and address using Nordic's codebase or the mbed one.

Generally speaking, one of these paths will put you more in the current "real world" of professional level embedded development, in which the ARM cortex parts play a leading role.  You will have conventional multiple source file projects tied together by more ordinary means such as a Makefile or explicit IDE configuration, rather than the rather oddball way the Arduino IDE has evolved to do things.  The basic lower level APIs you will be writing against will be much more conventional - ie, your code will start in main() rather than setup() and loop(), you will generate debug messages with printf() or similarly styled member function on mbed, rather than Arduino type print()/println() (though of course you can use printf() on an Arduino with some setup).  This tends to make it a lot easier to port or share code between this and other embedded systems, or even between an embedded system and a phone or desktop communicating with or simulating it.  Of course you can treat an Arduino as a plain ATmega and do this with that as well, up to the limits of the CPU and its memories.

People tend to think of the mbed option as being an online "toy" for certain boards, but you can generally use others just by setting it for a board using the same MCU in a similar way.  And in most cases you can download a zipfile of a project with a Makefile in it that will drive arm-gcc or a few other compiler choices.  The NRF51822 does come in varieties with different onboard storage sizes, and this can sometimes require care and attention to the linker script - in a few cases a project that fits in the online build (apparently with the Keil compilation engine as its backed) will not build in the downloaded GCC configuration unless you adjust the linker script to reduce the stack size, or perhaps change compiler optimization levels.

Countering reasons you might end up keeping the ATmega would be if you need some of its I/O peripherals or its 5v I/O capability.  For example, the NRF51822 has limited hardware PWM capability compared to an ATmega so that must generally be done in software.

If you are really at home with "The Arduino Way" switching to anything more traditional may take some adjustment of thinking and habits.  On the other had, if you look at the benefits of Arduino being the variety of works-out-of-the-box, easily modified examples you can use to explore the possibility of a project, but often find yourself annoyed by the legacy of its countless quirks and atypical approaches in the longer run, then you'll probably find the adaptation to using the NRF51822 directly to have been worthwhile.


The SPI wiring described in the SD card example sketch is for Uno. On Mega the SPI pins are 50 MISO, 51 MOSI and 52 CLK.


Any way to include the text of a file inside a sketch, to make it shorter and neater?

As suggested in comments, you can use #include statements to include texts of files into a sketch.  For example, suppose files c1.h,  c2.h,  c3.h,  c4.h, and  c5.h are in directory ~/sketchbook/tincludes, along with the file tincludes.ino, which is as follows:

#include <Streaming.h>
void setup() {
  const long int
#include "c1.h"
#include "c2.h"
#include "c3.h"
#include "c4.h"
#include "c5.h"
 etc=5   ;
  Serial.begin(115200);
  Serial << z1o <<  z1c <<  z2o <<  z2c <<  z3o <<  z3c <<  z4o <<  z4c <<  z5o <<  z5c;
}

Further, suppose c1.h ... c5.h each contain one line of code, as follows:

==> c1.h <==
  z1o=25829, z1c=9774,

==> c2.h <==
  z2o=7850, z2c=25585,

==> c3.h <==
  z3o=7103, z3c=17981,

==> c4.h <==
  z4o=30827, z4c=24511,

==> c5.h <==
  z5o=4167, z5c=10036,

Then the sketch will compile ok, and the sketch-lines with const long int through etc=5   ; will compile the same as if they were replaced by

const long int z1o=25829, z1c=9774, z2o=7850, z2c=25585, z3o=7103,
     z3c=17981, z4o=30827, z4c=24511, z5o=4167, z5c=10036, etc=5;


Is the Sparkfun RedBoard pre-loaded with a blink sketch?

Yes, the RedBoard is preloaded with the blink sketch (or at least the two that I've purchased have been).


How Do I Control the Onboard LEDs of My Arduino Nano 33 BLE Sense?

There are 3 LEDS on the Nano 33 BLE:

A power LED on pin 25 (yes, you can turn off the power LED programatically);
A built-in LED on pin 13;
An RGB LED with red on pin 22, green on pin 23, and blue on pin 24.

In the variant file, they are given names:
#define PIN_LED     (13u)
#define LED_BUILTIN PIN_LED
#define LEDR        (22u)
#define LEDG        (23u)
#define LEDB        (24u)
#define LED_PWR     (25u)

The power LED and the built-in LED are active-high, ie. you need to set their pin to HIGH to turn these LEDs on. The three LEDs in the RGB LED, however, are active-low.
This isn't well-documented as far as I know, and some example code snippets have it wrong too. A quick look at the schematic helps.
Also, as StarCat mentioned, you need two delay()s to make an LED blink.


Reading Arduino serial data in Octave on Mac

You most likely need the full canonical pathname for the port:

/dev/cu.usbmodem1421

On the Mac, as in Linux and other Unix derivatives, most devices, serial ports included, are special files in the /dev directory.


How to display variables on 0.96" OLED with u8glib library?

The U8glib user reference page mentions a couple of ways to print the value of a number using ASCII characters.

Eg, following the idea at the second mention of sprintf at above link:

char buf[9];
sprintf (buf, "%d", a);
u8g.drawStr(33, 33, buf);

Edit: The above follows the example at the link, but I've struck it out because in general snprintf is safer than sprintf.  See below.

enum {BufSize=9}; // If a is short use a smaller number, eg 5 or 6
char buf[BufSize];
snprintf (buf, BufSize, "%d", a);
u8g.drawStr(33, 33, buf);

The other way is via print.  (Search for U8GLIB::print in above link, and also see arduino.cc's Print docs).

Eg:

u8g.print(a);

To get a newline effect, you may need to have a variable keeping track of the current line number; add 1 to it to get next line's number, and use that as a position parameter in a drawStr call.


ESP8266: Client Server Based Home Automation System

I agree with most of 'Look Alterno's comment.  So here it is explained in more detail.

Each ESP runs a web server.
Each ESP will handle

GET /root/status
POST /root/change?device=x,state=y

When a client requests /root/status information on each relay managed by the device will be displayed.  For satellite ESPs this will mean displaying live data and for the central on it will mean displaying the last known state (it could also request an update at this time).  If you use an array then presenting this information will be quite simple.

When a client posts a change to a device then the satellite ESPs will change the relay state and the central ESP will forward the message onto the satellite.  It should probably also request a status update to check that the change has occurred.

If you steer clear of hardcoding things and use arrays rather than variable1, variable2, variable3 you should be able to make this expandable.  The biggest problem you will have is registering the satellites with the central device, but you could get around that for now by adding a configure page which had a HTML form that allowed you to enter the IP address of the central device and enter the name of the satellite and the name of the things connected to the relay.

Personally I wouldn't use a PC web server, yes it gives you more processing power, but I don't think you really need it for this, I was surprised how good they were.  If you have issues look at using an ESP32 instead of a ESP8266 for the central node.

I hope that helps


7-Segment Display with WS2312B and FastLED

First, for all the digits I'd use an 7 value array, indicating for every segment if it's ON or OFF. So for 0 your get byte digit0[] = {1,1,1,1,1,1,0}, where 1 indicates the segment is ON, and 0 indicates it's OFF. Your code then becomes:

void Print0(CRGB myColor){
  //Prints the digit 0:
  for(int i=0; i<7; i++){
    if( digit0[i] )
      leds[i] = CRGB (myColor);  //Switch the LED on
    else
      leds[i] = CRGB::Black; // Switch the LED off
  }
  FastLED.show();
}

The next step would be to create a two dimensional array containing which segments are on for which digits.

byte digits[10][7] = {
     {1,1,1,1,1,1,0} //0
    ,{0,1,1,0,0,0,0} //1
    ,{1,1,0,1,1,0,1} //2
    ,{1,1,1,1,0,0,1} //3
    ,{0,1,1,0,0,1,1} //4
    ,{1,0,1,1,0,1,1} //5
    ,{1,0,1,1,1,1,1} //6
    ,{1,1,1,0,0,0,0} //7
    ,{1,1,1,1,1,1,1} //8
    ,{1,1,1,1,0,1,1} //9
   }

Now you can generalize you Print0 function to accept any number:

void PrintNumber(byte number, CRGB myColor){
  if( number>9 )
    return;
  for(int i=0; i<7; i++){
    if( digit[number][i] )
      leds[i] = CRGB (myColor);  //Switch the LED on
    else
      leds[i] = CRGB::Black; // Switch the LED off
  }
  FastLED.show();
}

Call the new function in your loop; for example PrintNumber(3, CRGB:White);

If you want to put multiple 7-segment displays in series, you could add and offset argument to the PrintNumber function, and use leds[i+offset] instead. Then call the PrintNumber with offset 0 for the first digit/display, 7 for the second, 14 for the third, and so on.


The following saves a couple of program bytes (but no RAM) when now is a structure with a byte called DayofWeek:

 if ((byte)(now.DayofWeek+249)>250) ...
   -vs-
 if ((now.DayofWeek != 1 && now.DayofWeek != 7)) ...

It might save slightly more than that in your case, where now.dayOfTheWeek() appears to be a function reference.  This technique will work if function now.dayOfTheWeek() returns a byte, that is, an unsigned char.  The technique depends on value 7+249 overflowing to zero in byte arithmetic when truncated to a byte, because 7+249 is 0 modulo 256.

The cast to byte [or uint8_t] of now.DayofWeek+249 is needed because of int promotion as Edgar Bonet pointed out.


PubSubClient::setServer(const char * domain, uint16_t port) just saves the pointer, it doesn't copy the string (probably because it expects a static string literal).
(Source)
In your case, when ip goes out of scope, the pointer is no longer valid, so it won't work.

Just use the PubSubClient::setServer(IPAddress ip, uint16_t port) function instead.
(Source)

Always read the API documentation, most libraries have one, even though it can be hard to find. The ReadMe and GitHub Wiki pages are a good place to start.
If that's insufficient (not uncommon for open source projects), read the header files, which list all functions of the library.
If you still have doubts about what a function does, refer to the actual implementation files.


Why is function mentioned in global declaration?

Those are called function prototypes.  They mean "These functions exist somewhere else".  That "somewhere else" could be later on in the same file, or a different file entirely.

Usually these kind of things are provided by header (.h) files, or are automatically created (for functions in the INO file) by the IDE and hidden from you, so you never really see them. But if you're not using the IDE then you need to have them so your code (which is parsed linearly) knows that these functions exist before the parser comes across them.


Calculate time between 2 data of a sensor

Ok, yea...Please format this a little better (properly tabbed line spacing and such), and comments would go a long way to understanding this, because chances are people don't want to invest the time to decipher what's going on here without them. I'm not entirely sure what is going on here, but I'll just suggest what I would do in my understanding of the question, which is how to detect what the minimum and maximum value of the distance is and record the time at which each of these moments occurred.

I would have a float value to store the maximum and minimum distance as well as their times, and simply on every iteration of the loop check if the position was greater than the previous maximum distance or shorter than the previous minimum distance. If either of those are true, set the maximum/minimum distance to the current position and set the maximum/minimum distance time to the current time, using millis(). There's no reason I can see, if I'm understanding this correctly for an array to store all the data, it's just taking up memory space from what I see.

Hope this helps a bit, and, if I'm totally off base, again I'll emphasize the utility of comments in readability. Hope this helps and good luck.


Connecting to WiFi on ESP32 using credentials from SD card

you add the '\13' to the SSID and password string instead of the terminating zero, because ssid[i] = char(currbyte); runs for 13 too

use readBytesUntil()

  char ssid[33];
  int l = file.readBytesUntil('\n', ssid, sizeof(ssid));
  if (l > 0 && ssid[l-1] == '\r') {
    l--;
  }
  ssid[l] = 0;


DS18B20 setting resolution without addressing

You can use getAddress: bool DallasTemperature::getAddress(uint8_t* deviceAddress, uint8_t index)

If you want to set the resolution for all devices, you can just use void DallasTemperature::setResolution(uint8_t newResolution). (It will call getAddress for all indices.)


How to use Arduino Nano with Arduino Uno

try to connect uno and nano with I2C or serial, with I2C it connected to SCA/SDL pin (analog 4/5) or with serial it connected to tx rx. Make sure you use a pull up resistor. From the main site of arduino there's a tutorial in there but forgot to set up a pull up resistor.


The board and terminal are probably not using the same baud rate. Check the bottom right corner of the Arduino Serial Terminal and make sure it is set to 9600.

Serial Data

Serial communication works by sending the entire data stream one bit at a time. This is in contrast to the standard parallel port which sends one byte at a time. Both devices need to know at what speed the data is being sent. Furthermore, both devices need to be operating at the same speed. This is called the baud rate.

Baud Rate

Baud really just means pulses per second. In the context of serial communication, it means how many bits are transmitted per second. One of the most common values is 9600, but there are other common ones which are factors or multiples of 9600. It doesn't really matter, though, as long as both devices operate at the same speed.

If I'm sending you messages faster than you are getting them, you lose data. If I am sending you messages slower than you are receiving them, you get nonsense mixed in with what I sent you.

Data, Parity, Stop bits

If you look at the documentation for begin(), you'll see it can take two parameters:

Serial.begin(speed)
Serial.begin(speed, config)

Hopefully you understand speed now, it is the bits per second at which the Arduino will communicate.

The second parameter, config, lets you configure some other things about the serial data transmission. These are the Data, Parity, and Stop bits. You'll see on the page it has values like 5N1, 6N1 and SERIAL_8N1 (the default)

The first number represents how many data bits. The second character tells you what kind of parity bit there is. E for even parity, O for odd parity, or N for no parity. The third number tells you how many stop bits.

So really, with 8N1, we have 10 bits being sent for each 8 bits of "your" data. 1 start bit, 8 data bits, and 1 stop bit.

Anyway, both sides need to agree on this information as well as the speed. The Arduino Serial Terminal doesn't give you the option of changing these settings, but others do, so you'll need to be sure all of these configuration settings are the same.

More info on wiki: Asynchronous serial communication


You can load spread by saving the current value ORred 0x80 or 0x00.

When writing you write to the next memory location and when it wraps you take the other value to OR with.

The values in the eeprom will be

[{0x00|value},{0x00|value},{0x00|value},...,{0x00|value},{0x00|value},{0x00|value},{0x80|value},{0x80|value},{0x80|value},...,{0x80|value},{0x80|value}]

or

[{0x80|value},{0x80|value},{0x80|value},...,{0x80|value},{0x80|value},{0x80|value},{0x00|value},{0x00|value},{0x00|value},...,{0x00|value},{0x00|value}]

Then you read the first and last byte and if the upper bit is equal you take the last value.

If they are not equal you binary search until to the position changes, the most recent value will be the one right before the change.


How to create an array from serial.read?

If you are able to send the message as 16 chars, followed by a newline, then here is a test sketch that might work for you. Use the Serial Monitor to send the 1000100100110101 data. Please ensure you have the Serial Monitor set to send a Newline Only.

// Valid input data from serial is 16 chars followed by a newline.
// 1000100100110101
const byte bufferSize = 17;
char inputBuffer[bufferSize + 1];

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

void loop(){

  if(Serial.available() > 0){
    byte bytesRead = Serial.readBytesUntil('\n', inputBuffer, bufferSize);
    if(bytesRead == 16){
      for(byte i = 0; i < 16; i++){
        if(inputBuffer[i] == '1'){
          Serial.print("on ");
        }
        else{
          Serial.print("off ");
        }
      }
      Serial.println();
    }
    else{
      Serial.println("Invalid data length.");
    }
  }
}


If I have a group of Arduinos connected via I2C, can one Arduino cause the rest to freeze?

There are a number of places in the standard Wire library where the code goes into a tight loop waiting for an interrupt to occur. If that is missed for some reason, it will loop indefinitely.

By removing power from one of your devices you may be introducing electrical conditions that prevent the I2C messages from being transmitted properly (possibly just noise). Alternatively the device may parasitically power up from the SDA/SCL data and then behave in unpredictable ways. It is probably unwise to do this.

There is an alternative I2C master library at http://dsscircuits.com/articles/arduino-i2c-master-library which does not hang (I believe it times out instead).


Is checking an if statement every loop/while iteration inefficient?

Of course an if statement cost time, although very little. However, it changes (although once), so if you need to vary depending on the value, you have to use the if statement.

A while(true) also cost a little time (a little bit less), but less than 1 us, same as the if statement. You can do perfectly do an if statement within the while(true), but remember, the loop itself is behaving like a while(true) already.

However, I wouldn't concern at all about optimizing performance, unless:

You know beforehand you will need the fastest code possible
You have already performance issues

Always prefer readability/maintainability about performance.


I have found a solution for this problem in a blog.

Link: http://www.gammon.com.au/forum/?id=10892

I modified my master code and got my desired result.

Master code:

byte transferAndWait (const byte what)
{
  byte a = SPI.transfer (what);
  delayMicroseconds (2000);
  return a;
} // end of transferAndWait

void loop() {
  digitalWrite(SS,LOW);
  transferAndWait (10);
  received1 = transferAndWait (11);
  digitalWrite(SS,HIGH);
  Serial.println(received1);
}

The response will be "collected" next time through the loop. That's why we need to keep a dummy transferAndWait() function first and then the result of that transfer will be stored in received1 variable.


The essence of your problem is that the delay() function blocks
your program until the delay is over. This is only acceptable if the
program is doing one single things at a time. If you need to do multiple
things in parallel, like monitoring two moisture sensors, this approach
does not work.

Then, the first thing is to get read of delay() and instead use
millis() for managing time in a non blocking fashion. The essence of
this approach is to never wait. Instead, if it is time to do something
right now, you do it. If not, you just don't do it this time, but you
don't wait. This is nicely covered in the Blink without delay
Arduino tutorial. You should get familiar with this technique, as it is
essential for many Arduino projects.

Your problem is slightly more complex than blinking an LED though, as
the valve can be in two different states, and the action to perform
depends on that state. This is managed by a software construct called a
finite state machine. Essentially you have to remember the current
state and, depending on it, you decide what to do and what the next
state should be. Here is how you could do the timed watering with this
approach:

static enum { OFF, ON } stateValve1, stateValve2;
static uint32_t startedValve1, startedValve2;  // time when started

if (stateValve1 == OFF && analogRead(moisturePin1) <= 250) {
    digitalWrite(solenoidPin1, HIGH); //switch solenoid ON
    startedValve1 = millis();
    stateValve1 = ON;
} else if (stateValve1 == ON
        && millis() - startedValve1 >= WATERING_TIME) {
    digitalWrite(solenoidPin2, LOW); //switch solenoid OFF
    stateValve1 = OFF;
}

// and the same for valve 2.

For more in-depth coverage of the subject, I recommend you read the
Majenko's tutorial on finite state machines

At this point, the next step would be to throw in some modularization in
order to make the code less repetitive. I suggest making a class for
representing a “timed valve”. The valve has a turnOn() method that
turns it on, but does nothing if the valve is actually already on. The
class takes care of turning the valve off when the time has elapsed. But
since it cannot do that all by itself, you have to call an update()
method periodically to give it a chance to check whether it's time to go
off. Here is my implementation of that class:

const uint32_t WATERING_TIME = 100000;  // for example

class TimedValve
{
public:
    TimedValve(uint8_t pin) : valvePin(pin), state(OFF) {}
    void turnOn() {
        if (state == ON) return;  // do nothing if already ON
        digitalWrite(valvePin, HIGH);
        state = ON;
        timeStarted = millis();
    }
    void update() {
        if (state == ON && millis() - timeStarted >= WATERING_TIME) {
            digitalWrite(valvePin, LOW);
            state = OFF;
        }
    }
private:
    uint8_t valvePin;
    enum { OFF, ON } state;
    uint32_t timeStarted;
};

And you would use it like this:

const int solenoidPin1 = 1;
const int solenoidPin2 = 2;
const int moisturePin1 = A1;
const int moisturePin2 = A2;

void setup(){
    pinMode(solenoidPin1, OUTPUT);
    pinMode(solenoidPin2, OUTPUT);
}

void loop()
{
    static TimedValve valve1(solenoidPin1), valve2(solenoidPin2);

    // Turn the valves ON if needed.
    if (analogRead(moisturePin1) <= 250)
        valve1.turnOn();
    if (analogRead(moisturePin2) <= 250)
        valve2.turnOn();

    // Let them turn OFF if it's time.
    valve1.update();
    valve2.update();
}


If you add an optical sensor appropriate for the lamp (UV, IR, visible light?) and add a test line to your code, the Arduino would "know" if the light is on. Your second circuit could remain as presented, while the sensor would provide a status of the light.

If the light failed for an unknown reason, the code for your Arduino would not know the difference between that and a manually opened override switch.


How should you predict the battery size required for a project?

Yes, you need to know the average current draw over the period of an hour (or over a period that you then extrapolate to an hour).  That is the mAh (milliamps per hour) that your circuit draws.

It can be hard to calculate the actual current, though, since it is always changing depending on what is actually happening in your system at the time.  So I would suggest picking up a cheap current monitoring USB dongle from eBay / Amazon / Wherever (one with an LCD screen that gives mAh, such as this one and use that to get the total mAh of your system over an hour.

Multiply that mAh by 8 (the number of hours you want it to run for), and that will give you the minimum mAh for your battery. And then add some more as a safety margin, since the capacity of a battery is subject to many things (like temperature, age, etc), and the rated value is only a rough guide.

For instance, if you find your circuit uses on average 387mAh, then a battery of 3600mAh should be adequate.


LEDs Randomly smooth transitioning, accounting for black or how-to switch using HSV

Black will basically be when all the colours have reduced to 0. That can only happen when all three of C1, C2 and C3 are 1. So you basically need to ensure that never happens.

And that is simple enough to arrange, with a "try again" construct:

if ((((Col1 == 0) || (Col1 == 250)) && (((Col2 == 0) || (Col2 == 250)) && ((Col3 == 0) || (Col3 == 250))))) {

    // select a random number from 1 to 2 for the C1,C2,C3 array
    do {
        C1 = random(1, 3);
        C2 = random(1, 3);
        C3 = random(1, 3);
    } while ((C1 == 1) && (C2 == 1) && (C3 == 1));
}

Pick three numbers. If they are all 1 then you are destined towards black. So go back and pick three new random numbers. Keep trying until you get at least one result that isn't 1.


delete or free on object causes Arduino to hand or reboot

actions[i] == 0;

That statement has no useful effect. Perhaps you mean:

actions[i] = 0;


Serial doesent work when calling function from timer

Timer was to fast! When I decreased frequency everithing worked fine.


Firstly, solar panels inside a car is pretty pointless. Solar panels need to be in direct sunlight to be effective. Having them inside a car means they're not going to be in direct sunlight, so they're not going to be able to generate anywhere near enough power - unless they are massive, in which case where is the child going to sit? Yes, you could put them on the roof, but that would be silly.

The whole concept of solar panels for this project is completely wrong.

The car has a big battery and an in-built generator. Use them. There is absolutely no reason for you to have your own batteries as well. Yes, you could charge your own batteries from the car's battery, but that just introduces extra losses and wastefulness.

The only possible benefit of having your own batteries is it will safeguard the car's battery when the engine isn't running. It would then be impossible for your project to flatten the car's battery. But if you design your project properly that wouldn't be a problem anyway.

Some things you seem to be missing with your project:

The car has power you can use. It's throughout the car. No need to provide your own external power source.
The car has an "accessory" signal that is only turned on when the ignition is on. It's used by things like the radio etc so that when you turn the car's ignition off the radio turns off. No need for vibration sensors or anything to know if the car is running, it can tell you directly.
Cars generally have "seat occupied" sensors in them that couple with the seatbelts to know if a passenger hasn't got their seatbelt on and warn the driver (in most jurisdictions it's the responsibility of the driver to ensure all passengers have their seatbelts on).

If you really must charge batteries there are certain safety aspects you really must take into account. Your charge circuit must be able to manage the battery charging 100% safely. You have mentioned heat, and that is a very very important thing to manage. A decent battery manager chip will include an input for a thermistor. That is used as one of the multiple methods of charge termination (there's dv/dt (change in voltage over time), dT/dt (change in temperature over time), etc). It also serves as an over-heat safety cutout. Ensure that the charge circuit you use not only provides a thermistor input but also has the ability to cut off charging in the case of an overheat situation.

You also need to consider over-voltage. A car's 12V supply isn't 12V. It can get as high as 16V sometimes, and noise from the ignition can cause regular spikes as high as 70V or more. Automotive electronics have to be able to withstand those spikes, and that means your charge circuit has to be able to withstand those spikes.  Buffering the 12V through a proper 5V (cigarette lighter USB charger) regulator will remove that noise and make your circuit easier to work with.

So you need to think more carefully about just what it is you want to achieve and how that is going to fit into an automotive situation.


How can I connect an arduino to a raspberry pi via an HC 05 bluetooth module and transmit data?

I know this is old but to help out newcomers:
Here's a place you can begin https://create.arduino.cc/projecthub/millerman4487/view-serial-monitor-over-bluetooth-fbb0e5
The wiring depends on which arduino board you are using and the model of your HC-05 BT module. mine uses 4 pins VCC (5v) GND (ground) TX --> TX and RX --> RX
You should be able to google the wiring for your module, and connect to the raspberry pi after you install bluetooth on raspberry pi
sudo apt-get install bluetooth bluez blueman

sudo reboot

Navigate to new bluetooth interface in menu bar through

preferences
bluetooth

Add new device, turn arduino on with BT module plugged in and make sure your HC-05 module is blinking red, and you should see a pair connection named HC-05 on raspberry pi. Password is 1234


Why isn't the stack pointer changing in this simple sketch?

Another way the compiler can optimize is to compile small or single-use functions inline. What you expected would get wrapped inside a call and return sequence, may not.

Inserting __attribute__ ((noinline)) ahead of the function definition can suppress that optimization:

__attribute__ ((noinline)) void foo(int bar)
{
   // do something
}

suppresses the inlining for function foo(). Inlining has frustrated my investigations more than once, so I created this easier to remember macro. (The keyword is just __NOINLINE; the #else-clause is there so that, umm, "someone", doesn't unwittingly try to use the "__attribute..." declarator with another compiler that doesn't recognize it).

// Don't compile this function inline
//   '__NOINLINE void foo(void){ ... }'
#ifdef __GNUC__
#define __NOINLINE  __attribute__ ((noinline))
#else
#define NOINLINE error 'NOINLINE' not defined for this compiler
#endif


As you have already noticed, it may cause the 5V regulator to get hotter than would be normally considered reasonable.  However, how hot depends entirely on how much current your board is drawing (not including the 12V devices)- the more current you draw the hotter it will get.

Even at 12V it can get uncomfortably hot.

For running off voltages greater than about 9V I usually recommend using an external 5V switching regulator.  These can be easily and cheaply obtained under the name "UBEC" (Universal Battery Elimination Circuit) and are used extensively in the model aircraft arena.  They don't get hot, can handle large currents, and don't waste power like the on-board linear regulator does.

So you'd connect that to your 12.6V supply, then the 5V output of the UBEC (make sure you get a 5V one) would go straight to the 5V pin of the Arduino, and you wouldn't connect the barrel jack or Vin to anything.

You can also pick up cheap switching regulators on eBay - some are adjustable, so you'd want to make sure you adjust it to 5V first before connecting the Arduino, or if you can adjust it to around 7V then you could power the Arduino through the barrel jack (or Vin) with it and avoid too much heat from the on-board linear regulator.


Switch on the piezo emitter for a short time

Your myTimer1 in t = (millis() - myTimer1) / 1000; is not set


How to wait for next n bytes in I2C exchange?

First off; when talking about I2C bus, an important point to clarify: did you connect pullup resistors to both SDA and SCL lines (A4 and A5 respectively)? Without those, the I2C bus will not work properly.

Next, I2C protocol is quite low-level and a bit complex; but fortunately, the Wire library that comes with Arduino helps a lot and hides some of this complexity.

When using Wire library, there is a first point to keep in mind:

The device address is 7 bits only, the 8th bit is used to define the direction of data (read or write). You don't need to care about this direction bit as Wire deals with it for you.

In your situation, the device address is 0x6C, ie 1101100 in binary.

The commands you mentioned that you want to send to the device, 0xD8 0x30 0x0A and 0xD8 0x06 0xD9 already include the device address and the write bit (0):

0xD8 is 1101 1000 ie 1101100 plus the 0 direction bit at the end.

Please note that 0xD8 0x06 0xD9 is made of 2 commands actually:

0xD8 0x06 is a write command to tell the device hich register we want to read
0xD9 is just the device address followed by the read bit (1): this is the way the I2C master tells a slave that the former will now wait for data sent from the latter.

It is important to split this command in 2 because each will use a specific API from Wire library.

Writing to your device with the Wire library will be done this way:

// First command: start measurement
Wire.beginTransmission(0x6C);
Wire.write(0x30);
Wire.write(0x0A);
Wire.endTransmission();

// Second command: tell the device what register we want to read
Wire.beginTransmission(0x6C);
Wire.write(0x0A);
Wire.endTransmission();

Then you can start reading from your device with a different API:

Wire.requestFrom(0x6C, 3);
byte b1 = Wire.read();
byte b2 = Wire.read();
byte b3 = Wire.read();
// Now rebuild value from the 3 bytes just read...

Note that Wire.requestFrom(0x6C, 3); will send the 0xD9 that is calculated from the device address 0x6C and the read bit. SO you don't have (and you should not) send 0xD9 yourself, Wire doesit for you.

Please note that I use Wire.endTransmission() without the stop argument. Not sure if this is mandatory, but it worked fine on my I2C experiments.


You're not using strtok_r properly.  You have to treat the first call to strtok_r differently to all subsequent calls, and I don't know what you're trying to do with the &p parameter - that could never work since you're breaking the source pointer with that.

According to the manual page:

  The strtok_r() function is a reentrant version strtok().  The saveptr argument is a pointer to a char * variable that is used internally by strtok_r() in order to maintain context between successive calls that parse the same string.

  On  the  first  call to strtok_r(), str should point to the string to be parsed, and the value of saveptr is ignored.  In subsequent calls, str should be NULL, and saveptr should be unchanged since the previous call.

Unless you're doing concurrent tokenising of multiple strings there is no reason to use the reentrant version of strtok.  Instead you should just go:

char *p = I2CinBuffer; // The data to be parsed e.g. 6,100
int count = 0;

char *str = strtok(p, ",");
while (str != NULL)    // seperate at each "," delimiter
{
    inParse[count] = str;      // Add chunk to array
    count++;
    str = strtok(NULL, ",");
}

Note how the first call, outside the while loop, passes the string to parse.  All subsequent calls (inside the while loop) pass NULL as the string to parse so it continues from the last point in the string rather than starting the string afresh every time from the start (with a broken string since strtok() is a destructive function).

  A sequence of calls to strtok() that operate on the same string maintains a pointer that determines the point from which to start searching for the  next token.   The  first  call  to strtok() sets this pointer to point to the first byte of the string.  The start of the next token is determined by scanning forward for the next nondelimiter byte in str.  If such a byte is found, it is taken as the start of the next token.  If no  such  byte  is  found,  then there are no more tokens, and strtok() returns NULL.  (A string that is empty or that contains only delimiters will thus cause strtok() to return NULL on the first call.)

It is considered destructive because:

  The end of each token is found by scanning forward until either the next delimiter byte is found or until the terminating null  byte  ('\0')  is  encountered.   If  a  delimiter byte is found, it is overwritten with a null byte to terminate the current token, and strtok() saves a pointer to the following byte; that pointer will be used as the starting point when searching for the next token.  In this case, strtok() returns a pointer to the  start  of  the found token.

So in other words, your string that started out as:

foo,bar,baz\0

ends up, after tokenizing, as:

foo\0bar\0baz\0

So after the first tokenizing, if you try and pass the string again as the first parameter, instead of "foo,bar,baz", it actually only sees "foo" since the string now ends after foo.

If you wanted to use the reentrant version you'd need to create a separate pointer variable for the save pointer and pass that as the third argument:

char *p = I2CinBuffer; // The data to be parsed e.g. 6,100
int count = 0;
char *saveptr;

char *str = strtok_r(p, ",", &saveptr);
while (str != NULL)    // seperate at each "," delimiter
{
    inParse[count] = str;      // Add chunk to array
    count++;
    str = strtok(NULL, ",", &saveptr);
}

Note that you still need to use the same "pass the string on the first call and pass NULL on all other calls" methodology since it is still destructive.


adafruit LSM9DS0 Library - ok with Uno but compile error with LinkitOne?

The Adafruit library for the LSM9DS0 is written to run on an 8-bit Arduino. The LinkitOne isn't - it's an ARM board.

Either get a different library that is written to work on ARM, write your own library to work on ARM, or don't use that combination of components.


How to change the usb name of Atmel 32u4?

The Arduino '32U4 bootloader, Caterina, can be found under hardware/arduino/bootloaders/caterina. It requires LUFA in order to build.

With the technical part aside, note that you are not allowed to use the USB IDs assigned to Arduino LLC with products you intend to distribute under another name. You will need to acquire your own vendor ID from the USB-IF if you want to do so.


Arduino Mega not receiving data from Neo-6M

Not all pins on the Mega support software serial, have a read below:

https://www.arduino.cc/en/Reference/SoftwareSerial

Pins 18 / 19 are actually hardware serial pins so should not need the use of software serial.

Edit, should have noted to use hardware pins 18 / 19 you would use the constructor Serial1.begin(9600)


object with multiple instances with internal data store separate for each instance

Your Output::SetStrobe() is wrong, it uses a static variable (_lasr_strobe_state) that is thus shared between all instances of OUTPUT, which is NOT what you want.

You have to change it into a non-static member of class Output instead:

class Output
{
private:
    int _pin;
    OUTPUT_STATE _last_state;
    // NEW member here!!!
    OUTPUT_STATE _last_strobe_state;
    unsigned long _cycle_duration;
        unsigned long _last_elapsed;

public:
    Output();     //constructor: set pin data store
    void Begin(int pin, OUTPUT_STATE state);//set hardware to output and defaul state
    void Set(OUTPUT_STATE state);            //toggle operability
    void SetStrobe(unsigned long duration);  //strobe operability
};

Then you initialize it in the constructor:

Output::Output():_last_strobe_state(STATE_OFF)
{

}

And you remove it (static declaration) from method SetProbe (the rest of the method does not change):

void Output::SetStrobe(unsigned long duration)
{
    unsigned long elapsed = millis() - _last_elapsed;
    if (elapsed >= duration)
    {
        if (_last_strobe_state == STATE_OFF)
        {
            digitalWrite(_pin, STATE_ON);
            _last_strobe_state = STATE_ON;
        }
        else
        {
            digitalWrite(_pin, STATE_OFF);
            _last_strobe_state = STATE_OFF;
        }
        _last_state = STATE_STROBE;
        _last_elapsed = millis();
    }
}


How to keep a 24 hour maximum and minimum temperature

You should also keep a timestamp of the last time you reset the min and max otherwise the arduino will keep thinking it's a new day:

//add to globals
unsigned long lastDay = 0;

and inside loop()

  if (timenow-lastday >= day){

      maxtemp=0;
      mintemp=999;
      lastDay = timenow;
  }


That's the way to do it.

You need to select the type of board first:

And then the port. You can have both devices connected at the time and select which one you want to program.

With Arduino you can do OTA (Over The Air uploads) to NodeMCU and other ESP8266 based systems.

If you want to run two instances of the IDE, to work with two different boards at the same time, use UECIDE.


Is there a color LCD display for an arduino?

There are actually several shields that have color screens on them. Many of the shields are just regular mini TFT displays, however there are also touch screen ones.

Here is one from Adafruit that includes a MicroSD holder and a Joystick.

Here is one from Radio Shack that features a 2.8 inch screen with touch capabilities

As far as screen size, many of the screens are only about an 1 inch across, however the biggest I have ever been able to find are 2.8 in.


decoded backtrace in your question is missing, one of the choices to see stack trace is https://github.com/littleyoda/EspStackTraceDecoder
i dont know exactly if this is your case or not, but calling esp_ble_gap_stop_scanning() before esp_bluedroid_deinit() possibly avoids your crash.


Adafruit TLC5947 breakout board is not working with my Arduino Uno

... the LED does not turn on when connected to channel 0 on the board. [...] Connecting the LED directly to the v+ line lights it up, but obviously isn't switchable.

From this I suspect that you have connected the LED between pin 0 and ground. The problem with doing this is that the TLC594x LED driver outputs are current sinks, and connect the output to ground when on. The LEDs must connect between V+ and the output as shown in the datasheet.


Only print when the button is pressed and not being pressed anymore

If you want to be simple, you can use this library. The code will be

#include <ezButton.h>

ezButton button(7);  // create Button object that attach to pin 7;

void setup() {
  Serial.begin(9600);
  button.setDebounceTime(100); // set debounce time to 100 milliseconds
}

void loop() {
  button.loop(); // MUST call the loop() function first

  if(button.isPressed())
    Serial.println("OnsetTime");

  if(button.isReleased())
    Serial.println("GetOffsetTime");
}

If you want to understand in depth, You can see the code and instruction in this tutorial


If you mean you want to power it directly from a GPIO pin from an Arduino: no, for two reasons:

It doesn't show the current needed, but it's likely more than 20 or 40 mA which is maximum for a GPIO pin. So you need to use a transistor, which can be used to turn on something with higher current, with the current of a GPIO pin. Search for 'Transistor as a switch' for more info.
Also, it's 12 V and the Arduino delivers 5 V.

What you need is a separate 12V adapter, with a current capability MORE than what that light needs. I cannot find the current (mA) in the link, so you might need to measure it (e.g. with a digital multimeter). If you don't have a digital multimeter, buy one, you need one anyway if you will do electronics. You can even buy a 3 euro one from China if you want (for now).


Auto acknowledge failed with nRF 24L01+ and Arduino

To achieve that you have to do the following -

if ( radio.available() ) { // make sure the read will succeed
radio.writeAckPayload( 1, buf, len ); // prep the ack payload
radio.read( &got_time, sizeof(unsigned long) ); // also shunts out ack payload
}

So your program finally becomes -

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
int msg[1] = {1};
int rec[1] = {5};
bool stat = true;
RF24 radio(9,10);
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};

void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(100);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  radio.enableDynamicPayloads();
  radio.stopListening();
  radio.openWritingPipe(pipe[0]);
  radio.setRetries(15,15);
 }
void loop()
{
if(stat)
{
    if(radio.write(msg,sizeof(msg)))
    {
      Serial.print( msg[0] );
      Serial.println("...tx success");
      if(radio.isAckPayloadAvailable())
      {
        radio.read(rec,sizeof(int));
        Serial.print("received ack payload is : ");
        Serial.println(rec[0]);
      }
      else
      {
        stat = false; //doing this completely shuts down the transmitter if an ack payload is not received !!
        Serial.println("status has become false so stop here....");
      }
      msg[0]+=3;;
    if(msg[0]>=100)
    {msg[0]=1;}
    }
 }
}

And the RX part becomes -

#include<SPI.h>
#include<nRF24L01.h>
#include<RF24.h>
const uint64_t pipe[1]= {0xF0F0F0F0E1LL};
RF24 radio(9,10);
int rec[1] = {2};
int red;
void setup()
{
  Serial.begin(57600);
  radio.begin();
  delay(100);
  radio.setAutoAck(true);
  radio.enableAckPayload();
  radio.enableDynamicPayloads();
  radio.openReadingPipe(1,pipe[0]);
  radio.startListening();
  radio.setRetries(15,15);
}
void loop()
{
  if ( radio.available() ) {
    radio.writeAckPayload( 1, rec, sizeof(int) );
    radio.read( &red,sizeof(red) );rec[0]+=2;
    Serial.print("integer got is : ");
    Serial.println(red);
}
}

Know more about it at the following pages -
https://shantamraj.wordpress.com/2014/07/19/exploring-the-auto-ack-feature-of-the-transceiver/
https://shantamraj.wordpress.com/2014/11/30/auto-ack-completely-fixed/


What happens when there's no space left on SD card?

Open-source is just great. Lets have a look at the source code for SD. Here is what happens on write of a block.

/**
 * Write data to an open file.
 *
 * \note Data is moved to the cache but may not be written to the
 * storage device until sync() is called.
 *
 * \param[in] buf Pointer to the location of the data to be written.
 *
 * \param[in] nbyte Number of bytes to write.
 *
 * \return For success write() returns the number of bytes written, always
 * \a nbyte.  If an error occurs, write() returns -1.  Possible errors
 * include write() is called before a file has been opened, write is called
 * for a read-only file, device is full, a corrupt file system or an I/O error.
 *
 */

The source code shows that blocks are allocated from the free list and if there are no more blocks the function will return an error.


afmotor saying "servo does not name a type"

You are creating Servo objects instead of AF_DCMotor objects. Change this:

Servo leftMotor;
Servo rightMotor;

to this:

AF_DCMotor leftMotor(1);   // Change these numbers to the correct motor numbers
AF_DCMotor rightMotor(2);  // you are using on the shield


First Arduino Project - Need Advice (powering WS2812B LEDs)

Powering the LED panels
Powering your panels will be your greatest challenge!
These LED panels are powered by a single +5V power input per panel and do not need a resistor in the power supply path (they actually need a very low resitance path). You do need a good quality +12V DC -> +5V DC power supply (or multiple, as explained below).
Since 3 x 256 RGB LEDs require a large amount of power when they're all lighted at the same time (something like 60mA * 768 =~ 46A), the power supply should be able to accomodate that. It might be better to use three individual, smaller (~15A) power supplies. You could opt for power supplies smaller than 15A, but you should ensure that all LEDs will never light up at full intensity at the same time.
For supplying power from a 12V car battery, you could use high quality 12V DC to 5V DC buck converters (they're efficient). Use good quality cable with a diameter large enough for transporting the large currents necessary. If you need connections in the path of the power supply, make sure they are good quality as well. To reduce losses in long stretches of wire, you should place the buck converter(s) near the LED panels.
Connecting the data lines
The color and intensity of Individual LEDs is controlled via the data input coming from your Arduino and it only needs one input to control all 768 LEDs. The first panel's "data out" should be connected to the next panel's "data in" and so on, like your drawing.
Software
I recommend you look up the FastLED library and some of its examples to get familiar with controlling large amounts of addressable RGB LEDs. There are many good examples and interesting projects out there.


Modbus RTU controller monitoring with arduino and RS485 module

To send series of bytes over Serial or any other Stream (Print) implementation use the "write buffer" method size_t write(const uint8_t *buffer, size_t size)

For the case in question:

byte request[] = {0, 0x03, 0, 0, 0, 0x01, 0x85, 0xDB};
RS485Serial.write(request, sizeof(request));

If someone is curios about the Modbus RTU request bytes. They are:

station address
function - 0x03 Read Multiple Holding Registers
register address - 2 bytes
number of registers to read - 2 bytes
checksum - 2 bytes

The response:

station address return
function or error code
data length
data - length bytes
checksum - 2 bytes


Remove a sudden pulse on pin d3 of nodemcu when powering it up

D3 is GPIO0, which is used as an active low input to signal the ESP8266 bootloader to expect programming after a reset.
Use a different pin.


AC meter By ADC timer interrupt from Nick Gammon

You can read two analog channels like this:

int first_reading = analogRead(A0);
int second_reading = analogRead(A1);

If this does not fit your purpose, then your question was not asked
properly: rewrite it and clearly state your requirements. Explain why
the simple solution does not work for you.

If this does work for you, then stop (for now) reading advanced
tutorials, like the one where you found your code, and focus on the very
basics: the Arduino examples in the 01.Basics section, then the
03.Analog section.


If you have any timers left, I would (regardless of the number of PWM signals and if you need different PWM frequencies) just dedicate a timer to do IRQs to manage them.

The frequency of the IRQs would then depend on how accurately you want to control the duty cycle, ref. also to the comment from Edgar Bonet .


Can we call GPRS HTTP request asynchronously in Arduino?

Sure there is. All you're doing is reading and writing serial data. All you have to do is learn how to do that without blocking.

Most code I see bandied around is of the form:

Send AT command
Delay for numerous seconds
Read and discard anything that might be there
Send another AT command
Delay for more seconds
Read and discard anything that might be there
... etc ...

That is completely the wrong way to do things.

Instead you should be using non-blocking reading to look for an actual OK response from the AT commands that you have sent and use that to progress through the different stages of a Finite State Machine.

Some reading resources from my blog:

Reading Serial on the Arduino
The Finite State Machine
The Evils of Arduino Strings
Splitting Up Text in C


The beginning of your code in the loop:

void loop()  {
  digitalWrite(ledPin,LOW); //remove this line here
  if (digitalRead(switchPin)==HIGH)
{
     digitalWrite(ledPin,HIGH);//DBG
     delay(500);
}
 if (digitalRead(switchPin)==LOW);
 {
      digitalWrite(ledPin,LOW);//DBG
       delay(200);
     }
}

Before your first if(digital read(switch pin) == HIGH)  you turn the LED off, and then you have a delay, which gives the blinking effect, remove that and it will not blink.


Arduino autorestarts when powered externally

https://www.arduino.cc/en/Main/ArduinoBoardUno

Majenko has a good lead,

12V is just within spec of the voltage regulator.

Though this may be different per manufacturer or different in your environment.

To battle overheating you can:

Create beter airflow
Add a heatsink
Draw less current

But you should try a 9V source, that can deliver enough current (not the 9V "block" batteries).

Also check if the system draws excessive current, maybe the circuit has a low resistance or power hungry part (on the 5V rail)

If nothing works, you could try and use another Arduino board, maybe the regulator is faulty/damaged.


How can I learn to use Generic ESP8266 boards Libraries in Arduino?

They publish a reference page for the included libraries at each release of the ESP8266 core for Arduino. The latest at this time is here:

http://esp8266.github.io/Arduino/versions/2.3.0/doc/libraries.html

You can adjust that URL for the release version you're using.

The libraries try to follow the API of the standard Arduino libraries and that documentation mostly focuses on the differences. So you will also find some documentation for these libraries in Arduino's library reference pages:

https://www.arduino.cc/en/Reference/Libraries

and the reference pages for the Arduino core API:

https://www.arduino.cc/en/Reference/HomePage

Of course the definitive (albeit less beginner friendly) reference will always be the source code. There are two ways to quickly determine the location of the source code for a library:

Option 1:

Select the appropriate board from the Tools > Board menu. The Arduino IDE may select the library to be used based on which board is selected.
File > Examples > {library name} > pick any example
Sketch > Show Sketch Folder. This will open the {library name}/examples/{example name} folder. The source files for the library will be found in the library root folder, src folder, or utilities folder.

Option 2:

File > Preferences > Show verbose output during: > compilation (check) > OK
Write or open a sketch that includes the library.
Sketch > Compile/Verify
Wait for the compilation to finish.
Examine the contents of the black console window at the bottom of the Arduino IDE window. The path to any library used by the sketch will be found in that output.


Is there a way to put multiple integers in a method?

Check your spelling Intensity instead of Intesity.

Consider using switch instead of if-then-else.

Define left, right and middle as [integer] constants somewhere (and probably something more descriptive like rightLED, leftLED and middleLED) because your code is looking for an int, instead you give it something undefined like left, right and middle (and all). I would consider using bitwise operators for identifying the LEDS, instead of a simple integer flag as this gives future flexibility in lighting up combinations without changing your code (the current function would be rewritten to accommodate this).


The state of this meter can be read in 3 ways:

Pulse, this is very easy to implement. But depending on the stability of the hardware u can miss pulses leading to inaccurate values. In this way u have to calculate the meter value yourself.
RS485, this is a communication bus not default on arduino. But given this link https://arduino-info.wikispaces.com/RS485-Modules i think it is doable but not easy. This will read the value from the meter.
M-Bus: There is special hardware needed to interact with it. This is the industry standard of doing it. It's not cheap. But u can link many meters together. This will read the value from the meter.

Depending on your time/knowledge/other requirements u have to make a chose what way your going to use.


For me brownout issue was solved by removing the esp32 from Arduino IDE board manager + removing files from disk and use install procedure "Using Arduino IDE with the development repository" - https://github.com/espressif/arduino-esp32/

I guess it will use newer version of arduino-esp32 that has some brownout protection due to CONFIG_REDUCE_PHY_TX_POWER being activated by default. Also you should probably learn how to decrease wifi power + deep sleep for longer battery usage.


There is a file (binary.h) with every possible permutation of number between 0 and 255 represented as binary in it. They're stored as C-preprocessor macros:

#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1
#define B10 2
#define B010 2
#define B0010 2
#define B00010 2
#define B000010 2
#define B0000010 2
#define B00000010 2
... etc ...

Quite why Arduino decided to do this is anyone's guess.  It makes, as you have seen, for non-portable code.

Personally, I never use (and would never recommend any one else should use) those macros, and instead use the GCC standard binary literal representation 0b.....


After correcting the syntax error (missing semicolon) I tried your code on my Teensy 3.0. The results look OK to me:

Start...
1250
2250
Finished
1000 milliseconds elapsed

Start...
2250
3250
Finished
1000 milliseconds elapsed

Start...
3250
4250
Finished
1000 milliseconds elapsed

Start...
4250
5250
Finished
1000 milliseconds elapsed

Start...
5250
6250
Finished
1000 milliseconds elapsed

Start...
6250
7250
Finished
1000 milliseconds elapsed

Start...
7250
8250
Finished
1000 milliseconds elapsed

Start...
8250
9250
Finished
1000 milliseconds elapsed

Since the code you posted doesn't compile, can you re-test please with your posted code, assuming you add in the semicolon, and put a space before "milliseconds elapsed".

Further down my test I see this:

Start...
153258
154258
Finished
1000 milliseconds elapsed

Start...
154259
155259
Finished
1000 milliseconds elapsed

Start...
155259
156259
Finished
1000 milliseconds elapsed

Now are you talking about the "creep" in the start time? That doesn't totally surprise me, because the rest of the code must take some time to execute.

I know this isn't an "answer" per se, but I can't post this much information into a comment.


Generate a ramp input with an Arduino Uno

A RC filter will create a slow slewrate.

simulate this circuit – Schematic created using CircuitLab

The circuit creates this signal:

A slow rising signal and a fast falling signal can be created with an extra transistor (the signal will be inverted).

simulate this circuit

For a linear rising and falling edge, a resistor network with a few digital pins is a simple solution. I think it can be created with an opamp circuit as well, but there are also special chips called "slew rate limiter".


MicroSD interfering with ISP programming

Because the SD card is an SPI device it shares the same pins as the ISP interface. The only way to not have the SD card interfere with the ISP is to not have the SD card connected.

As you have seen, that can be achieved by removing the card.

It can also be achieved by adding a tri-state buffer between the MCU and the card so the MCU only connects the card to the SPI bus when it is ready to use it - under default operation the card is disconnected.


How to add hysteresis to threshold values?

Adding hysteresis behavior to your code is not difficult. You just need to store the state you're in and make the thresholds for transitioning into another state dependent on that.

You can use an enum to store the state:

enum BatteryStates {
  Red, Orange, Green
};

Then, instead of defining and checking against one threshold value, define two thresholds for each transition, separated by so much that you don't observe the undesired flip-flopping behavior.

For example, when transitioning from Green to Orange you could do something like this:

if ((state == Green) && (battery < 690))
  state = Orange;

And the other direction would use a slightly higher threshold

if ((state == Orange) && (battery > 700))
  state = Green;

so that small fluctuations of the voltage do not cause flip-flopping.

(Note that my code assumes

int battery = analogRead(BatteryVoltagePin);

The variable state should be declared and initialized like so:

enum BatteryStates state = Green;

Instead of an enum you could use a simple int and map each state to a number (e.g. red = 1, orange = 2, green = 3), but using enum makes the code easier to read and write. (In fact enum does use integer numbers.)

I might also use a switch statement instead of an if chain to implement the transitions, but that's a matter of taste.)


Arduino emits signal A (infrared) but another Arduino receives everything but A (IR-LED problem)

Sorry not enough rep to comment. Had to answer instead.

So if your schematic is correct then you just fried your LED. You need a series resistor between vcc and the LED.

If it's not accurate and you have the resistor in place, I'd check the LED anyway, it could be a dud. Apply voltage with a resistor and look at it with your cell/mobile phone digital camera, you should see it through the camera glow dimly.

If all is good then it might be the wavelength of the LED, which is 850nm. Most IR LED's I've used are 950nm, actually they all were.

Now I don't know what the specs of your receiver are but it might be out of its sensing (is that a word?) range, also it only has a 20° viewing angle, so check the alignment of transmitter and receiver.

I'm also confused by your statement that your getting signals that don't look like IR. This makes me wonder if your sensor is hooked up properly. It could be background IR or from another source. Look around the room or test elsewhere.


MQTT bridging with Arduino and ESP8266 - What software should I use?

MQTT is perfectly suited to this application. Here is an overview of a possible configuration. You should be able to find tutorials about each piece of the system.

On the Raspberry Pi:

Setup a Mosquitto server that can receive messages published by the ESP devices.
Write and run a MQTT client on the RPi that subscribes to the messages published by the ESP devices. This client would then store the data in some sort of permanent data store (database, flat files, whatever).
Write and run on the RPi a web app that reads and presents the data from the data store.

On the ESP devices:

Connect to the same wireless network as the RPi (or set up the RPi as an access point and have the devices connect to it)
Read data from the sensors and publish it to the MQTT server on the RPi.

If you want to push data to the ESP devices -- have them subscribe to certain messages (topics) on the MQTT server and then publish messages in those topics on the server.  Your web app could do this.

All of this can be done on an isolated network.


ESP8266 was developed for 'Serial over WiFi' as system-on-chip based on the Tensilica processor. The GPIO pins of Tensilica where used for different purposes of the system, like antena, flash memory connection, boot setup etc.

The more general use of the ep8266 as micro-controller with WiFi has evolved, but needs to accept the legacy of the original concept. Smart people even found a way how to share SPI with the flash memory of the system.

If you want to use the IO pins of the esp8266 (they are not called GPIO in datasheet), you must accept the required boot state and use only circuit,
sensor or actuator that doesn't disturb it and can handle it.

io0 LOW tels the esp8266 to boot into bootloader flashing mode. It is evaluated by ROM software in the boot process. Pull-up circuit is required to achieve normal boot. So if you want to attach something to this pin, it must accept this conditions. For button it is ideal.

If you want to use io 0 or io 2 as output, use logic that is normally HIGH and make sure it is not connected direct or indirect to ground at startup.


Actually he isn't really converting float to int. He never uses float since he don't need it. The datasheet of the DS18B20 shows at page 6, how the data is formatted:

The 4 highest bits just resemble the sign bit 11.
The first digit with full degrees is bit 4. Every bit below that has values below 1°C

So the data bytes 0b1111100001010000 will represent a temperature of -123°C and 0b1111100001011000 -122.5°C.

The author from the link then shifts this data 4 bits to the right, so that all bits representing values under 1 vanish. You can convert the received value per hand to float by also using this.

int16_t whole_degree = (result & 0x07FF) >> 4;
float temperature = whole_degree + 0.5*((data[0]&0x8)>>3) + 0.25*((data[0]&0x4)>>2) + 0.125*((data[0]&0x2)>>1) + 0.625*(data[0]&0x1);
if (data[1]&128) temperature*=-1;

As float does not have the same structure, as the data, we need to convert them. So I calculate first the number of whole degrees analog the your code. Then I add this up with the values of the lowest 4 bits. ((data[0]&0x8)>>3) and it's siblings will be 1, when the corresponding bit is set, and 0, if not.

So you get the full precision of the sensor (12 bits). Please note, that for this to work, you should not configure the sensor to less resolution. In that case you would have to ignore the corresponding lowest bits. But the sensor is in 12 bit mode at power up anyway and your code does not configure it otherwise.

Note: I'm unsure about the line result |=61440; in the original code. This sets the 4 highest bits of a 16 bit value to 1. I don't see, why this should be correct here, since a normal 16bit integer does only have 1 sign bit. In my understanding the original code would lead to false readings (way off), when reading temperatures below zero. I instead simply multiplied the resulting temperature with -1.

The whole code would look like this (I also added the statement for printing out the pure received data as binary, as I requested it in my comment. These statements are currently commented out):

#include <OneWire.h>
float dallas(int x,byte start){
    OneWire ds(x);
    byte i;
    byte data[2];
    int16_t result;
    float temperature;
    do{
        ds.reset();
        ds.write(0xCC);
        ds.write(0xBE);
        for (int i = 0; i < 2; i++) data[i] = ds.read();
        result=(data[1]<<8) |data[0];
        // Here you could print out the received bytes as binary, as requested in my comment:
        // Serial.println(result, BIN);
        int16_t whole_degree = (result & 0x07FF) >> 4; // cut out sign bits and shift
        temperature = whole_degree + 0.5*((data[0]&0x8)>>3) + 0.25*((data[0]&0x4)>>2) + 0.125*((data[0]&0x2)>>1) + 0.625*(data[0]&0x1);
        if (data[1]&128) temperature*=-1;
        ds.reset();
        ds.write(0xCC);
        ds.write(0x44, 1);
        if (start) delay(1000);
    } while (start--);
    return temperature;
}
void setup{
  //Adding Serial.begin(9600); for printing the received bytes here
  //Serial.begin(9600);
  dallas(A0,1);
}
void loop{
  float currentTemp = dallas(A0,0);
}


Make Sure \n is the last character in serial string

Since you are using all 8 bits of the serial data for your data there is nothing "in band" that you can use for a delimiter.

Instead you will have to think outside the box somewhat and create some form of "out of band" data that can signal the end of a packte.

One option (probably the simplest) would be to include the concept of time into your protocol.  If you go more than X milliseconds (X is to be determined by you) without receiving a byte then you are at the end of your packet. This has the disadvantage that it slows down your maximum packet rate, since each packet has to have a suitable delay between them.

Another option may be to use a serial break character between packets. This is a special event where the UART output is held low for at least 10 symbol lengths, which results in an framing error (the STOP bit is wrong) and a flag being set. It would mean though that you have to implement all the UART code yourself since the Arduino's UART code doesn't support breaks.

A third option, which also would require you to write your own UART code, or alter the Arduino UART code, would be to operate the UART in 9-bit mode. You then have 0-511 instead of 0-255, so you can send your 8-bit data as per normal (with the 9th bit set to 0) and any control and protocol characters with the 9th bit set, so between 256 and 511.

Finally, you could halve your overall transmission speed by sending the data as ASCII-encoded HEX digits. That would be two characters (0-9,A-F) for each byte sent, leaving all the other characters (including \n) available for you to use as you wish.


Unable to find arduino on device manager

It seems your computer recognize the serial port of the Arduino device, but doesn't know how to 'talk to it'.

In most USB to TTL devices (that are included in Arduino and ESP8266 boards) you need to install their driver (like CH341 driver) BEFORE you plug in your device.

Please try to find/identify the 'USB to Serial' chip you have on the board, and install its drivers.

Good Luck!


What is it you hope to achieve by "opening" the hex file or "converting it to binary"?

A hex file is a compiled sketch. It is intended to be installed into the Arduino Uno using avrdude.


You need to add an external 3.3V voltage regulator. You can get these quite cheap on eBay (etc) as a module - some even come in a breadboard friendly format.

Power it from the 5V from the Arduino, then power your MAX4466.

However, the MAX4466 can run at up to 5.5V, so I fail to see why you think you need 3.3V.


Buying Arduino Parts Different Manufacturers

Of course you can. In just the same way that you can buy a car from one manufacturer and bumper stickers from another.

That's the whole point of the Arduino platform - mix and match to make things -just like LEGO®.


Connecting Something Big to an Arduino - Sending more than 5V

Use a transistor, amplifier, opto-isolator or if you can drive a 5V relay use that relay to drive a higher voltage/current item item.


How can I stop SoftwareSerial from receiving data and re-enable it at some other point?

Call serial.end() to stop receiving.

Then call serial.begin(...) again when you want to start listening again.


Ultrasonic PING: multiple trig on single dig. pin

I was able to achieve the result using my suggested method in the question.
As BrettAM stated, the signals are wasted on the other 3 pins when checking 1.
This solution was suitable as a proof of concept


Connecting a time on/off circuit and my adafruit neopixel light strip

You cannot find a tutorial for controlling neopixel strips with a relay, because that just does not make any sense. You don't need a relay to control the strip.
The Neopixels consist not only of the LEDs themselves, but also of one LED driver chip per LED (WS2811 and it's siblings). These driver chips control the LEDs based on the data, that you send through the data pin. Actually one Neopixel LED consists of 3 LEDs inside a single package, one LED each for the colors red, green and blue (so that you can create all the other colors with a combination of them). The driver chip controlls the brightness of all three colors.
Thus you only need to connect your 5V power source to the strip (5V and ground) - Be sure to connect the power lines directly to your power supply, so that the LED current does not flow through the Arduino (because that can fry your Arduino) - and the data In pin of the strip to a fitting digital pin of the Arduino. You can use the Adafruit Neopixel library or the FastLED library for controlling them.
To turn the strip on, you set the needed pixels to the wanted color and then call the show method of the library (which sends out the color data through the data pin). To turn the strip off, you simply clear all the pixels (the libraries have extra functions for that), which basically means setting all pixel to black (red, green and blue components all zero).
So forget about the relay and just use the strip directly. Also Adafruit has a very good guide on how to use the Neopixels.


What is the highest baud rate that can work between Android device and an Arduino connected to an HC05?

The HC-05 may only have implemented baud rates up to 1382400, even though the protocol is spec'd for up to 128000.
If you're using Software Serial to talk to the HC-05 from an Uno, 9600 baud is about as fast as SoftwareSerial can keep up with incoming bytes (I've heard from some people that 19200 will work).
If you're using one of the UARTs on a Mega, you may be able to use the full rate implemented by the HC-05. An experiment would be in order...
Update:

I did an experiment and found out that the maximum baud rate
achievable between the HC05 (communicated with by SoftwareSerial on
Arduino Nano) and the Android device is 115200.

I would guess you were transmitting from the Arduino? I've been able to transmit that fast with SoftwareSerial but its receiving ability is more limited. (This has enabled me to, f/ex, set an HC-05 or an ESP8266 to a slower baud-rate than it shipped with, by blindly transmitting an appropriate 'AT' command at the higher speed, then testing it at my intended speed to see if the command worked).


You should specify what model of Hokuyo scanning range finder you have.  Some models are USB-interfaced, in which case  COM+ and COM- could possibly correspond to USB D+ and D- leads.

The Hokuyo URG-04LX has both USB and RS-232 interfacing.  The linked page shows the following pinout on CN1:

Pin No.   Signals                                Colors
1         N.C.                                   Red
2         N.C.                                   White
3         OUTPUT(Synchronous output)             Black
4         GND(5th pin of 9-pin, D-sub connector) Purple
5         RxD(3rd pin of 9-pin, D-sub connector) Yellow
6         TxD(2nd pin of 9-pin, D-sub connector) Green
7         0V                                     Blue
8         DC5V                                   Brown

Given that pinout, you would connect pin 5, RxD, to a TXD output on the Mega, and pin 6, TxD, to an RXD input on the Mega.  Note, before making any such connection, measure the output voltage on pin 6.  An ordinary Mega supports 0 V and 5 V levels for serial data, but standard RS-232 levels are lower and higher than that; for example, ±12 V.  If you connect  ±12 V RS-232 levels to your Mega, you will damage it.  The several Hokuyo documents I've looked at don't say whether they use traditional RS-232 levels (±12 V) or TTL levels (0-5 V).


What terminologies and concepts describe the codes that follow a format of Text1.Text2()?

The over-arching concept is Object Oriented Programming (OOP).
The terms I was taught at University - taking Serial.println() as an example:

Serial is an instance of a class (in this case HardwareSerial), sometimes called an object.
println() (a function in a class) is a method of a class.
A "variable" in a class is called a property of a class.

A commented code example:

class Foo { // This is the *class*

    public: // These symbols are accessible from outside the class

        int bar; // This is a public property

        void baz() { // This is a public method
        }

    private: // These symbols are only available from inside the class

       int meep; // This is a private property

       void moop() { // this is a private method
       }
};

Foo bar; // Instantiate an instance of the Foo class and call it bar.


Arduino IDE compiling for non-arduino AVR boards

Yes, MiniCore is a self-contained hardware package. After installing MiniCore select one of the MiniCore boards in the Arduino IDE's Tools > Board menu and the Arduino IDE will automatically use the pins_arduino.h file included with MiniCore. There is no need to modify any file in the Arduino IDE folder or any other folder.


When I call the tone function on a Uno, why do I not have to declare the pinmode in setup?

Because the tone(hertz) code initializes the pinmode, along with the timer/counter control registers to produce the appropriate frequency.

void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
  uint8_t prescalarbits = 0b001;
  long toggle_count = 0;
  uint32_t ocr = 0;
  int8_t _timer;

  _timer = toneBegin(_pin);

  if (_timer >= 0)
  {
    // Set the pinMode as OUTPUT
    pinMode(_pin, OUTPUT);
   ...

See Tone.cpp - line 255 for the source.


Instead od the SD card you can use the esp8266 file system SPIFFS. It uses the flash of the esp8266, which is connected at 40MHz as Quad I/O on newer systems.

To use SPIFFS you create a folder named data in your esp8266 sketch folder. You put the files in that folder and then you use the SPIFFS upload plugin.

In runtime use the SPIFFS library. It is similar to SD library.


Specific noise while using arduino ADC in free running mode

If you use an ISR to retrieve the ADC result, you will need to protect the read of the variable. An interrupt may occur when reading aval in the loop(), as this is a 16-bit value and the read requires several instructions. This may give corrupt values.

void loop() {
  noInterrupts();
    val = aval;
  interrupts();
  val = map(val, 0, 1023, 0, 255);
  Serial.write(val);
  delay(10);
}

Cheers!


Supplying near perfect DC signals from Arduino UNO

(1) A multipole active lowpass filter works wonders.
Something like a 5 pole Bessel filter will probably meet your need. That needs two active stages (1 input RC pole +2 +2 ). You can use transistors in emitter follower mode with some reservations but using 2/4 of a quad opamp per filter is easier overall. I can't spare the lookup time just now (later maybe) but AD & LT and NatSemi all have good free active filter design programs.

(2) A Simple sample & hold per channel will give you steady output limited only by the drift of the opamp used. You can buy commercial S&H ICs or use std opamps. I've used even the venerable LM324 for this but there are much better - you apply the voltage via a switch to a cap[acitor at a unity gain buffer input and then turn off the switch. Again, the "switch can be as simple as an ancient CD4016 or CD4051 but much better more modern ICs are available.

With 1 x CD4051 and 2 x LM324 (or better) you can feed 8 x S&H and update them occasionally top compensate for drift.  If you add another CD4051 with identical addressing but working backwards you can read back the current capacitor voltage and "nudge" it with a simple digital on signal via a diode and high R  resistor if it is slightly off. You can even do ALL signal setting this way if required with NO PWM (or you are effectively implementing adaptive PWM without formally doing so). You eg use 4 driver lines - a fast and slow drive high and a fast and slow drive low. Each is just a digital pin + a resistor and a diode. Select one output channel with the output mux (CD4051 or whatever, and the return mux connects it to your ADC. Pump it up to about right with fast-high, top it off with slow-high and correct with slow-low if needed, then step the mux to the next channel and the S&H cap looks after it. Note that the return channel to the ADC must not load the cap significantly while reading.

If this answer attracts significant interest I can add detail and suggestions re more modern components etc. If not, the above is all a keen person needs to look into the concept.


Lily Pad mp3, nested loops with timing and play randomly choosen mp3, coding problem

Halo, thank you for ansering anything.. I got the loop loop loop thing now runin..

So its about playing an Audiofile if hookon == LOW ........ check it out :-)

The code now looks like this.

const int ringerPin = A0;
const int offhook = A4;
const int onhook = A5;
double beginRing = -40000;

void setup(){
    pinMode(ringerPin, OUTPUT);
    pinMode(offhook, INPUT);
    pinMode(onhook, INPUT);
    randomSeed(analogRead(0)); // this starts Arduino's random number generator
}

int randCall = random(60000, 3600000); // generate a random number between 1 min and 60 min

//ring every 1 to 60 minutes if the phone is down (hookon) and dont ring if the phone is picked up (no hookon)
void loop()
{
  if (digitalRead(hookon) == HIGH){
    delay (randCall);
    beginRing = Time.elapsedTime;
    while(Time.elapsedTime - beginRing <= 30000 && digitalRead(hookon) == HIGH){
      //turn any audio off???
      for(int x = 0; x < 15; x++){
        digitalWrite(ringerPin, HIGH);   // turn the solenoid on (HIGH is the voltage level)
        delay(50);                           // wait for 50 msec
        digitalWrite(ringerPin, LOW);    // turn the solenoid off by making the voltage LOW
        delay(80);                          // wait for 50 msec
      }
      delay(2500);
    }
  }
  if(Time.elapsedTime - beginRing <= 30000){
    //play one randomly choosen audiofile out of 10
  }
}

So, now its about to stop any sound if the hookon is HIGH and to play the randomly choosen file 1 out of 10 if the hookon is LOW (its in the code as description...there i need the right comands)


How to make Serial.read() return an integer instead of an ascii value?

If it's a single digit:
if (t >= '0' && t <= '9') {
    int numeric_value = t - '0';
} else {
    // Handle the input error.
}


Explanation please, of hardware and software serial links

Most small micro controllers, AVR's included, have dedicated hardware for communicating with different serial devices. In arduino these are referenced with "Serial", "Serial1", "Serial2" and so on, depending on how many hardware serial ports your particular arduino has.

Leonardo's are an exception, the first hardware port is "Serial1" and "Serial" refers to the PC's usb connection. On the other arduinos that I know of "Serial" is hardware serial used for PC comms, so using it for other hardware requires sacraficing your PC link.

Software serial ports use the processors more generic pin-change interrupt system to communicate on any pins that support said interrupts, but they have a higher processing overhead and often cannot support the same high speeds as the hardware serial. There are different libraries for Software Serial that have different approaches giving different advantages and drawbacks.

To use a software Serial port you will need to make one to be used in your code, which will look something like this, depending on the type name the library you include uses:

SoftwareSerial softSerial( txPinNumber, rxPinNumber);

So in short, your processor has dedicated hardware for communicating over serial that should be used first, but if you need more ports the processor can simulate some extras which is referred to as "Software Serial". The documentation to your GPRS shield implies that either will work just fine. You should look at the arduino documentation for your board to see how many ports you have and which pins can be used for serial.

The documentation does not imply you will need any special link to your computer outside of the USB connection.


Test level shifter with Arduino and some data

You don't need to write any program.

First, note that this is (or at least purports to be) an I2C level shifter. This means that it does not actively pull up anything; it only actively pulls down. You are supposed to provide pull-ups somewhere in your circuit.

To test it, pull up HV1 and LV1 with 10K resistors to HV and LV respectively; measure the voltage on both sides to verify you are pulling to ~5V and ~3.3V respectively.

Ground HV1, check that LV1 is low.

Ground LV1, check that HV1 is low.

Ta-dah!


All of the errors I got were "NewPing does not name a type", "AF_DCMOtor does not name a type" and "motor<> was not declared in this scope". I don't see library includes; at least one for NewPing is needed. I don't know where AF_DCMotor is supposed to be declared but, as it is not declared as a type, it leaves all of the motor undefined. Those are the bulk (if not all) of the errors as the code stands now. Add the missing NewPing library do whatever you need to to define AF_DCMotor.


Using more than 8 digits using the sevseg library

You can change the pre-defined maximum number of digits at the top of the SevSeg.h header file to as many as 10, if you use long or unsigned long when you call setNumber.  It is defined here, on line 27:
#define MAXNUMDIGITS 8 //Increase this number to support larger displays

This the version referenced from the Arduino Playground SevSeg.  Be sure to use the same number in your modulo, too:
void loop()
{
  //local vars
  static byte decPlace = 0;

  sevseg.setNumber(8888,decPlace);
  decPlace++;
  decPlace %= 10; //rollover back to 0 once variable gets to 10

decPlaces is mostly useful for floating-point numbers: it specifies how many digits after the decimal point should be displayed.  For integer values, it specifies how many leading zeroes will be displayed.
However (as you discovered), you cannot call setNumber with anything larger than a long, so you are limited to 10 or fewer digits for MAXNUMDIGITS.  (There is no byte overflow -- it's just limited to the number of decimal digits in 232-1.)  This is a limit of one SevSeg instance.  You could have two instances of SevSeg like this:
#include <SevSeg.h>
SevSeg sevseg1;
SevSeg sevseg2;

void setup()
{
  byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13}; //Segments: A,B,C,D,E,F,G,Period

  byte digitPins1[] = {2, 3, 4, 5, 22, 23, 24};
  sevseg1.begin(COMMON_ANODE, sizeof(digitPins1), digitPins1, segmentPins);
  sevseg1.setBrightness(10);

  byte digitPins2[] = {14,15,16,17,18,19,20,21};
  sevseg2.begin(COMMON_ANODE, sizeof(digitPins2), digitPins2, segmentPins);
  sevseg2.setBrightness(10);

  sevseg1.setNumber(  7654321UL, 7 );
  sevseg2.setNumber( 87654321UL, 8 );
}

void loop()
{
  sevseg1.refreshDisplay();
  sevseg2.refreshDisplay();
}

The first instance handles 7 digits, and the second instances handles 8 digits.  Note the use of "UL" to force and unsigned long call.
Update 11-DEC-2015

Using the following code, I can't get the 3rd set of 5 numbers to display. I have changed the sevseg.h file to 15, but that shouldn't matter:

First, the MAXNUMDIGITS is the maximum per instance, so you could set it to 5 to save some precious RAM.
Second, you have a copy and paste error:
sevseg1.refreshDisplay();
sevseg2.refreshDisplay();
sevseg2.refreshDisplay();   <--  Oopsies!  :)

Third, I assume the setNumber calls are placeholders for what you're really going to use.  Since they always set the same value, they could be in setup.  In your final program, there must be some input that will be used to calculate a number to display with setNumber.


I made up a test by adding enough to the posted code to get it to compile:

float ActualPosition, SetPosition, Velocity;

int Iteration;

int ProgFormula() {

  static int StartPosition;
  static int DeltaPosition;
  static int LoopTime = 5;
  static int AccelerationLoops;
  static int TotalLoops;
  static int EndOne;

  static float VelocityLoop;
  static float VelocityFactor;

  int Setpoint;

  if (Iteration == -1) {
    StartPosition = ActualPosition;
    DeltaPosition = abs(SetPosition - StartPosition);
    VelocityLoop = Velocity / (1000 / LoopTime);
    TotalLoops = DeltaPosition / VelocityLoop;
    if (TotalLoops <= (AccelerationLoops * 2)) {
      AccelerationLoops = (TotalLoops / 2);
      VelocityFactor = (VelocityLoop * 0.5 / AccelerationLoops) / 2;
    }
    else {
      AccelerationLoops = 70;

      VelocityFactor = VelocityLoop * 0.5 / AccelerationLoops;
    }
    TotalLoops = DeltaPosition / VelocityLoop + AccelerationLoops;
    EndOne = (VelocityFactor * pow(AccelerationLoops, 2));
  }
  else if (Iteration >= 0 && Iteration <= AccelerationLoops) {
    if (StartPosition < SetPosition) {
      Setpoint = VelocityFactor * pow(Iteration, 2) + StartPosition;
    }
    else {
      Setpoint = -VelocityFactor * pow(Iteration, 2) + StartPosition;
    }
  }
  else if (Iteration > AccelerationLoops && Iteration <= (TotalLoops - AccelerationLoops)) {
    if (StartPosition < SetPosition) {
      Setpoint = VelocityLoop * Iteration - EndOne + StartPosition;
    }
    else {
      Setpoint = -VelocityLoop * Iteration + EndOne + StartPosition;
    }
  }
  else if (Iteration >= (TotalLoops - AccelerationLoops) && Iteration <= TotalLoops) {
    if (StartPosition < SetPosition) {
      Setpoint = -VelocityFactor * pow((TotalLoops - Iteration), 2) + DeltaPosition + StartPosition;
    }
    else {
      Setpoint = VelocityFactor * pow((TotalLoops - Iteration), 2) - DeltaPosition + StartPosition;
    }
  }
  else {
    Setpoint = Setpoint;
  }
  return(Setpoint);
}

void setup ()
  {
   ProgFormula ();
  }  // end of setup

void loop ()
  {

  }  // end of loop

Disassembling this I got the following assembler:

000000a8 <_Z11ProgFormulav>:
  a8:   6f 92           push    r6
  aa:   7f 92           push    r7
  ac:   8f 92           push    r8
  ae:   9f 92           push    r9
  b0:   af 92           push    r10
  b2:   bf 92           push    r11
  b4:   cf 92           push    r12
  b6:   df 92           push    r13
  b8:   ef 92           push    r14
  ba:   ff 92           push    r15
  bc:   0f 93           push    r16
  be:   1f 93           push    r17
  c0:   cf 93           push    r28
  c2:   df 93           push    r29
  c4:   00 91 0c 01     lds r16, 0x010C
  c8:   10 91 0d 01     lds r17, 0x010D
  cc:   8f ef           ldi r24, 0xFF   ; 255
  ce:   0f 3f           cpi r16, 0xFF   ; 255
  d0:   18 07           cpc r17, r24
...
 4ec:   cb 01           movw    r24, r22
 4ee:   df 91           pop r29
 4f0:   cf 91           pop r28
 4f2:   1f 91           pop r17
 4f4:   0f 91           pop r16
 4f6:   ff 90           pop r15
 4f8:   ef 90           pop r14
 4fa:   df 90           pop r13
 4fc:   cf 90           pop r12
 4fe:   bf 90           pop r11
 500:   af 90           pop r10
 502:   9f 90           pop r9
 504:   8f 90           pop r8
 506:   7f 90           pop r7
 508:   6f 90           pop r6
 50a:   08 95           ret

0000050c <setup>:

So that function (ProgFormula) has taken up:

0x50a - 0xa8 = 1122 bytes

Now by removing the "static" declarations, like this:

   int StartPosition;
   int DeltaPosition;
   int LoopTime = 5;
   int AccelerationLoops;
   int TotalLoops;
   int EndOne;

   float VelocityLoop;
   float VelocityFactor;

It now compiles to:

000000a8 <_Z11ProgFormulav>:
  a8:   6f 92           push    r6
  aa:   7f 92           push    r7
  ac:   8f 92           push    r8
  ae:   9f 92           push    r9
  b0:   af 92           push    r10
  b2:   bf 92           push    r11
  b4:   cf 92           push    r12
  b6:   df 92           push    r13
  b8:   ef 92           push    r14
  ba:   ff 92           push    r15
  bc:   0f 93           push    r16
  be:   1f 93           push    r17
  c0:   cf 93           push    r28
  c2:   df 93           push    r29
  c4:   c0 91 04 01     lds r28, 0x0104
  c8:   d0 91 05 01     lds r29, 0x0105
  cc:   8f ef           ldi r24, 0xFF   ; 255
  ce:   cf 3f           cpi r28, 0xFF   ; 255
  d0:   d8 07           cpc r29, r24
...
 27e:   cb 01           movw    r24, r22
 280:   df 91           pop r29
 282:   cf 91           pop r28
 284:   1f 91           pop r17
 286:   0f 91           pop r16
 288:   ff 90           pop r15
 28a:   ef 90           pop r14
 28c:   df 90           pop r13
 28e:   cf 90           pop r12
 290:   bf 90           pop r11
 292:   af 90           pop r10
 294:   9f 90           pop r9
 296:   8f 90           pop r8
 298:   7f 90           pop r7
 29a:   6f 90           pop r6
 29c:   08 95           ret

0000029e <setup>:

That is now:

0x29e - 0xa8 = 502 bytes

Conclusion

Adding "static" has made the function over twice as long. Presumably it is also slower. After all, those extra instructions have be doing something.

  to increase the speed I added some static variables to it.

Your belief that making variables static increases the speed does not seem to be supported.


How can I have 2 differents frequency on the 2 DAC outputs on an Arduino Due?

I don't have experience with this, but what you can do is:

If the frequency of DAC1 is x times faster than DAC2 to calculate the delay time based on the fastest and for DAC1 changing in every loop, while changing DAC2 only every DAC1/DAC2 times.
Vice versa if DAC2 is x times faster than DAC1
However, if there is not a simple ratio between DAC1 and DAC2 than you have to use the fastest speed of the two and use for the slowest an approximation...
Or use a higher significant fixed speed for i use a simple linear approximation between two points of the wavetable.

E.g. assume the speed is 10 times too fast for DAC1.
Suppose i = 100.. you should use the following points in the waveform: wave[100/10] and wave[100/10 + 1], so two consecutive points.
Assume the first is 10.0 and the second is 20.0... for the 10 increases of i (because i is running 10 times too fast) you can calculate for values of

 i     : 10.0 +   0% of (20.0 - 10.0)
 i + 1 : 10.0 +  10% of (20.0 - 10.0)
 ...
 i + 10: 10.0 + 100% of (20.0 - 10.0)

etc.

Note this is called linear interpolation.

You would have to check how many numbers per wave form table you need to get good values for different frequencies/speeds and what 'fixed' frequency you need to use for the delay.


Arduino RTC - getting the time from RTC after the power is cut off

Without knowing the DS1307 well, I think there are two options:

Make the setting of the clock a UI function (you should probably do this in any case since you will want users to have the ability to set the clock). The user would have to initiate the action (and put in the time to set) so there would be no problems the clock getting reset inappropriately, or
Do a check for sanity of the clock before you run that line. You might be able to do that through the clock API (e.g., make a call to check the time, or to get the clock status and see if it makes sense) or you could do it by storing the clock status in nonvolatile memory. The very worst case would be that you store the time of last boot and check that it seems reasonable (e.g., the time you get from the RTC is after the last boot and is within reason – say no more than a month or a year ago). If the time is too far off to feel confident you could issue a "check time" warning.

If you have a network connection using NTP as well as the RTC would be a very smart option. NTP can hold the time within a few milliseconds. The RTC would then provide you with protection against a network outage.

If you are using the Arduino to manage scheduled events one thing you'll want to think about is events that are scheduled in a moment of time that is either "skipped" as you advance the clock or that "repeats" if you set the clock back. One way to handle that is to never "jump" time, but to always just speed it up or slow it down.


Arduino Nano/Uno and js sketch compiling/uploading from browser

You can't, and that's a good thing. If the browser could let a Web site access your hardware, that would be a huge security breach. You may be able to bypass this security restriction if you can write an extension (plugin) for your browser.


button connection without connection to 5V pin

There is a pullup resistor you don't see in the diagram because it is internal to the Arduino. I have added it in red. To make pin 7 an input, you can write:
digitalWrite(7, INPUT_PULLUP);

, which not only makes the pin an input but also engages the internal ~20K pullup  resistor.
So, you're right about the first diagram - it looks like the pin is left floating. Without the code, or an explanatory note, the pullup resistor isn't documented. In such a diagram, once you are familiar with the processor and know that there are optional pullups on the pin-drivers, you can assume that the optional pullup will be used.

Update: I drew in the resistor assuming the red rail was connected to 5v - I should have drawn that in, too.


2.4Mhz clock for 3-wire SPI using Arduino Mega 2560

It's hardly possible to generate a stable and exact frequency with your method.
Imagine you have an interrupt routine interrupting your spiRead() or any function called inside: Your clock will be extended by the ISR runtime.
Apart from this:

I'm not sure if your LOW phase is long enough (there's no delay between setting CLK from LOW to HIGH. If 2.4 MHz is the max frequency for the chip, it should be at least 208ns.
However:
If you are sure that the runtime of digitalWrite is always longer than 208ns, you could remove your delay() at all. The resulting frequency is the maximum possible you can achieve with your method.
The smallest delay() is 1ms, which leads to a maximum of something < 1 kHz (or even 0.5kHz for a 50:50 signal).
You should use delayMicroseconds() to get at least 500kHz.

But what I'm really wondering:
Why are you implementing bit banging instead of simply using the SPI library?


do two arduinos that are linked to a common 9v rail and ground still need a common negative connection for a serial tx rx connection?

All voltages are ground referenced, hence the ground is the only (supply) connection required. Remote modules can be self-powered and signals will still be discriminated as long as ground is connected.