Where do avrdude parameters get defined in the Arduino IDE?

There are 3(or 4) places that you need to look at to know how to upload.
There is the boards.txt file and the platform.txt file.
You can consider a platform.txt file line

tools.avrdude.path={runtime.tools.avrdude.path}

as (in linux in windows replace ${xx} by %xx%)

set tools.avrdude.path ${runtime.tools.avrdude.path}

and the board.txt for the selected board like

uno.bootloader.tool=avrdude

as

set bootloader.tool avrdude

The arduino ide uses the following string to know the upload command environment variable

tools.${bootloader.tool}.upload.pattern

This way it knows the command to upload is

"{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

{cmd.path} is hardcoded as tools.${bootloader.tool}.cmd.path which equals {path}/bin/avrdude
where {path} is to be understood as tools.${bootloader.tool}.path wich equals {runtime.tools.avrdude.path}.
{runtime.tools.avrdude.path} is defined by the boardsmanager based n the json file and the location where the boardsmanager extracted the download.

So that makes 3 files: boards.txt, platform.txt and json file and some hard coding.

A 4th file comes into play when you use the "other upload commands". These are located in the programmers.txt file.

IMHO Arduino IDE core team did not opt for the simplest solution to define these things. They also change the way they work from time to time.
If you use a makefile know that a lot of people have done this already so it may be a good idea to "reuse other peoples work" instead of "reinventing the wheel". It is not so easy or straightforward.

Note I know all these things because I implemented the Arduino eclipse IDE. As far as I know none of this is documented.


Include Adafruit_RGB LCD Shield library in class

Move your #include statements outside the class definition.

You declare a pointer, but never allocate space for it with new. I see no need for a pointer.

#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

class LcdMenu
{
 public:
     // default ctor will be called here.
     Adafruit_RGBLCDShield lcd;

     void Setup()
     {
      lcd.begin(16, 2);
     }
     void Write(int line, char text[17])
     {
      lcd.clear();
     }
};

LcdMenu LcdM;
#define VIOLET 0x5

void setup()
{
  LcdM.Setup();
  LcdM.lcd.setBacklight(VIOLET);
}

Also note: you are not extending the Adafruit_RGBLCDShield class as in the example you linked. To do that:

#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

class LcdMenu : public Adafruit_RGBLCDShield
{
 public:
     void Setup()
     {
      begin(16, 2);
     }
     void Write(int line, char text[17])
     {
      clear();
     }
};

LcdMenu LcdM;
#define VIOLET 0x5

void setup()
{
  LcdM.Setup();
  LcdM.setBacklight(VIOLET);
}


I 've been working on an autonomous arduino quadcopter for about 7 months now and I have a few tips for you.

1) your setup seems fine as long as your motors aren't going to draw more amps than your ESC can supply, but It is always a good idea to buy ESCs with a higher "max amps" than your motors draws. I would choose 25 amp max ESCs or higher.

2) In order to control the motors via PWM, I use the Servo library because you get a resolution from 700-2000 as opposed to "analogWrite" which gives a default resolution of 0-255.

3) your ESC probably has a minimum pulse width value before it will start. I would recommend writing a program that gives you the ability to plug in values from 700-2000, and use the program to slowlly find that arming pulse width value. Mine is 1110 for reference.

If you have anymore questions, I will glady answer them.

May I ask, what is your project?


Find external router IP from Arduino Yun inside router network

You can write a program that updates its own external IP every couple of minutes/hours, or when it doesn't get a response from another Yún/PC/server.

You can use this link (or find another site of the web that gives you your external IP address): http://www.realip.info/api/p/realip.php

This link has a beautifully formatted information that you can easily extract. I have a similar solution on one of my servers that have a dynamic IP...


Bluetooth Low Energy dropping data at 115200 baud?

Well, I did some tests and was not able to reliably receive data at over 9600 baud, even with hardware flow control activated via the AT+FLOW1 command. And even then, if either the BLE module or the phone was moving, data was consistentlydropped.

I ended up implementing an SD data logger instead.


The problem with getting no response from the mouse was that the bluetooth did not auto reconnect to the computer after powering down. I solved this by sending the command SM,6 for auto reconnect and then R,1 to reboot.


Yes absolutely it is possible. As a beginner, I suggest something like this:

simulate this circuit – Schematic created using CircuitLab

In your setup you will need to declare D4 - D7 as inputs. I have used D4 - D7 but you can choose whatever pins are available.

Then in the loop part of the code you want to look for the rising edge on the input (ie when the switch is pressed). Switch debounce is less important for this application as it is not a counter but rather a mode change.

I have written a good answer for detecting a button press here.

Nick Gammon has an excellent switch tutorial gammon.com.au/switches that covers all kinds of conceivable situations (high or low, GND or +5V, internal pull-up or pull-down, capacitor debounce or software debounce, etc.)

I would imagine the code would look something like this:

if( digitalRead(SW1) == HIGH )
    mode = 1;

if( digitalRead(SW2) == HIGH )
    mode = 2;

if( digitalRead(SW3) == HIGH )
    mode = 3;

if( digitalRead(SW4) == HIGH )
    mode = 4;

You could then use a switch-case statement to run the various NeoPixel patterns.

For more programming reference see: https://www.arduino.cc/reference/en/


Arduino code of making a LED digit display not functioning properly

The for loop in your setup() function isn't quite right. The condition (i<9) and the iterator (i++) need to be the other way round, like this:

for (int i = 2; i<9; i++)
{
  pinMode (i, OUTPUT);
}


MAX7219 with Arduino UNO - LED control doesn't work

OMG, the only problem was a typo in LedController initialisation! I used LedControl lc=LedControl(12,11,10,4); instead for LedControl lc=LedControl(11,12,10,4);. It seems the library has no error detection if passed data pin isn't really a data pin. Now everything works fine.


How to develop or edit an Arduino library?

I'm not accepting any answer because they are only focused on versioning/git/github fork->edit->share and I am very interested on all the things that I have to do to make the development.

I will run through the basics of making a library. It's really quite simple, and they persist through upgrades to the IDE.

Let's imagine I have a useful function (or lots of functions) that I want to use in lots of sketches. For example, something that blinks an LED:

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i < times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED

And some test code:

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop

Make a library

To turn that into a library we need three steps:

Make a folder for the library. This should be placed inside the libraries folder in your sketchbook folder. This folder:

In my case: /home/nick/sketchbook/libraries. It does not go into anywhere associated with the IDE download.

  but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries

No, not there.

I will call my library blinkLED. So I make that folder, which is now: /home/nick/sketchbook/libraries/blinkLED

Make a function prototype for any functions your library is going to "expose" to the end-user, and put that into a .h file, like this:

blinkLED.h

#include <Arduino.h>

void blinkLED (const byte which, const int times);

Important: You must include <Arduino.h> as in the example, or you will get compile errors.

Put the C++ code into a .cpp file, like this:

blinkLED.cpp

#include <blinkLED.h>

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i < times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED

Important: You must include the .h file created in step 2, as in the example, or you will get compile errors.

That's it! Restart the IDE now so it notices the new folder with the library in it.

Now our test sketch can just use the new library.

#include <blinkLED.h>

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop

Testing

For testing I just keep the library files open in a separate text editor (I am using Geany these days, but whatever your favourite editor is).

You can make changes to the library source and save them. You do not need to restart the IDE if you do this. It will always pick up the latest version.

In the IDE you alter your calling code, upload and test. It is really quite fast and simple.

Git

Once you have put a bit of work into your library you probably want to put it under source control. Using a terminal/command window, navigate to the library folder and put it into a Git repository:

git init
git add *.cpp
git add *.h
git commit -m "Initial commit"


Sending to Arduino UNO multiple values from Python code

Well I did it in the simplest way.

I just sent a string to C++ and deconstructed it with sscanf().


Non-blocking incrementation with single button pressure

In your approach a button press will be detected every 100ms when you just keep the button pressed. So you have to set a flag when the button is pressed. When the button is not pressed while your flag is set, that's the event you're looking for. In this way you can detect both a button press and a release respectively.
As @JRobert mentioned, there still has to be an amount of time between two calls to such a routine to provide some button debouncing.

bool pressed_flag=false;
bool button_timestamp=millis();
uint16_t button_period=100;

if(millis()-button_timestamp>button_period){
  button_timestamp=millis();
  if(redButton.isPressed() && !pressed_flag){
    // button has just been pressed
    // you can do sth. here
    pressed_flag=true;
  }
  else if(!redButton.isPressed() && pressed_flag){
    // button has just been released
    // you can do sth. here
    pressed_flag=false;
  }
}


How does this Motor Circuit not ruin the Microcontroller

This is a bad idea, but not because two pins seem to be connected directly. They're not; there is a load (the motor) between the pins, and that motor will take care of different levels between the pins. High and low will make the motor turn one way, low and high the other way, and the same level on both pins will stop the motor.

Why is this bad? An I/O pin can only supply a limited current, and even for a small motor that will peak rather high. If you run the motor for some time this way you will damage the I/O ports. An H-bridge, like you mention, is the solution.
Note that electric motors cause a lot of noise in the power supply, which may cause the microcontroller to reset all the time, so that your program doesn't work. (The motor may seem to start/stop all the time.) You need to decouple the power supply with capacitors.


Declaring and using array of structures in Arduino

The problem is that a struct is handled as a value type, not as a reference type.

This means that a copy of _stop is made and put in btns (btns[3] actually).

So what you need to do is putting pointers into the btns array:

SCENARIO* btns[4] = { &_red, &_yellow, &_white, &_stop};

The symbol * denotes a pointer, and & means the address of a variable (so it points to the variable and is not a copy).

Now when you change _stop, also btns[3] which points to _stop will show the correct initialized value.

For printing you should use:

Serial.println( (*btns[i]).LampPin);Serial.print(":");
Serial.println( (*btns[i]).PB_Pin );

Because *btns[i] is a pointer, but because this is a very often used feature, a special notation can be used:

Serial.print(btns[i]->Lamp_Pin);Serial.print(":");
Serial.println( btns[i]->PB_Pin);


Arduino Micro: how to switch off its blue power LED?

Unfortunately the blue LED is a direct connection between 5V and GND. You can see below in the schematic exactly how it is connected

The only way to 'turn off' the LED would be to remove either the 1K resistor or LED with a soldering iron.

Another possibility is to take a sharp knife and make a cut in the track directly before or after the LED. I've marked the locations where to cut on the eagle screenshot.


Read an analog signal without changing it? Or should I start over?

A JFET op amp such as the TL071 has an input impedance in the hundreds of gigaohms or higher. Using one to buffer the voltage should allow you to sample it without much interference to the existing circuit.


Code is not running, servo does not even spin

For starters: this bit is a strange mixture of for and while syntax:
while (int i = previous_angle) {
  i <= 90;
  i = i + 1;
  myservo.write(i);
  delay(45);
};

It will compile, but probably not do what you want it to do. It should probably be:
for (int i=previous_angle; i<=90; i=i+1) {
  myservo.write(i);
  delay(45);
}

Also, previous_angle is never changed in your code after initialisation; it is always 0.
That also means that the for loop below will not do what you want (and that loop also doesn't increment i anywhere):
for (int i = previous_angle; i>0;)

There may be more; make the suggested changes first and see what happens.


What is the wiring of arduino motor shield to Nano?

I believe, though it's not clear, that the shield in question uses a 74HC595 shift register to control the main motor drivers - the other pins are for the servo interfaces (and they are just wired 1:1). Theoretically you can therefore use any pins you like to control the motor drivers themselves.

It's not the same as the Adafruit one which looks to use direct Arduino control of the motor drivers.


I can't receive string that I have sent through nrf correctly

Remove the & in the master code line, change

 radio.read(message, sizeof(message));

to

radio.read(message, sizeof(message));

message is an array, so either you should pass the address of the first character (&message[0]), or simply pass message.

Another problem is sending a String in the slave code (using type String). It's better not to use this type anyway, but you probably have to convert it to a character array of the same type as in the master code.

You can use the function StringToCharArray for that, see StringToCharArray.


MD5 hash for Arduino Uno [-Wshift-count-overflow]?

....\sketch_may02a_MD5_test.ino\sketch_may02a_MD5_test.ino.ino:15:51: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

That is a flaw in the library. The author defined the function as taking a char * instead of a const char *.  You can ignore it, it's just a warning - however maybe raising the issue with the author could be a good idea.

  C:\Program Files (x86)\Arduino\libraries\MD5\MD5.cpp:207:21: warning: right shift count >= width of type [-Wshift-count-overflow]

This one is a little more awkward.  The size variable is defined as type size_t.  That varies in length depending on the architecture the software is compiled on.  On the 8-bit Arduinos that's a 16 bit variable. On 32-bit Arduinos, like the Due, it's a 32-bit variable.

It is probable that the author developed the library using a 32-bit Arudino (or Arduino-compatible) device - in which case he would never see that warning (since 29 is less than 32).  However anyone that then uses an 8-bit Arduino gets the warning, and probably a corrupt hash.

However, it looks like it should only be a problem if size is too big - and it can't be on an 8-bit Arduino. So again you can ignore it, but the author should really be made aware of the issue.


How is better to store html / java script / in code or in flash on esp32

Best is to store static files in SPIFFS and serve them with Expires header set, to let the browser cache the html, css, js files and pictures files.

How to build the Expires header:

unsigned long expires = now() + SECS_PER_YEAR;
bp.printf(F("Expires: %s, "), dayShortStr(weekday(expires))); // two printfs because ShortStr functions share the buffer
bp.printf(F("%d %s %d 00:00:00 GMT"), day(expires), monthShortStr(month(expires)), year(expires));

And use AJAX method to show data on the page. Make the request with XMLHttpRequest object:

function getData(cmd) {
  var xhr = new XMLHttpRequest();
  xhr.onerror = function(e) {
    alert(xhr.status + " " + xhr.statusText);
  }
  xhr.onload = function(e) {
    showValues(xhr.responseText);
  };
  xhr.open("GET", "http://" + host + ":" + restPort + "/" + cmd, true);
  xhr.send();
}

showValues would be your function to fill the data into page

In ESP32 build the response as JSON for simple handling of the data in JavaScript.

Here is the WebServer in my project. It uses the basic Arduino Server class, not the esp WebServer. It has #ifdefs for SD or SPIFFS. The static files of my project including the js file are here.


I have to disagree that your first sketch is working. I suppose that a very fast blinking led seems to be "on".

When you describe what should happen in a logic way, then you can put that into code.

The logic is: The led is on, if at least one of the buttons is pressed.
In other words: The led is off, if no button is pressed, else the led is on.

This logic has as a result that the led stays on if a second button is pressed and after that the first button is released. I assume this is okay.

For two buttons it is possible to check both conditions.

if (digitalRead(button.pin) == HIGH || digitalRead(button2.pin) == HIGH)
  digitalWrite(ledPin, HIGH);
else
  digitalWrite(ledPin, LOW);

Or test for LOW:

if (digitalRead(button.pin) == LOW && digitalRead(button2.pin) == LOW)
  digitalWrite(ledPin, LOW);
else
  digitalWrite(ledPin, HIGH);

For multiple buttons, a bool can be used or the number of pressed buttons can be counted.

A fixed number for the array size is easy and has less chance for a mistake:

#define BUTTONS_COUNT 2

It is also possible to use sizeof(). The total size has to be divided by the size of one element:

int count = 0;
for (int i = 0; i<sizeof(buttons)/sizeof(Button); i++) {
  if (digitalRead(buttons[i].pin) == HIGH) {
    count++;
  }
}

if (count == 0)
  digitalWrite(ledPin, LOW);
else
  digitalWrite(ledPin, HIGH);


How to set a time out like Serial.setTimeout() for Serial.read()?

You can't set timeout for read(), but you can use readBytes() to read one byte.

byte b;
int count = Serial.readBytes(&b, 1); // read one byte with timeout
if (count) { // 0 or 1
  Serial.write(b); //echo
}


Proper use of * and & when passing objects in methods

The method you have implemented, passing by pointer, is one of the two normal methods, yes. The other is passing by reference and is specific to C++, not C.

Under the hood the end result is the same between the two methods, by the syntactic "sugar" is very different and the latter can be preferable for that reason alone.

Your method:

void function(whatever *ob) {
    ob->method();
}

function(&myObject);

The pass by reference method:

void function(whatever &ob) {
    ob.method();
}

function(myObject);

As you can see the need to convert the object into a pointer with & is now gone. That makes it much easier for people lacking in programming skills to use it since it hides the whole pointer mechanism from them.

Also, internally your function now treats ob as just another object using ., rather than a pointer to an object and needing to use ->.  Note that you can only use the reference operator in a function prototype, not a variable or anything like that - it's purely for passing objects and variables to functions.  If you want to then go and store the pointer in a variable you still then have to get the address:

void function(whatever &ob) {
    myObjectPointer = &ob;
}

As you see it gets confusing with the two different uses of &. Basically though: if it's in a function prototype it's the pass by reference operator. If it's anywhere else it's the get the address of operator (or a logical AND of course).

Storing the pointer can be useful if you want to then do other things later on with the same object, especially if you are yourself working with a class.  For instance, I often write code similar to the following:

class foo {
    private:
        bar *ob; // Pointer to other object of type "bar"
    public:
        foo(bar *inob) : ob(inob) {}
        foo(bar &inob) : ob(&inob) {}

        void something() {
            ob->doSomething();
        }

        void somethingElse() {
            ob->doSomethingElse();
            ob->evenMoreThings();
        }
};

You then have a choice of constructors:

bar myBar;
foo myFoo(myBar);

// ... later ...
foo.something();

or

bar myBar;
foo myFoo(&myBar);

// ... later ...
foo.something();

and the user doesn't have to remember which they need to use - whichever they try will work.


The size of the text file and the size of your compiled code are impossible to relate. The compiled size purely depends on what your code consists of, not the size.

To find out how much room your code will take on the chip you need to compile it. The IDE will then tell you how much flash and RAM it takes.

For example:

Sketch uses 3730 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 157 bytes (6%) of dynamic memory, leaving 2403 bytes for local variables. Maximum is 2560 bytes.


Why impedance between I/O pin and ground drops when Arduino is not powered

The Atmega328p (which is used in the Un[ (and actually all other AVR microcontrollers) has clamping diodes in the input hardware to protect it from overvoltage (above Vcc). When not powered, Vcc is at the same level as ground, so any positive voltage on an input pin is above Vcc. The protection diodes get conductive to protect the input hardware. Note, that the diodes can be fried easily, if a too high current flows through them. You should prevent that.
How to prevent it? By not doing it. You should never provide a voltage on an input of an unpowered chip (like any chip). If you really need to unpower the Arduino, you can prevent the voltage from reaching the input pin with a MOSFET.


How to increase the frequency of data transmission of SIM900A GSM Module connected to Arduino Uno?

There does not appear to be a complete description of how ThingSpeak throttling works.  However there is this text on the Thing Speak License FAQ web page:

As a reference, one unit provides the ability for a device sending
data to ThingSpeak at once per second to send data to ThingSpeak for
one year.

Assuming your code is working as expected and the ThingSpeak throttling is to suspend your service for 15 minutes, it may be that you are sending data faster than ThingSpeak will allow.
To test this, try to send messages slower than once per second.


Your code is absolutely correct. As I tested it with my Mega with Serial3 connected to GSM SIM900. I think there is something fishy about SoftwareSerial. Double-check the location of SoftwareSerial.

  C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src

Maybe you can see if RAM usage is exceeding the safe limit. Here is my output:


Sense checking Arduino Uno barebones schematic

You shouldn't put a capacitor under the chip like that. In fact I don't much like the layout of the whole crystal circuit at all.
You need capacitors on the 7805 regulator - around 10µF on both the input and output.
The RESET pin needs a pullup resistor otherwise the chip won't function at all.
You need decoupling capacitors on all VCC pins on your main chip.
Instead of meandering ground traces you should use a ground pour.
Running from the kind of voltages you propose the 7805 is going to melt. You will need a BigAss™ heat-sink on it. For those kind of voltages you would be better using a switching (aka buck) regulator. Maybe as an off-board module to keep your board simple.


How to program an Arduino pro mini using native serial port (on my mainboard)

To upload a hex file to Arduino over Serial interface, the bootloader must be active. The bootloader is active after reset. It waits a short time if a new application is uploaded. If not, it jumps to existing application.

To reset the MCU on Arduino boards with independent USB chip a circuit connected to DTR line of serial is used.

On a board like the Pro Mini there is no chip for USB neither an auto reset circuit. You must reset the board with the reset button right before avrdude sends the hex file. avrdude tries ten times, so you have 10 chances to time it right after you hit the Upload button.

Some USB-to-TTL-Serial adapters (or RS232 adapters) have the DTR line and it can be used to reset the board.

Or use ISP flashing over the ICSP header with a programmer or other board as programmer.


How to determine minimum and maximum angle for cheap servos?

I think you have 2 choices: either measure and store for each one individually, or find the worst case for all of them and code around that.

Do you really need the full travel? If you're using the servo to push/pull, the servo-travel endpoints are pretty weak anyway.

  I wanted a robot look left and look right, which is 0° or 180°.

Maybe you can make up the limited angular travel of the servo in the linkage between the it and the camera platform.


If the Arduino IDE identified your Uno as COM Port 3, your computer most likely has already assigned COM Port 3 to your Uno. You can double check the port assignment in Device manager > Ports.


sizeof doesn't return the number of elements. It returns the number of bytes. Since they are uint16_t arrays each element is 2 bytes - hence twice the size.

The reason your last number is only 40928 is because of integer wraparound. You only provide a 16-bit unsigned variable to store it in, so all you get is the lower 16 bits of the answer.

92000 + 40000 + 40000 = 172000

172000 in hex is 0x29FE0

0x29FE0 truncated to 16 bits is 0x9FE0

0x9FE0 in decimal is 40928.

  The RAM of Due is 96kb. Does this mean that with the initialization of only three arrays it's almost full? Ifi crossed the RAM limit, would the IDE throw an error?

It would, but you aren't actually using the arrays for anything, so the compiler threw them away.

  If i still need more RAM, can i use and external one with Due for high speed RAM acquisition?

There are ways of interfacing the SAM3X with external RAM, but I don't thing the Due exposes all the signals you need. I would change to a chip with more RAM, such as the PIC32MZ with 512kB of RAM and 200MHz operation.


Programming the ATMega328P without Arduino board always returns the error: avrdude: stk500_recv(): programmer is not responding

A new chip cannot be programmed in that manner until it has the Bootloader installed. The Bootloader starts after a reset and monitors the serial interface to see if something is attempting to download code via the serial port.

Selecting a Programmer has no effect on serial download, that only comes into play when Programming via the SPI pins SCK/MOSI/MISO/Reset/Power/Gnd.

Your "design" needs a couple more parts: 0.1uF caps between VCC and Gnd, and AVCC and Gnd.

The Cryslal and 22pF caps could also be a lot closer to the device - like right next to it.

I can't read the FTDI markings, so I can't tell if you have Rx and Tx swapped there.


From this Amazon review:

  There are 'live' (12V), 'ground' and 'signal' wires coming out of the
  back. Live and ground are pretty self-explanatory, and need to be
  connected to a 12V supply - I bought a simple 1A DC one. The final
  wire says 'signal', and needs to be connected to your circuit as input
  into a GPIO pin in the case of a raspberry pi. It produces a pulsing
  5V signal (Why not tell us it will be 5V somewhere in the
  documentation? Luckily I have a multimeter) as a way of encoding which
  type of coin it has encountered. However, raspberry pi's only want
  3.3V signals as inputs, so you'll be wanting to make a voltage divider (With a couple of resistors - I used 33k and 18k) to safely bring that
  5V pulse down to 3.3V. (http://en.wikipedia.org/wiki/Voltage_divider)
  You'll also want to connect the ground from the device to a ground on
  your Raspberry Pi, or the signal won't work. I did this by splicing
  the ground cable from the power supply so that it has 2 ends - 1 for
  the power supply to the unit, and one for the unit to the Raspberry Pi
  Circuit.

It seems that a 5v pulse is the expected output. How are you measuring the output? You'll need a 'scope rather than a multimeter measuring voltage...

Anyway, I would not try to 'amplify' the signal, I would look to check the connections are correct and if that's not the issue, I would return the unit as defective.


First of all there’s no negative resistance, resistance is a positive only measure, from 0 to infinity.

My best guess is you have your optocoupler the other way around, so you are measuring the input rather than the output: is that possible?


Your PCB is lacking in the majority of things you need to get the module working. These modules are not "simple" in that you provide power and forget about it. You must add all the required support components. Those support components are NOT optional. For example: you aren't setting the boot mode properly with the right pullups. You lack a capacitor on the power pins (I told you to add one already. Where is it?). Also your power traces are too thin. The impedance is too high.


Arduino IDE crash when I connect Blend Micro

you should try to run the arduino from the consolle, on windows digit cmd on the search bar and the command promp program should appear.

Well, then you should navigate in out arudiono folder: digit cd "XXX" where XXX is the arduino executable location (something like c:/program files/blabla), you can copy paste it from the folder explorer.

then write arduino_debug.exe and you should see on the terminal the error appear; with that we may find the issue.


Is not really connecting GPS to IMU, is more like you read GPS values, read IMU values and after apply what is called a sensor fusion algorithm.

One of the most common used sensor fusion algorithms is called Kalman filter (the Extended Kalman Filter more likelly). However, if you do not have some basis on control theory you may have more trouble in applying it.

here is a good example of use of this kind of sensors and fusion algorithms. It is also very commonly used in drones or autonomous vehicles.

The implementation will be specific to what you are trying to do.


The INA219 breakout will pass current, even if it doesn't receive any power itself.


I2C communication problem with two slaves (atlas scientific) and one Nano (official)

Two ideas.

1: Count your grounds. If you count more than 1 you have a problem. Your system should have a single ground, so ANY connection on every component labeled GND should be connected to ground.

The reason multiple grounds are a problem is that your signals (other than differential signals) are measured relative to ground, so if two components have different ideas of what "ground" is they start to disagree about what constitutes a 1 and a 0.

2: Scope your power supply. Check that your 5V supply is still providing 5V. It's possible (although unlikely) that the L7805ACV can't supply enough current and your system is browning out. If possible have a look with an oscilloscope to check for noise on the 5V supply.

Your boards should already have decoupling capacators, but adding another won't hurt, so also try adding a 0.1uf cap between 5V and GND to eliminate any noise.


Leonardo and micro: high pitch noise when powered from Vin

Yes, I've had this problem on a number of boards. It seems there are some faulty units coming out of the factory. I've had them replaced by my supplier, but I end up being sent more faulty boards.

It makes any kind of accurate ADC reading impossible.

A quick way to work out if your board has this problem

Place a jumper between 3.3v and A0
Put an analogRead in a loop and println the result
When powered by 5V you'll see a fairly constant value (around 670), varying by 1 or 2
When powered by 12V, if you have a faulty board, you'll see varying values, deviating by 50 or more.

There's a couple of solutions/workarounds to the problem listed here: http://forum.arduino.cc/index.php?topic=235729.0.


How do I feed NRF24L01 from Arduino Pro Mini?

can I feed NRF24 directly from Vcc pin?

NO: the pro mini is either 5V or not strong enough to power the RF24.
EDIT: the 3V3 pro mini "could" power the RF24 via VCC, if you use the cap and if it's not the PA&LNA model (or in full power mode). Best practise is to use an external regulator.

  if I fed NRF24 directly from battery and reduce 3.7V to 3.3V via
  another TIP122 transistor?

NO: lipos are 4.2V when fully charged, and they can be used until 3V (I mean 3V sag voltage, when the load is powered, not when disconnected): External 3V3 regulators is the way to go.

  Do you also think it is a reliable way of controlling the motors'
  speed?

These are PWM output, so yes, why not? Also, add flyback/freewheeling diodes (and -maybe- 100nF polyester caps should help) between the motors terminals.


Serial plotter isn't displaying my supplied data

You can't send arbitrary information (percent signs, text etc) to the plotter. The plotter only understands numeric values. You have to separate these number values from each other with commas, then do a println in your last value:

Serial.print(percent);
Serial.print(F(","));
Serial.print(tankPercent(depth));
Serial.print(F(","));
Serial.print(litres);
Serial.print(F(","));
Serial.println(tankLitres(depth));

In your case, it'd be simply:

Serial.println(DHT0.humidity);

You can go a bit further if you want to switch between either serial output, or serial plotter. In one case, I just set a constant variable for graph or plain data, then have a function for each (my above Serial statements are actually within a function called displayGraph()). The data function would be something like you had originally, example:

void displayData(float depth, float percent, float litres){

  // water level depth (inches)

  Serial.print(F("current missing inches: "));
  Serial.println(mixtureDistance());

  // cubic inches

  Serial.print(F("total cubic inches: "));
  Serial.println(TANK_TOTAL_CUBIC_INCHES);

  Serial.print(F("current cubic inches: "));
  Serial.println(tankCurrentCubicInches(depth));

  // litres

  Serial.print(F("total litres: "));
  Serial.println(TANK_TOTAL_LITRES);

  // ... etc
}

I also have projects where I use a switch that if on, sets a flag to output in serial graph format, and if off, uses the serial data routine.

Then, in your sketch loop(), you'd do something like:

graph
  ? displayGraph(depth, percent, litres)
  : displayData(depth, percent, litres);

...or a bit more verbose rather than using the tertiary operator:

if (graph){
  displayGraph(...);
}
else {
  displayData(...);
}

Here's a Q&D serial plotter example of my displayGraph() function above. In the top-right corner of the image, the four colours represent the four pieces of data I'm sending in, in order:

In my case, those represent the exponential moving average of the percentage of how full a liquid tank is, the second is the raw data I'm building that average on, third is the exponential moving average of how many litres are remaining in the tank, and lastly, again, the raw data for that average.

The sharp movements are simply me slapping the tank to get some variable and unstable readings for example purposes.


The reset pin of the ESP8266 has internal pull-up. Connecting the pin to ground activates the reset of the ESP.

To create a reset button, wire a momentary push button between reset pin and ground. Pushing the button will connect reset to ground, causing a reset of the esp8266.

The io 16 pin is connected internally to RTC, which in deep sleep counts down the time and then sets the pin LOW. If io 16 is wired to reset pin, this resets the ESP8266 to end the deep sleep.

The only way to end the deep sleep of the esp8266 is a reset. There is no conflict between RTC io 16 and a reset button, both wired to reset pin. Both can activate the reset to end the deep sleep.


Take a look at the HTTP specification:

Request       = Request-Line              ; Section 5.1
                *(( general-header        ; Section 4.5
                 | request-header         ; Section 5.3
                 | entity-header ) CRLF)  ; Section 7.1
                CRLF
                [ message-body ]          ; Section 4.3

Request-Line  = Method SP Request-URI SP HTTP-Version CRLF

You don't send the CRLF (carriage return, line feed) at the end of your request line and at the end of the header at the same time of the request. Why the delay?

You also miss the obligatory host header.

Host = "Host" ":" host [ ":" port ] ; Section 3.2.2


Using different processors when it comes to arduino

Sometimes faster and more powerful is not needed. If you just needed a simple timer, and it needed to be battery operated, a processor like the ATmega328 would be the better choice. It really depends on the application.

The ESP32 is a great device. But the A/D converter on it is less than stellar. It is not as consistent compared to the A/D in the Atmega328P.

The ESP32 is more fussy about the power supply requirements compared to the Atmega328P. Lots of people get themselves into trouble when they use poor design practices with the ESP32/ESP8266 modules. Poor practices that worked well enough for lower power and lower speed processors like the Atmega328P. Most people don't bother with reading the datasheet for the processors. They just try and copy stuff they fine on the Internet. And the Internet is full of poor quality information by people who don't really understand much of what they are working with.

If you want to start using the ESP32, then do yourself a favor and buy a working board with a power supply and not just buy a module. It will save you many hours of grief.

The Arduino IDE makes it easy to get stuff working. There also is Python, but it is less popular. There is a lot more information available for the Arduino IDE, and available libraries. And that makes development a lot easier. There are other ways, but the learning curve is much steeper.

The "Blue Pill" STM32F103C8T6 based board is a lot of capability for little money. The CPU runs on 3.3 volts like the ESP devices. It has gain a lot of popularity in the last few years but there isn't as much information as for the Atmega328P.

The STM32F103C8T6 and the ESP devices are 3.3 volt based designs. And they require 3.3 volt devices to interact with. There are some devices that are mostly 5 volt only devices. Like a character LCD. It is easier to interface that to a 5 volt processor.
There is lots that I could still say but it would take hours. But what you should do before deciding on a part is to decide what the needs of the project are. That will often guide you towards the part you should use.
One more note. The ESP devices are running a lot of code on top of the Setup and Loop functions. There is lots of stuff going on in the background to support the WiFi capability. And you don't have the kind of control that you could have with a non-ESP device. But if you want that part then you need to accept that limitation.


Interrupt and delay problems on Attiny 85

In short:

Arduino delay() is relying on millis().
The millis() function is  updated by timer ISR.
ISR handler blocks all other ISRs by disabling global interrupts.
No update for millis results into deadlock in delay if you use it in another ISR

And recommendation for ISRs? Do it as short as possible! Set some volatile flag and do the action later outside of ISR.


Compile problem when using keyword 'new' on Raspberry Pi

The Arduino uses AVR libc which does not provide a complete C++ environment.

Among other things AVR libc does not support new and delete. See the FAQ for more information.

Some versions of the Arduino libraries may provide new and delete but they are just wrappers around malloc and free. I suggest not using new and delete on arduino because they do not have the same behavior as C++. For example destructors will not be called on the arduino when delete is called.


How can I remove everything except for what is in the brackets from the string?

There are a number of String class member functions that can help with this. First, indexOf(val) will help locate the character of interest. Second, substring() will help cut out the part you want. And as a bonus, using lastIndexOf() will allow brackets within the string.

String s = "println('hello world')";
s = s.substring(s.indexOf('(') + 1);
s = s.substring(0, s.lastIndexOf(')'));

Cheers!


We can't tell you the "best" method.  It depends on too many details we don't have.

Here are some options:

A reed switch at the bottom of the hole and a magnet on the peg.
A photo sensor at the back of the hole -- the peg blocks the light.
As you suggest, a switch at the side of hole.
Use contrasting colors on the wall and the pegs and detect the pegs using a camera and some sort of image processing (not an Arduino solution)

I think you are going to need to build some prototypes and experiment to find the best option for you.


Error conecting raspberry with my arduino in a serial port

What's almost certainly happening here is that you've named your file serial.py, so the import is trying to load the library from your file within the current working directory.

To fix this problem, simply rename your serial.py script to something else, for example serial_comms.py or whatever other useful name you want.


Troubleshooting an Arduino Computer Program

You need to learn basic C syntax.

= is assignment, not comparison.

For comparison you use ==

https://www.tutorialspoint.com/cprogramming/c_operators.htm


How to reset arduino Mega 2560 code automatically?

avr-libc already has the appropriate functions created for you. Just include <avr/wdt.h>.

Sample usage

#include <avr/wdt.h>

void setup()
{
   wdt_enable(WDTO_8S);
   ...
}

void loop()
{
   wdt_reset();// make sure this gets called at least once every 8 seconds!
   ...
}


Switching 4.2V circuit with 3.3V Arduino GPIO

The MOSFET you chose will probably fail. Using a 30V device on a 24V system is asking for problems. Go to a minimum of a 60V MOSFET and use a UIS, Avalanche rated one. R4 is very week for what you need to do, I would suggest something in the 10K range to swamp out any leakage in the Arduino. If the MOSFET is properly rated the flyback diode is not needed but make a space for it incase you have to sub a MOSFET. Putting C2 in parallel with C1 will help. I do this a lot with electrolytics. I double up each one the needed size when one fails you don't notice it. I would suggest a couple of 220nF caps across the motor but that is application dependent.


The SoftwareSerial receive buffer is getting filled up and discarding characters. You are not reading fast enough from the buffer. Adding Serial.println() will slow down your reading even more. The simplest solution to this is to increase the size of the SoftwareSerial buffer from its default size of 64 bytes to 256 bytes (or smaller, depending on what works for you).

On a Windows PC, go to C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial. Open SoftwareSerial.h and change the line:

#define _SS_MAX_RX_BUFF 64 // RX buffer size

to

#define _SS_MAX_RX_BUFF 256 // RX buffer size

Save the file and try your sketch again.


The Nano boards that I have used all have pins on 0.1" (2.54mm) spacing.  There are single-row female connectors that are designed to accept 0.025" square pins.  One example is Samtec 32 position female header but there are many others.

Note that these female headers are available to accept either 0.018" round or 0.025" square pins.  My great preference is for the 0.018" round pins but those are less common in hobby circles.

The really huge advantage of the smaller round pins is that you can safely insert them into solderless breadboards without damaging the contacts in the breadboard.  But you would want to standardize on one style or the other.


avrdude: stk500v2_getsync(): timeout communicating with programmer error

I get this problem sometimes with some of my boards. I usually solve the problem following these steps:

Set the compiler on debug/verbose mode to see what's happening
Launch compilation/upload
When the compile phase is done, and the upload process is about to start, press the reset button on the board

Usually that takes care of the problem.


How to wait Arduino ready with ANY method?

Again, you're not waiting for the bootloader to complete before sending your text:

port.open(argv[1], std::fstream::in | std::fstream::out);
// Board resets and enters bootloader

port << argv[2] << endl;
// You send argv[2] to the bootloader

port >> answer;
// The bootloader doesn't understand what you sent so doesn't reply with anything

You must wait for the bootloader to complete before sending ANYTHING to the Arduino.

The two ways you can do that are:

Insert a sleep(3); immediately after opening the port to give the bootloader a chance to time out and start running your sketch, or
Provide an initial "I Am Ready" message from your sketch that your C++ program waits for before sending the text you want to send to elicit an answer.


Firmata: strings sent from the computer become damaged after Arduino

You have to understand the Firmata protocol to write your own client library. The spec is here: https://github.com/firmata/protocol.
In this particular case, you need to know that data that is sent (the string in this case) can never use bit 7 of the data, since these values have special meanings. Therefore, Firmata sends every byte as two bytes, first bits 0-6 and second bit 7 as bit 0 of the next byte. Therefore, the conversion to UTF-8 is not sufficient. You need to do a two-byte-per-8-bits encoding. The same applies for the reply.


How to move from arduino to physical prototype

The best thing to do is, of course, to use a PCB. But it doesn't need to be a custom PCB; there are plenty of pre-made PCBs that are usable for approximately 98% of designs. Here are just a few:

Adafruit Perma-Proto boards are connected just like breadboards, so direct transfer is possible.
BusBoard proto boards come in a ridiculous variety of configurations, including enclosure kits, and they even have SMD boards if you're up to it.

For switches just use a panel mount form. They come in everything from simple to robust to ridiculous.

LEDs can also be panel mount, or you can use a light pipe to make a LED on the PCB visible from the outside.

For power you can use a USB connection or a separate power jack with a voltage regulator. If you also need a serial connection then you should consider a pre-made serial module, and either use its built-in USB jack or a separate panel mount USB jack.

The servo can be mounted inside the case if appropriate, or can be connected to a PCB mount or panel mount connector instead.

Naturally the MCU itself should also be placed in a socket directly on the PCB. Don't forget the decoupling, the oscillator, and the ISP connector.

As for the circuit itself, you can get rid of the pullup resistors on the switches if you use internal pullups instead. And 100ohm is way too low a value for switch pullups regardless.


Why do I get different results when compiling the same code with different ide?

Different compilers produce different machine code.
As Majenko pointed out, the Arduino IDE's compiler, which happens to be GCC, uses float even when you write double.
The Atmel Studio creates double for double, using twice as much bits.
Calculating with more bits takes longer.


Read sd card content(text files) and display it on lcdi2c

Well The Do You Really Have an i2c module connected to the display you can find this out by checking how many pins the display has if it is not four pins then you need the LiquidCrystal Library If Not Then The Arguments Passed To The LiquidCrystal I2c Function Should Be The Address Witch Should Be 0x27 If You Did Not Modify The i2c Module(Next Time Give The Circuit Schmatics )


Pass a member function pointer to a method of a foreign class (EDB Lib)

The problem here is a common one with C++.  It basically boils down to how C++ handles member functions.

You define a member function as, say,

class myLib {
    void myFunc(int val);
};

When you call the function it's actually not defined as that - it's instead had its definition change to:

void myFunc(myLib *this, int val);

The addition of the myLib *this is an implicit parameter, and it's how C++ keeps track of its object instances when calling different functions.

So a function which expects a parameter of void (*func)(int) won't accept your method because it's actually void (*func)(myLib *, int).  Hence the error you are seeing.

There is no easy, clean, way around it that I have found as yet, I am afraid.  The closest you can do is to move the reader and writer functions outside of your class and store a global pointer to the actual class, something like:

static myLib *globalLib;
void globalConfigWriter( unsigned long address, byte data ) {
    globalLib->congigWriter(address, data);
}
byte globalConfigReader( unsigned long address ) {
    return globalLib->configReader(address);
}

Then in the constructor for your lib you can do:

myLib::myLib() {
    globalLib = this;
}

You then register the global reader and writer functions with the EDB constructor instead of the class member functions.

It does have the rather major down-side that there can only be one instance of your class since there is only one global pointer and only one pair of reader / writer functions.  There are ways of supporting a finite number of instances, but it basically involves having a reader/writer pair for each instance and allocating one to an instance when it's constructed and de-allocating it when its destructed.  Keeping track of them and knowing which object is associated with which function pair is tricky at best...


How to wake up Arduino Mega when in Power Saving Sleep Mode?

It is certainly tempting to go into a very deep sleep in order to save
power, but you still need to keep awake whatever peripheral you want to
use as a wakeup source. If you want to use a 16 bit timer, there is no
other choice than SLEEP_MODE_IDLE.

But it may not be that bad. In IDLE mode you can selectively disable the
clock (and hence put to sleep) the peripherals you do not use. Or maybe
put them all to sleep, and then wake up the few ones you do need. This
is achieved with the power_*_disable() and power_*_enable() family
of functions.

In the edited code below: all peripherals but the Timer 1 are disabled
while the CPU sleeps. The USART is enabled only for the time it needs to
send its message:

#include <avr/interrupt.h>
#include <avr/power.h>
#include <avr/sleep.h>
#include <util/delay.h>

const uint16_t PERIOD = 2150;  // 34.4 ms

void setup()
{
  // Disable all but the needed peripherals.
  power_all_disable();
  power_timer1_enable();

  // This is for debug pulses.
  pinMode(22, OUTPUT);

  // Configure Timer 1 to wake us up every 34.4 ms.
  TCCR1A = 0;            // undo the timer config done...
  TCCR1B = 0;            // ...by the Arduino core library
  TCNT1 = 0;             // reset the timer
  OCR1A = PERIOD - 1;    // set the period
  TIMSK1 = _BV(OCIE1A);  // enable TIMERx_COMPA interrupt
  TCCR1B = _BV(WGM12)    // CTC mode, TOP = OCR1A
         | _BV(CS12);    // ...and set the prescaler /256

  Serial.begin(9600);
}

ISR(TIMER1_COMPA_vect)
{
  // Send a debug pulse.
  digitalWrite(22, HIGH);
  _delay_ms(2);
  digitalWrite(22, LOW);
}

void loop()
{
  // Enable the USART only while needed.
  power_usart0_enable();
  Serial.println("Program is on");
  Serial.flush();
  power_usart0_disable();

  // And go to sleep in IDLE mode.
  sleep_mode();
}

Notice also that the ISR does not print to the serial port: it just
sends a debug pulse to watch with the scope. This should be removed from
production code. The delay is achieved with the avr-libc function
_delay_ms() because the standard Arduino delay() would not work: it
relies on Timer 0, which has been disabled.


Using that pin configuration you'll have several problems despite you'll use enable pin.

I would use a I2C module for 16x2 lcd like this https://www.amazon.com/SainSmart-Serial-Module-Display-Arduino/dp/B00813HBEQ

Control 16x2 lcd with I2C.


using a switch case with a 5-position switch and serial output

When you want to perform actions in response to button presses, you
should take care of reacting to the signal edges rather than levels.
In other words, you perform the action only when the signal changes from
LOW to HIGH, not every time you see it HIGH.
You should also read about button bounce, and either implement your own
debouncing or use an existing library. Below is an example using
Bounce2, but there are other options:
#include <Bounce2.h>

const uint8_t pinDim    = 3;
const uint8_t pinMedium = 4;
const uint8_t pinBright = 5;

Bounce buttonDim, buttonMedium, buttonBright;

void setup() {
    buttonDim.attach(pinDim, INPUT);
    buttonMedium.attach(pinMedium, INPUT);
    buttonBright.attach(pinBright, INPUT);
}

void loop() {
    buttonDim.update();
    buttonMedium.update();
    buttonBright.update();

    if (buttonDim.rose()) {
        Serial.println("dim");
    }
    if (buttonMedium.rose()) {
        Serial.println("Medium");
    }
    if (buttonBright.rose()) {
        Serial.println("bright");
    }
}

You could also, as suggested in Michel Keijzers' answer, use arrays for
the pins and Bounce objects. While these would help streamline the
calls to attach() and update(), they will not help with the meaty
part of the code, i.e. reacting to the presses. There, I would prefer
the button to have descriptive names.


Does Arduino.cc silkscreen the pin headers? What explains the differences here?

No, there is nothing that documents the differences as in a changelog, purely because this is not an iterative change.

The two boards are designed and manufactured by two different (competing) companies in two different countries (USA and Italy) using different component suppliers.

Just because they both say Arduino UNO doesn't make them both the same board - not these days anyway, since the founders of Arduino got really childish and started throwing their faeces at each other like monkeys in the zoo.


Installing Ports for Arduino Nano on Mac OS X Yosemite

Had exactly the same problem. Also using 10.10 and just got an Arduino. What worked for me was using a different cable. The one that came with my Arduino Uno only provided power not data. If you have a printer, it might have the right cable, just test it quickly.

Edit: In addition, whilst trying to find solutions, I also installed 64bit mac FTDIUSBSerialDriver_v2_2_18.dmg. I'm not sure if it made a difference. As after installing it and using the original cable the problem persisted.


Replace the line:

  if (A0 == HIGH) {

by this one:

  if (digitalRead(A0) == HIGH) {

If you plan on using the pin back as an analog input, use something like this:

  if (analogRead(A0) > 512) {

The explanation is what Ignacio said: you were comparing the pin "name" A0 directly to HIGH instead of reading from the input named A0. To make it clearer, the two lines are equivalent:

if (A0 == HIGH)
if (0 == HIGH)

Get it?

There's more about what pin names to use with digitalRead() and analogRead() here:

analogRead(0) or analogRead(A0) at EE.SE.


How to know if my Bluetooth HC-05 is connected through serial monitor

If your board is actually a HC-05, you can

Pull the KEY pin to Vcc (see note)
Write the serial command AT on the serial interface
Look at the output: if you receive AT or OK then the module is connected, otherwise it is not

Note: The key pin is the number 34 on the SMT module (with the antenna pointing upwards, its the pin in the top-right corner). If you have a THT module (so the one with about 6 pins) MAYBE this pin is connected to one of the pins you don't usually use (they are named EN, STATE, ...). Check with a multimeter if it is connected to one of these. If it is not, then you'll have to solder a wire from it to an arduino pin.

If, on the other hand, your board is a HC-06 (almost identical to HC-05, but with a different firmware - it is a slave-only bt device), then keep it disconnected from the master and perform steps 2 and 3: when not connected, in fact, the HC-06 is already in AT mode.

More information on this webpage


Yes, your thinking is pretty much correct.

You can place an ATMega32U4 chip and the associated required circuitry within your own circuit design. The required circuitry is actually quite simple - a crystal for the CPU clock, a few capacitors (load capacitors for the crystal, and decoupling), two 22Ω termination resistors for the USB bus, and a 10KΩ pullup on the reset pin. That's about it (besides power of course).

As far as programming goes, you can either install a bootloader (butterfly - like the Leonardo etc) that works through the USB, or you can directly program the chip using ICSP. It's best to provide an ICSP header anyway (it's the SPI pins plus RESET basically), and if you have done that (which you'd need really to be able to get a bootloader on there) then you may as will skip the bootloader entirely and just program direct through the ICSP header. Of course, you'll need some kind of programmer (an Arduino can do the job at a pinch, but it's worth spending the $10 to get a cheap AVR programmer from eBay).


Yes possible, but the ESP8266 only has one core and one set of peripherals. WiFi uses time, interrupts, and even the ADC peripheral, and maybe more.
This is why anything timing-critical, or time-intensive, is a pain to get to work properly on an ESP8266. It depends one what you are trying to do, of course, and also on if you can unload what you want to a peripheral the WiFi doesn't use, or if switching off WiFi is an option during parts of your code.
Generally, for applications such as yours, I would get an ESP32 or an Arduino Nano 33 IoT or any other solution that has a core for handling WiFi, and a core for you to use without restrictions. It makes development a more pleasant experience.
If, for some reason, you are bound to using an ESP8266, you would have to be more specific about what your eventual goal is; maybe a workaround can be found.


LSM9DS1 breakout - How to increase speed

Check the header of the library,

you will find readAccel readMag readGyro and readTemp in separate public functions and looking at the implementation of read it just calls those 4 in sequence. readAccel will update the accelData member field.

So you can just call lsm.readAccel() in the loop and then grab lsm.accelData directly and ignore the rest.

void loop()
{
  lsm.readAccel();
  accelX = lsm.accelData.x;
  accelY = lsm.accelData.y;
  accelZ = lsm.accelData.z;
  rms = (accelX*accelX)+(accelY*accelY)+(accelZ*accelZ);
  Serial.println(rms);
}


card.init(SPI_FULL_SPEED,SD_CS_PIN) returns false for Arduino Mega

53 is a SS pin if the Mega is SPI slave. Pin 10 is connected to shield to select it as a listening slave. So let the parameter set to pin 10. Additionally on Mega set pin 53 to output, otherwise the Mega can 'fall' into SPI slave mode.

SPI pins 50, 51 and 52 are connected to the ICSP header too. The 6 pin ICSP header is on the same place relative to Uno an Mega common pin headers.


Can Android phone can be used instead of( or with) Arduino as controller?

You cannot directly control your RC car using and Android phone if you are talking about a normal RC car. If you have an RC car that can be already connected via bluetooth this is another story.

So for normal RC car you would need to have:

AndroidPhone -> Network -> AndroidPhone -> SerialInterface -> Arduino -> RC


Where can I find a hardware manual (or documentation) for Arduino board?

The Arduino Uno is little more than an ATmega328P microcontroller. In
most cases you will be interested by the documentation of the
microcontroller itself. Anyway, here are both:

The Arduino Uno product page contains the most basic specs, as well as links to

the board schematic
the pin mapping, but see below for a nicer alternative

the ATmega328P product page links to

the ATmega328P datasheet, a 650 page authoritative document
the AVR instruction set manual, for those who want to play with assembly
many application notes discussing specific uses of some peripherals

Alberto (aka PighiXXX) has published nicer versions of the Arduino Uno
pinout.


I usually use female headers pointing straight up off the board because they accept the most common double-male breadboard wires. The downside is that their mechanical connection to the board is not terribly stable due to the board-end pins being little bitty extensions of the sheet-metal socket inside the header.

Male headers are much more stable, and a handful of male-female breadboard wires will connect them to a breadboard. The downside of going this route is it invites JRobert's Law of Erroneous Selection: whenever you have more than one kind of similar component, the first one you pick will always be the wrong kind.


Which arduino should I start on to learn about it?

I would simply say: buy a startkit like this one.At the end it is not important which Arduino board you'll start. They are (almost) the same*. At the very beginning you can start with Uno or Nano and even Leonardo could be very good. Those boards are very similar and you can program them in the same. Even the pins location and designation is not really different.
The most important thing about Arduino is to understand how to work and program and interface such a board with the sensors. In this sense I would choose a Uno board (or even 2009) which is less expensive and very easy to find overall. I don't really know how much experience you have, but it is likely, at the beginning, that you invert polarities of batteries, you drain too much power, or you invert some pins and damage the microcontroller. In that case doesn't make sense to buy the last powerful mega expensive board on the mark. If you get a Uno you can do almost everything and have for the next month a lot to learn.

To change from Uno or Nano to the other board it is not very difficult. Once you understand the basis you can switch to every board you want. If you need more power and memory you can buy a Mega. If you need much more power you can buy a Due/Tre/etc...you need just an upgrade not everything from scratch to learn.

If you are really new to Arduino the best way is to buy such a learn package as I showed you above. That have everything you need to understand basic of programming till to RC-Servo movement and motor drivers.

Happy new year.

*: stay away for the moment from the Arduino Due/Tre/Zero/Yuan/.. series. they are too expansive and require a lot of attention (3.3V, max drain current from the pins, pull up, pull down...etc..). Here is the risk to get your board damaged within few time very high. And you'll spend a lot of time thinking that the board has some problems.


if (pinOn = 0) is doing an assignment (single =) not a comparison (double ==), so pinOn is begin set to 0 each time through the loop. The result of an assignment is the value being assigned. So it's the same as if ( 0 ), which is false.

Now, on to the two branches. pinOn + 13 is a statement and the result is not being assigned to anything. You need an equals sign somewhere:

if (pinOn == 0) { // == means "is equal to"
  pinOn += 13; // same as pinOn = pinOn + 13
}
else {
  pinOn -= 1;
}


The Arduino forums talk the Arduino resetting when the serial port is opened. A solution as stated in the forums is to add a short delay. See if that works.
Source: http://forum.arduino.cc/index.php/topic,18371.0.html


LCD is not printing strings, only integers with Arduino

Whenever I use an LCD display I make sure to use the I2C backpack.  It takes actual effort to hook it up wrong if you use them.  So if this were me, I would desolder all those pins and get one.

Here is a good description of how they work:
https://learn.adafruit.com/i2c-spi-lcd-backpack/overview


Connection from Arduino Uno to Microsoft SQL Server Database

Using a layer between Arduino and MSSQL might give you the least headache. Would you like to do this on-premise or in the cloud?

For an easy cloud approach, look at AWS Lambda. Write a Lambda function that inserts into your MSSQL database, possibly running on AWS too. Your choice of Java, Node.js, C#, or Python. Hook it up with incoming MQTT messages from your Arduino.
https://stackoverflow.com/questions/33165045/aws-lambda-and-sql-server-integration
 could help.

For a cloud-free approach, you could run your own local MQTT server (broker, to be exact, Mosquitto being the most popular), and have your C# subscribe as an MQTT client. When the Arduino publishes a fingerprint signature, your C# script can do the database work.


The Arduino paradigm is based on abstracting the hardware to a few simple function calls.  So many drivers appear simple to the end user (end programmer).

Most go here for a list of libraries (which have already been written) and how to use them.  I believe these libraries are distributed with the Arduino SDK.  To learn more about writing libraries go here. I am not aware of any formal method of submitting Arduino libraries.  If I wanted to find out more I would go here and participate in the forum.  However, using the forums search, I found this specific (several years old) post where it says:

  You can add a page to the Playground section:
  http://playground.arduino.cc/ You might start by adding your website
  with Arduino code to the index of the playground, perhaps a page in
  the Playground section is not needed. The index can contain links to
  websites, to the Arduino forum or to a page in the Playground section.

  You can not change or add to the reference or official libraries.


Serial ports(in 1.0.5 & Port in 1.6.11) is greyed out under tools

Information on a “Serial Port Setup” page at fedorahosted.org should be adequate to sort the problem manually.  Here are a few snippets from that page, along with notes about application to the current problem.

• Use command ls -l /dev/ttyUSB* to find out the serial port's group.  For example, on my Ubuntu system that shows

crw-rw---- 1 root dialout 188, 0 Aug 20 11:13 /dev/ttyUSB0

Note, substitute for ttyUSB if the port you're concerned about doesn't start with that.

• Use command groups to find out which groups you belong to.

• The fedorahosted page says to use command sudo adduser (username) dialout to add dialout to your groups list.  I haven't tried that approach, and would be more inclined to instead try sudo usermod -a -G dialout (username) [where  “(username)” represents your username].


Most probably you are using sim900 or sim800 module. These modules would be either fixed to a certain baudrate like 9600 or 115200, OR the module might be at auto-baud mode.

In auto baud mode you need to send AT\r to the modem after the modem is switched ON so it can know what baud you are using.

Please check the following...

GSM Modem/Module not responding to AT commands after firmware Upgrade??
Serial port AN


Well, your PWM outputs are both on 16b Timer/Counter 1 and the servo is attached to the 8b Timer/Counter 0. So my guess is that 8bit counter has too low resolution for driving the servo and it uses Timer/Counter 1 in full 16b mode for better precision instead (PWM uses just 8bits from 16). Also Timer/Counter 0 is used for counting millis, so its settings can't be changed anyway.

For the confirmation you can either:

use pins 5 and 6 (TC0) or/and pins 3 and 11 (TC2) and for the servo use pin 9 or 10
You can read the values of TC1 configuration registers and according to the datasheet you can figure out what mode is currently used.

EDIT:
So on the Uno board is used Timer/Counter 1 for timing purposes:

  if(timer == _timer1) {
    TCCR1A = 0;             // normal counting mode
    TCCR1B = _BV(CS11);     // set prescaler of 8
    TCNT1 = 0;              // clear the timer count
    TIFR |= _BV(OCF1A);      // clear any pending interrupts;
    TIMSK |=  _BV(OCIE1A) ;  // enable the output compare interrupt
    timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
  }

So no PWM on the OC1A nor OC1B in normal mode and the channel A is taken by Servo.


In C/C++ you either use the #include pre-processor statement in the form of

#include "someFile.h"

or

#include <someFile.h>

The form

#include <"someFile.h">

is not legal. You must correct it to one of the two forms above.

The difference between those forms is explained in https://stackoverflow.com/a/77092/5296568.


Having trouble figuring out CTC on Timer 1 with ATTiny85

The only explanation I have is, that the Software serial switch off the interrupts globally when it operates (print). If interrupts are locked when the timer completes, you loose a tick. It does not explain the different behavior of the four value pairs, but there are some issues reported in a german forum. They did not find an answer, but the assumed it depends on the 'delay()' function, that is used for the software serial and the fact that the interrupts are locked to make the delay function more exact.

If you want to be sure, you can try this by completely removing the Software Serial from your program. If you make the values switchable by e.g. a button press you can change it without having to reload the program. Then it's easier to see different  blinking intervals.

int ledPin = 1;
int state = 0;

int regValues[] = { 0x8f, 0x8e, 0x8d, 0x8c };
int cntValues[] = { 30, 61, 122, 243 };

const int buttonPin = 2;
int buttonState = LOW;

long lastDebounceTime = 0;
long debounceDelay = 80;
int lastButtonState = LOW;

int pairIndex = 0;

void setup()
{
  TCCR1 = regValues[ pairIndex ];
  OCR1C = cntValues[ pairIndex ];

  TIMSK = (1 << OCIE1A);

  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

ISR(TIMER1_COMPA_vect)
{
  state = !state;
  digitalWrite(ledPin, state);
}

void loop()
{
  int reading = digitalRead(buttonPin);

  if (reading != lastButtonState)
  {
    lastDebounceTime = millis();
  }

  if ( (millis() - lastDebounceTime) > debounceDelay)
  {
   if (reading != buttonState)
   {
      buttonState = reading;

      if (buttonState == HIGH)
      {
        if ( ++pairIndex > 3 )
        {
          pairIndex = 0;
        }

        TCCR1 = regValues[ pairIndex ];
        OCR1C = cntValues[ pairIndex ];
      }

    }

  }

}

I wrote this code without having a attiny to testing it. So hopefully all is correct. If you would try it, can you please report any errors, so I can correct them?


Let's see which device uses which communication protocol:

WiFi Module (ESP8266 ESP-01) uses Serial communication.
RTC (Real Time Clock - DS1307) uses I²C communication.
RFID Reader (RC522) uses SPI communication.
SD Card Module also uses SPI communication.

Now, the Arduino UNO supports One I²C, One SPI and One Serial (by default) communication port.

So, you can easily connect your Wifi and RTC modules.

Now, actual problem is: "How to access multiple SPI interfaces on Arduino" (and that is a solved problem).

Hope it helps and you don't have to buy an Arduino MEGA.


Reducing read time for reading DS18B20 temp sensors

Doing a search every time is quite inefficient. The search function is for if you don't know the device address - and it takes a while to do. In your case, presumably the addresses will never change. Find the addresses and hard-code them into your code. Or if that isn't practical, store them in EEPROM. And if even that isn't practical find the addresses once in setup.

Next, you need a delay while you take the temperature readings. Why not parallel those up? In a loop, tell all the devices to take a reading. Then wait one second. Then read them all (in another loop). That way the one-second delay is shared between all your sensors.

However from the page Gerben linked:

  And it is NOT possible to run DS1820 sensors on a simple pull-up resistor. During the "Conversion" phase, it needs more power. And there are Application Note discussing this in length.

That suggest that if you are using parasitic power, my suggestion won't work too well (having multiple devices taking readings would make it worse).

I found this code on my disk from a couple of years ago. There don't seem to be any delays between reading sensors. There is a delay at the end of the main loop, mainly to stop spamming the serial monitor.

Notice the comment:

  Call sensors.requestTemperatures() to issue a global temperature request to all devices on the bus

See if that works for you.

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Streaming.h>

// Data wire is plugged into port 10 on the Arduino
const byte ONE_WIRE_BUS = 10;
const byte TEMPERATURE_PRECISION = 10;
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress myThermometer [10];
int deviceCount;

void setup(void)
{

  // start serial port
  Serial.begin (115200);
  Serial << "Dallas Temperature IC Control Library Demo" << endl;

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial << "Locating devices..." << endl;
  deviceCount = sensors.getDeviceCount();

  Serial << "Found " << deviceCount << " devices." << endl;

  // report parasite power requirements
  Serial << "Parasite power is: " << (sensors.isParasitePowerMode() ? "ON" : "OFF") << endl;

  // method 1: by index

  for (int i = 0; i < deviceCount; i++)
  {
    if (sensors.getAddress(myThermometer [i], i))
    {
      Serial << "Device " << i << " Address: ";
      printAddress(myThermometer [i]);
      Serial << endl;
      sensors.setResolution(myThermometer [i], TEMPERATURE_PRECISION);
    }
    else
      Serial << "Unable to find address for Device " << i << endl;
  }  // end of for loop

}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

void loop(void)
{

  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  sensors.requestTemperatures();

  // now get all temperatures
  for (int i = 0; i < deviceCount; i++)
  {
    float tempC = sensors.getTempC(myThermometer [i]);
    if (tempC > -80)
    {
      Serial << "Device " << i << " Temperature: " << tempC << endl;
    }
    else
      Serial << "Unable to find temperature for Device " << i << endl;
  }  // end of for loop

  delay (1000);
}


Arduino resets when I call network.begin()

The problem was that the RF24Network library is not compatible with the version of Arduino IDE I have. I downloaded Arduino IDE v1.0 and now it works like a charm. I will send an email to maniacbug to tell him about the problem.


Can be many causes since you did not provide more info (like what circuit, what application). But in general:

Wrong software installation
Try another similar chip/device, maybe this one is broken
Is it recognized by USB at all?
Bad USB cable
Did you select the right board in the IDE (Arduino IDE?)

Possible solution:

Reinstall IDE
Change chip
Change Arduino
Use different cable


Servo doesn't move if I detach it AFER the write?

The detach() function probably stops the data pin from outputting the servo control signal.
Your code disables the control signal a few microseconds after it is enabled.
The cotrol signal is never generated.
Furthermore, a servo requires the signal to be present at all times for it to keep its position.
When your programming includes real-world events, you have to think about the time frame of the events, and about the time frame of the running program.
Think in the terms that the program can loop 100,000 times before the servo has finished moving.


Your code doesn't do what you think it does. The timer always runs at 244Hz, and OCR0B only matches twice per period, causing it to have the same frequency but a different phase. What you need to do is set OC0B on compare match and clear it in the overflow ISR. OCR0A you can simply set to toggle on match.

TCCR0A = _BV(COM0A0) | _BV(COM0B1) | _BV(COM0B0) | _BV(WGM01);
TIMSK0 |= _BV(OCIE0A);

 ...

ISR(TIMER0_COMPA_vect)
{
  PORTB &= ~_BV(PD5);
}

Also, OC0A is D6, not D4.


Arduino MKR 1010 WiFi as BLE central/client

In case this thread turns up in a search, the ArduinoBLE library now includes central and peripheral support.


Arduino Code for Pulse Skip Modulation (PSM)

Just adding to chrisl's answer since I bought this module, too.

There is a simple example on the manufacturers website of this module which does not seem to implement PSM the obvious way:

/*
Connect RobotDyn AC Light Dimmer as follows:
Dimmer pin  --  Arduino pin
    VCC     --    5V
    GND     --    GND
    Z-C     --    D2
    PWM     --    D3

Glow sketch for AC Voltage dimmer with Zero cross detection
Based on the sketch by Charith Fernanado
Adapted by RobotDyn: http://www.robotdyn.com
License: Creative Commons Attribution Share-Alike 3.0 License.
Attach the Zero cross pin of the module to Arduino External Interrupt pin
Select the correct Interrupt # from the below table (the Pin numbers are digital pins, NOT physical pins: digital pin 2 [INT0]=physical pin 4 and digital pin 3 [INT1]= physical pin 5)

Pin    |  Interrrupt # | Arduino Platform
---------------------------------------
2      |  0            |  All
3      |  1            |  All
18     |  5            |  Arduino Mega Only
19     |  4            |  Arduino Mega Only
20     |  3            |  Arduino Mega Only
21     |  2            |  Arduino Mega Only

In the program pin 2 is chosen
*/
int AC_LOAD = 3;    // Output to Opto Triac pin
int dimming = 128;  // Dimming level (0-128)  0 = ON, 128 = OFF

void setup()
{
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

// the interrupt function must take no parameters and return nothing
void zero_crosss_int()  // function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle) For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65

  int dimtime = (75*dimming);    // For 60Hz =>65
  delayMicroseconds(dimtime);    // Off cycle
  digitalWrite(AC_LOAD, HIGH);   // triac firing
  delayMicroseconds(10);         // triac On propogation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // triac Off
}

void loop()  {
  for (int i=5; i <= 120; i++){  // We use 120 as the lowest and 5 as the highest brightness setting. May be adjusted depending on the lamp used.
    dimming=i;
    delay(20);
   }
  for (int i=120; i >= 5; i--){  // Same as above
    dimming=i;
    delay(20);
   }
}

They are using an interrupt as suggested by chrisl.
There is no flickering present with low dim values (using an incandescent bulb).
See this video for a similar board with the original version of the above sketch.

Note: If you want to integrate your own code into this example, it will likely not work as intended because the Arduino is busy with delayMicroseconds() most of the time

EDIT: The manufacturer of this module just released a library. Check it out on their github


Arduino won't send serial data if connected with external power supply

Solution : The Arduino worked perfectly. When you connect the Arduino with an external power supply the Tx and Rx lights won't light up, Even when they are transmitting or receiving.

I'm adding this as the solution to stop this being re-added as an unsolved problem.

That is correct. The Tx and Rx LEDs are connected to the Atmega16U2 processor, and thus only flash if there is serial comms via USB.


Can I turn off a device using the 5V and analog pins?

You would use a transistor. Something like this would work.

In this case the Arduino controls a transistor to drive a brushless motor.

Source: Arduino Cookbook: (https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-8/figure-8-9)

Update:
For the sake of clarity I should point out that the TIP102 is the device to use for the 1A required (not the 2N2222). And as pointed out by others the 5V supply of most Arduino boards would not be sufficient to supply 1A, so an external supply would be advised.


Getting negative results from calculations

analogRead() returns a number from 0 to 1023, and you want to convert that to a range from 0 to 255? One easy way would be to simply divide the reading by 4.

On a more general note, given that the numbers will (should!) never be negative, there's a flavour of int called unsigned int. By using that:

unsigned int val = analogRead(...);

you can cover a range from 0 to 65535 instead of int's -32768 to 32767. That will give you a little more head room - but not enough to multiply the maximum value 1023 by 255 first.

There's also another type long. That covers the range from -2 to 2 billion (and a bit), while unsigned long goes from 0 to 4 billion (and a bit) - but that uses a LOT of processing for the poor Arduino to work with.


Arduino Nano + RFID RC522 + Ethernet shield W5100

I had almost exactly this situation with one of my projects.

The problem is that some Serial Peripheral Interface (SPI) devices don't properly put the MISO pin into high-impedance when SS is pulled high. I eventually resolved this by placing a tri-state buffer in the MISO line for each of the SPI devices.

I used a 74HC125 (4-channel tri-state buffer).

This is the page on Better SPI Bus Design in 3 steps that finally got me on the right track. I think the explanations are reasonably clear (at least compared with many other sites I found!).


exchanging data between two hc05 bluetooth modules

I think there is no simple answer for that. First you have to pair 2 HC-05 modules. To do so, you have to configure one HC-05 as slave, and other HC-05 as master.

Steps for SLAVE:

Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.
Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)
Note the values of AT+PSWD?, AT+NAME? and AT+ADDR?(let's say 1111:22:123456) commands. You might set the password to 1234 for easy remembering. Issue AT+PSWD=0000...
Be sure to set the module to slave mode by issuing AT+ROLE=0 command.

Steps for MASTER:

Be sure to select correct Baudrate in your Terminal Emulator (Arduino IDE or Terraterm etc.) for your module. There is no default baudrate... Different manufacturers set the baudrate on their HC-05's differently... 9600 and 38400 are good starting points.
Enter AT mode, by providing high level(3.3V or 5V) signal on KEY pin(PIO11)
Reset the module to its original state by issuing AT+ORGL command.
Remove the previous parings(if any) by issuing AT+RMAAD command.
Set same password as slave by issuing AT+PASSWD=0000 command.
Change the role to master; AT+ROLE=1
Set connecting mode to any address it sees; AT+CMODE=1
Initialize the SPP profile lib ; AT+INIT
Be sure that you see the slave HC-05 module, AT+INQ command will list the modules you see.
Be sure that you see address of the slave module(1111:22:123456).
Last of all enter AT+LINK=1111,22,123456(note the commas).

With these steps you should exchange data...


In the Nano Every schematic, PF2 and PF3 are connected over to PA2 and PA3 respectively.  That is, Arduino pin A5 and ATMega4809 pins PF03 and PA03 are connected together by PCB traces such that there's no distinction between them, PF03 doesn't have its own header pin anywhere distinct from PA03.  They're both A5.  Likewise for Arduino pin A4 and ATMega4809 pins PF02 and PA02.
The Nano Every was designed to be compatible with the original Nano boards that used the ATMega328P.  On these boards the A5, analogRead-capable pin, is also the I2C/Wire clock signal.  Likewise,
A4, analogRead-capable pin, is also the I2C/Wire data signal.
On the ATMega4809 the I2C/Wire Master/Slave signals on PORTA routed to the A5 and A4 pins are not also analogRead-capable.  That is, they are not connected to the analog-to-digital converter in the chip as they were in the Atmega328P on the old Arduino Nano boards.
To mirror the workings of the original Nano, where A4 and A5 were both analogRead pins and I2C/Wire Master/Slave pins, they connected A4 and A5 to pairs of ATMega4809 pins.  One of these pins on PORTF is connected to make the Arduino pin analogRead-capable and the other pins on PORTA are connected to make the Arduino pin Wire/I2C Master/Slave capable.  In other words, they used two AVR pins to synthesize a single Arduino pin capable of both functions that were available on that pin on the older Nano boards.
When it comes to using PORTMUX to switch choice of I2C pins, practically speaking, you won't be able to if you're looking to get alternate pins for TWI Master.  PORTMUX lets you switch the I2C Master/Slave or just Master peripheral onto pins PC2 and PC3 instead of PA2 and PA3.  But, in the Nano Every schematic, you can see these are not connected to anything.  So if you wanted to do that, it would mean something like soldering wiring-wrap wire directly to the MCU pin, which would be difficult.  And PC2 and PC3 are the only two other ATMega4809 pins that PORTMUX will route the hardware I2C Master/Slave peripheral to.    So, practically speaking, if you want I2C any pins other than A4 and A5 on a Nano Every, it means using a software (bit-banged) implementation of I2C.
You asked (in comments) about the TWI support indicated on PF2 and PF3 in the ATMega4809 datasheet.  I think I'd either been looking at an older datasheet or maybe disregarded those pins because of how they're hardwired over to PORTA on the Nano Every.  The ATMega4809 has a "Dual TWI" mode apparently, where you can have just master mode on the pins that are normally both, and just slave mode on an alternate set of pins.  In two configurations of PORTMUX under Dual TWI, the PF2 and PF3 are where the slave-only capability of the peripheral are broken out.  With PORTC's TWI pins unconnected and PORTA's TWI pins hardwired to PORTF's TWI pins, it's unclear to me what advantage you could get out changing PORTMUX on an Arduino Nano Every.


String(int) function stopping the Arduino

You should avoid String on the Arduino. It will cause random crashes. However that's not your issue. Your issue is trying to copy the data into an array that is too small.
char tempSMS2[] = "";

That creates a one byte array which contains just a \0. You then try and squeeze your String data into it and it of course overflows all over the rest of your variables and data.
A better solution is to work directly in char arrays. It is a little trickier though:
First convert your float to a string:
char tempFloat[8];
dtostrf(analogRead(LM35_pin) * 0.48828125, -7, 3, tempFloat);

Then build up your string:
char tempSMS2[30];
strcpy_P(tempSMS2, PSTR("Hava "));
strcat(tempSMS2, tempFloat);
strcat_P(tempSMS2, PSTR(" derece."));


Do I need a bubble sort or something easier?

You could do a qsort. You haven't posted any data types so it is hard to answer with your specific code, however here is a sample of sorting numbers:

const int COUNT = 10;

int someNumbers [COUNT] = { 7342, 54, 21, 42, 18, -5, 30, 998, 999, 3  };

// callback function for doing comparisons
int myCompareFunction (const void * arg1, const void * arg2)
  {
  int * a = (int *) arg1;  // cast to pointers to integers
  int * b = (int *) arg2;

  // a less than b?
  if (*a < *b)
    return -1;

  // a greater than b?
  if (*a > *b)
    return 1;

  // must be equal
  return 0;
  }  // end of myCompareFunction

void setup ()
  {
  Serial.begin (115200);
  while (!Serial) { }  // for Leonardo
  Serial.println ();
  // sort using custom compare function
  qsort (someNumbers, COUNT, sizeof (int), myCompareFunction);
  for (int i = 0; i < COUNT; i++)
    Serial.println (someNumbers [i]);
  }  // end of setup

void loop () { }

Output:

-5
3
18
21
30
42
54
998
999
7342

Generic compare function with a template

Interestingly, you can make the compare function be a template which lets you compare any type -- that is, any type that supports direct comparisons. Change the compare function to:

// callback function for doing comparisons
template<typename T>
int myCompareFunction (const void * arg1, const void * arg2)
  {
  T * a = (T *) arg1;  // cast to pointers to type T
  T * b = (T *) arg2;
  // a less than b?
  if (*a < *b)
    return -1;
  // a greater than b?
  if (*a > *b)
    return 1;
  // must be equal
  return 0;
  }  // end of myCompareFunction

This change removes the reference to "a" and "b" being "int" and replaces them with T, which is the template type.

Now we can change the qsort line to be:

  // sort using custom compare function
  qsort (someNumbers, COUNT, sizeof (int), myCompareFunction<int>);
  // -------add this----------------------------------------^^^^^

That gives the same results, but now we can also compare float, long, unsigned long, byte, all that sort of thing.

Compare floats

For example to compare floats:

const int COUNT = 10;

float someNumbers [COUNT] = { 7342, 54, 21, 42, 18, -5, 30, 998, 999, 3  };

// callback function for doing comparisons
template<typename T>
int myCompareFunction (const void * arg1, const void * arg2)
  {
  T * a = (T *) arg1;  // cast to pointers to type T
  T * b = (T *) arg2;
  // a less than b?
  if (*a < *b)
    return -1;
  // a greater than b?
  if (*a > *b)
    return 1;
  // must be equal
  return 0;
  }  // end of myCompareFunction

void setup ()
  {
  Serial.begin (115200);
  while (!Serial) { }  // for Leonardo
  Serial.println ();
  // sort using custom compare function
  qsort (someNumbers, COUNT, sizeof (float), myCompareFunction<float>);
  for (int i = 0; i < COUNT; i++)
    Serial.println (someNumbers [i]);
  }  // end of setup

void loop () { }

The only change there was changing the word "int" to "float" (in two places) on the qsort line, and on the data declaration itself.

Compare String objects

You can even compare String objects (not C strings), for example the data is:

String someStrings [COUNT] = { "the", "quick", "brown", "fox", "jumped",
                               "over", "the", "lazy", "dog", "ZOMG"  };

And the sort is:

  // sort using custom compare function
  qsort (someStrings, COUNT, sizeof (String), myCompareFunction<String>);
  for (int i = 0; i < COUNT; i++)
    Serial.println (someStrings [i]);

Compare C strings

We need to use strcmp in this case, but most of the work is done in that. We just have to dereference the pointer so strcmp gets the pointer to the string (not the pointer to the pointer to the string).

char * someStrings [COUNT] = { "the", "quick", "brown", "fox", "jumped",
                               "over", "the", "lazy", "dog", "ZOMG"  };

int myCompareFunction (const void * arg1, const void * arg2)
  {
  return strcmp (*(char **) arg1, *(char **) arg2);
  }  // end of myCompareFunction

void setup ()
  {
  Serial.begin (115200);
  while (!Serial) { }  // for Leonardo
  Serial.println ();
  // sort using custom compare function
  qsort (someStrings, COUNT, sizeof (char *), myCompareFunction);
  for (int i = 0; i < COUNT; i++)
    Serial.println (someStrings [i]);
  }  // end of setup

void loop () { }


PWM is only supported for timer1 on the ATTiny461. Not in timer0.

Look at TCCR1A; specifically the COM1xn bits.


It is the 0V reference for everything else, as well as the power supply return.

"Ground (electricity)" on Wikipedia


How to connect neo 6m 6pin module with nodemcu v3

The 4 pins VCC/GND/TX/RX are the same as any other GPS module.
The other two pins, SCL and SDA, are nothing to do with the GPS. They connect to the HMC5883L compass chip.
Use the normal TinyGPS library for the GPS, and a HMC5883L library (such as this one) for the compass.


How to power both arduino and 1 color led strip from single power source

Note that VIN pin and the 2.5mm DC Jack are connected. So in the tutorial one of these is getting power from a +12Vdc source and the other is supplying +12V to the +12v labeled pin on the LED string. Where the R G and B pins of the strip should be connected to Collectors of NPN's. Each of the NPN's bases are driven by Arduino Output pin and all the Emitters are connected to Ground.

So +12V supplies the DC Jack (aka Vin) the Arduino's local regulator converts that to Ground. The +12V via Vin supplies the LED's. And the Digital Outputs drive the base's of the NPN's. Which in turn act like a relay closing the perspective LED's to Ground, so they can illuminate. Where a Digital ONE or HIGH or TRUE on the BASE results in 5V above ground, which causes it to have low resistance.


You need to write a I2C bootloader to the AVR. There seems to be a project that has already created such a bootloader.

Atmel has provided a TWI/I2C bootloader for their XMega processors (not the ATmega168).

Next problem is uploading the code via I2C. You'd need some hardware to convert USB  to I2C. And some software to talk to this hardware. The last part is probably supported by AVR studio, as Atmel has provided an I2C bootloader. Though I'm not sure both of the above bootloaders are using a compatible protocol over the I2C.


You get widest search with Google. Write "arduino" and then the device or topic name.

Most of the libraries have a GitHub repository. You can use a search field on GitHub.

A list of selected libraries sorted by topic is on Arduino playground.


Working with multiplexers for constant voltage output

Even I am new to this and I also find it a bit challenging with the available setup and desired output. Though it seems tough, I want you to just try out this code (it is a little modification to the one posted by you) and check whether it matches the expected result.

    //Mux control pins
#define s0 8;
#define s1 9;
#define s2 10;
#define s3 11;

//Mux in "SIG" pin
#define SIG_pin 3;

#define testValue 255;  //maximum value for analogWrite() function

void setup()
{
  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);

  pinMode(SIG_pin, OUTPUT);

  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
}

void loop()
{
  //Loop through and read all 16 values
  for(int i = 0; i < 16 ; i ++)
  {
    delay(1000);
    writeMux(i);
  }
}

int writeMux(int channel)
{
  int controlPin[] = {s0, s1, s2, s3};

  int muxChannel[16][4]=
  {
    {0,0,0,0}, //channel 0
    {1,0,0,0}, //channel 1
    {0,1,0,0}, //channel 2
    {1,1,0,0}, //channel 3
    {0,0,1,0}, //channel 4
    {1,0,1,0}, //channel 5
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++)
  {
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //read the value at the SIG pin
  for(int i_testValue = 0; i_testValue < testValue; i_testValue++)
  {
    analogWrite(i_testValue, SIG_pin);      //incresing intensity slowly with delay of 100ms
    delay(100);
  }

  //return the value
  return 0;
}


Noise on piezo analog read due to Arduino power supply

The 9V wall adapter is in most cases a switched power regulator with a high frequency. That's like a radio transmitter direct beside the wire. So there is nothing mystical, when the smooth USB Voltage does not show problems but the
"radio transmitter" does.

There are two ways the power supply can impact: over radio wave or as ripples over the regulated Voltage of your Arduino.

I asked myself, which one it is (or even both)? If you use the extra regulated analog voltage reference (AREF) as the +5V on your Voltage divider, it would be more likely that the problem comes through the air. Then it would help if you activate the shield of the wire by connecting it to GND.

If a rippled supply voltage is the problem, you have to smooth it. Perhaps with a low pass filter (a big Elko between Vcc and GND).

Perhaps you have a solenoid iron core. Then you can wrap the wire to the piezo sensor a few times around it (near the A0 Pin). This technique is often used in computer power supplies to prevent the switching frequencies from escaping to the public power lines.


How to put Arduino Nano in low power sleep mode (<0.05mA)

Turns out the voltage regulator was AMS1117 - not MIC5205-KB50/KB33/KBAA like the one in the article. Ripping it off gave me the 0.026 mA idle current which is even better than what I was hoping for.


Delay not working in function other than loop

You have no delay in between turning the LED off and turning it back on. Add one.