text:
esp32 spi library, how read a mcp23s08 register
thanks for any help
I need to read a gpio expander mcp23s08 set as 8 bits input.
my code write correctly (I believe) the setup register using SPI library, with the enclosed example modified.
But I do not understand how read a gpio register (0x09)
code (with the read out routine wrong:
#define GPIO_SEL_pin 14                         // D14 = MCP23S08 GPIO SPI select pin
#define SCLK 18                                 // D18 SPI SCLK
#define MISO 19                                 // D19 SPI MISO
#define MOSI 23                                 // D23 SPI MOSI

#include <SPI.h>

uint8_t keyboard;

static const int spiClk = 1000000; // 1 MHz

//uninitalised pointers to SPI objects
SPIClass * mcp23s08 = NULL;

void setup() {
  Serial.begin(115200);
  pinMode(GPIO_SEL_pin, OUTPUT);                     //MCP23S08 SPI select pin
  digitalWrite(GPIO_SEL_pin, HIGH);                  //pull ss high to disable data transfer
  mcp23s08 = new SPIClass(VSPI);
  mcp23s08->begin(SCLK, MISO, MOSI, GPIO_SEL_pin);   //SCLK, MISO, MOSI, SS
  mcp23s08SetUp();
  delay(1);

}

void loop() {
  keyboard = mcp23s08Read();
  Serial.println (keyboard);
  delay(100);
}

// ================================== routines =================================
void mcp23s08SetUp( void ) {
  uint8_t dev_adr  = 0x40;                          // MCP23S08 address 0; R/W = write
  uint8_t reg_adr  = 0x00;                          // MCP23S08 IODIR register
  uint8_t reg_data = 0xFF;                          // pin configured as input

  digitalWrite(GPIO_SEL_pin, LOW);                 //pull SS slow to prep other end for transfer
// ============================= MCP3S08 pin as input ==============================
  mcp23s08->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  mcp23s08->transfer(dev_adr);
  mcp23s08->transfer(reg_adr);
  mcp23s08->transfer(reg_data);
  mcp23s08->endTransaction();

  reg_adr  = 0x01;                                 // MCP23S08 IPOL register
  reg_data = 0xFF;                                 // invert input polarity
// ============================= MCP3S08 invert input ==============================
  mcp23s08->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  mcp23s08->transfer(dev_adr);
  mcp23s08->transfer(reg_adr);
  mcp23s08->transfer(reg_data);
  mcp23s08->endTransaction();

  reg_adr  = 0x06;                                 // MCP23S08 GPPU pull-up register
  reg_data = 0xFF;                                 // set pull-up register
// ============================= MCP3S08 pullup resistor ==============================
  mcp23s08->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  mcp23s08->transfer(dev_adr);
  mcp23s08->transfer(reg_adr);
  mcp23s08->transfer(reg_data);
  mcp23s08->endTransaction();

  digitalWrite(GPIO_SEL_pin, HIGH);                //pull ss high to signify end of data transfer
}

uint8_t mcp23s08Read ( void ) {
  uint8_t dev_adr  = 0x41;                          // MCP23S08 address 0; R/W = read
  uint8_t reg_adr  = 0x09;                          // MCP23S08 GPIO register
  uint8_t reg_data;                                 // GPIO register
  mcp23s08->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  mcp23s08->transfer(dev_adr);
  mcp23s08->transfer(reg_adr);
  reg_data = mcp23s08->transfer(0x00);
  mcp23s08->endTransaction();
  return reg_data;
}

Why do you toggle SS inside mcp23s08SetUp() function and NOT inside mcp23s08Read()?
I don't remember if SS pin is managed by SPI Arduino library, but you can try it.

Yes, you are right. Just forgot to toggle the ss pin.

Hi @Angelo Gilin Maggiora if this answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.

Thanks a lot for your help. @leoc7 could you tell me where is the check-mark button? I did not find in the page. Sorry, I am a newbe

Read answer of this question in order to know how to accept an answer. :) https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work

I, hopefully, did it. Isn't it

I would submint the full working example of setting up and readout of GPIO expander MCP23S08 using esp32 and SPI bus.

You forgot to toggle SS pin in mcp23s08Read() function.
 uint8_t mcp23s08Read ( void ) {
      ----> digitalWrite(GPIO_SEL_pin, LOW);                 //pull SS slow to prep other end for transfer
      uint8_t dev_adr  = 0x41;                          // MCP23S08 address 0; R/W = read
      uint8_t reg_adr  = 0x09;                          // MCP23S08 GPIO register
      uint8_t reg_data;                                 // GPIO register
      mcp23s08->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
      mcp23s08->transfer(dev_adr);
      mcp23s08->transfer(reg_adr);
      reg_data = mcp23s08->transfer(0x00);
      mcp23s08->endTransaction();
      ----> digitalWrite(GPIO_SEL_pin, HIGH);                //pull ss high to signify end of data transfer
      return reg_data;
    }


text:
LCD 16*02 I2C shield only shows first character printed
I have an I2C LCD screen provided with a Sunfounder kit and certainly built by DFRobot or such a constructor (there is nothing written on the LCD), and an Arduino Uno R3 copy.
My issue is when I use lcd.print() to write a string on the LCD, only the first character of the string is printed. I can only print on other positions by using setCursor but only one character at a time.
I tried to change libraries (https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library, the one supplied with the LCD...), It always behaves the same!
For example, here's a very simplistic program which exhibits this behavior:
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);
// set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  lcd.print("write");
  delay(1000);
  lcd.setCursor(10, 0);
  lcd.print("p10");
  lcd.setCursor(0, 1);
  lcd.print("0, 1 write");
  if((millis() / 1000) % 5 == 0) {
    lcd.clear();
    delay(1000);
  }
}

I end up with something like:
w      p
0w

On the screen (before the clear() occurs of course).
Instead of something like:
write  p10
0, 1 writewrite

The lcd itself was ok some time ago. The only thing I could think is I recently updated to Arduino 1.6.6. Can it be a bug in the compiler?
The hello world from DFRobot also doesn't work properly (first char only, again) (please note to make it display something with my LCD I have to change the address from 0x20 to 27).

That's definitely a bug appeared in 1.6.6.
For reference, see
https://blog.arduino.cc/2015/11/03/arduino-ide-1-6-6-released-and-available-for-download/#comment-278766
https://forum.arduino.cc/index.php?topic=359652.0
http://forum.arduino.cc/index.php?topic=357312.msg2476987#msg2476987
Last link seems to provide a solution, by a updated version of LCD I2C lib : https://github.com/marcoschwartz/LiquidCrystal_I2C (not yet tried).
The 1.6.6 is a bit messy according some people, but the I2C lib too ;). So the question is : where should it be fixed ?

Your code contains, in part,
#include <LiquidCrystal_I2C.h>
....
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
  lcd.init();
  lcd.backlight();
}

For all of the constructors in LiquidCrystal_I2C.h on my system, the second and third parameters are EN and RW, ie, the enable and read/write backpack-pin numbers.  They don't specify the size of the display.
I suggest trying constructor usage like
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack

and in place of lcd.init(); say
lcd.begin (16,2); // for 16 x 2 LCD module

Note, lcd.begin() will call init().

Hello and thanks for your answer. The code I supplied was previously working, your LiquidCrystal_I2C lib should be different if you don't have at all the same ctor than mine. But I'll do a try with yours to see if if fixes my problem.

I have had same problem, issued on v1.6.7 and v1.6.8. I solved it with the new 'marcoschwartz' library specified in other answers.
Previously, I had used the same DFRobot library, which worked fine on IDE 1.6.0, until I upgraded on v1.6.7.

Welcome on Arduino Stack Exchange. "Thanks" and "Me too" answers aren't really considered usefull (http://meta.stackexchange.com/questions/256378/are-me-too-answers-considered-a-noisy-answer-detailed-in-the-faq). In your case, you do give some interesting information, but keep it in mind. You should only add an answer if it is different from another answer given and will actually answer the question.

I tried the solution described by AFract and it solved the problem. (sorry, I couldn't reply to his comment because I don't have enough reputation.)
I got the new LiquidCrystal_I2C library here: https://github.com/marcoschwartz/LiquidCrystal_I2C
Info on the code commit is here: https://github.com/marcoschwartz/LiquidCrystal_I2C/pull/5

I'm incredibly new to Arduino (I literally got one a few hours ago and I'm still finding my feet with it!) so take that into account when considering anything I say however I'd be inclined to agree that this may be an issue with the 1.6.6 IDE.
I was getting pretty much the same symptoms on a Freematics MEGA2560/3.2" SSD1289 LCD using the MultiLCD library using 1.6.6. Based on your comment above I uninstalled and installed 1.6.5 instead, recompiled and uploaded and it's now displaying properly...

Hello, thank you very much to confirm the behaviour I've seen. I had not time yet to look for other solutions like the suggestion of jwpat7.

I had the same problem. My LCD only showed one character. I downloaded and tryed docens of LCD libraries and ended up with a bunch of libraries installed in my IDE. After days trying to solve the problem I decided to clear my IDE deleting the libraries directory (mind that the IDE could take them from documents/arduino/library folder). After that I tested one by one the LCD libraries. I case it did not work I deleted it. The one posted above  https://github.com/marcoschwartz/LiquidCrystal_I2C worked!!.I don't really know where was the problem exactly, maybe a conflict among the libraries intalled.

source: Stack Exchange

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

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

sort: votes


text:
Connect multiple modules to arduino micro
I have an Arduino Micro and I want to connect an LCD and Bluetooth module to it. The problem I face is that there are not enough power pins for them both.
I understand that I probably need some external power supply for them, but I have no idea how to do this properly.

Just split the wire going from the vcc pin.

You can design/build/deploy a power supply that provides to each board (arduino included) the voltage it needs (but it's advisable to have modules working at the same voltage level) and that should be sufficient.
As long as you have a shared Vcc-to-GND reference, it's enough.
To verify that the power supply you choose is ok, do the following:

check that the modules are compatible with its voltage (ex: all at 5V)
check that the combined power consumption of each module (you get that from the datasheet) is lower than the total power output of the power supply.

Additional checks:

check that the maximum voltage ripple provided by the power supply is lower than what the modules can tolerate
check that the peak current the power supply can provide is larger than the combined peak current of all the other devices.

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


text:
ArduinoUno+LcdKeypad+ArduinoWifi=Pins Problems
Is it possible to connect these two shields to my Arduino Uno? After a research on the internet, I discovered that they use some of the same pins. Even so, is it still possible for me to connect the LcdKeypad and the ArduinoWifi on my Arduino Uno? (the LCD would be on top)
Here are the pic of the shields, and some information:
LDC KEYPAD
Arduino WIFI
WiFi shield info:

The Arduino communicates with the processor WiFi shield with the microSD card by SPI
  (Eurotherm the ICSP bus) that is on pins 11, 12
  and 13 at Uno. The pin 10 is used to select the HDG104 and pin 4 to
  the microSD card(i dont need the pin 4 cause i wont use SD). These pins can not be used
  for input and output. The
  digital pin 7 is used for initialization of the communication protocol
  between the shield and Arduino WiFi and should not be used.

LCD info:

This shield we will have to use the following sequence to initialize
  the library LiquidCrystal:
  LiquidCrystal lcd (8,9,4,5,6,7);

As you guys have noticed, there is the pin 7 on both shields that I need to use. How would it work? Can I do this? If i can't, is there any solution that I can expand my pins that would not result buying a Mega?
I still have to connect two INFRA-RED sensors and a motor (using pins 0, 1, and 2). I don't know if i can connect on the pins TX and RX (they seem to work).

So here are your needs:

WiFi, which uses pins 4, 10, 11, 12, 13. I know you said that you don't need pin 4 since no SD, but because that pin switches on/off the SD card, if you use it at all. Note: As Connor Wolf points out, it's not really relevant when there's no SD card. If you're facing problems with the Ethernet shield using the LCD additionally, you might have to reroute pin 4.
LCD, which uses pins 4, 5, 6, 7, 8, 9. The standard Arduino LCD library can use any pins, but your shield is hard wired to use those. As mentioned before, you can reroute them if you want to. Below is the method for rerouting pins.

Rerouting pin 7 (you need to do this!):

Bend pin 7 on the LCD shield and the WiFi shield outward so it doesn't make contact with the header
Use LiquidCrystal lcd(8,9,3,5,6,2); if you're rerouting pin 4, or LiquidCrystal lcd (8,9,4,5,6,2); in your code if you're not rerouting
Attach a jumper between the pin 7 on the header of the WiFi shield and the pin 7 on the Arduino Uno
Attach a jumper between the pin 2 of the WiFi shield (or the Uno, if that's easier) and the pin 7 of the LCD using the free space of the pin bent above it.

This will isolate pin 7 on the LCD, still send the pin 4 signal to the WiFi shield, and reroute the signal from pin 2 on your Arduino to pin 7 on the LCD shield.

Rerouting pin 4 (optional):

Bend pin 4 on the LCD shield and the WiFi shield outward so it doesn't make contact with the header
Use LiquidCrystal lcd(8,9,3,5,6,2); in your code
Attach a jumper between the pin 4 on the header of the WiFi shield and the pin 4 on the Arduino Uno
Attach a jumper between the pin 3 of the WiFi shield (or the Uno, if that's easier) and the pin 4 of the LCD using the free space of the pin bent above it.

This will isolate pin 4 on the LCD, still send the pin 4 signal to the WiFi shield, and reroute the signal from pin 3 on your Arduino to pin 4 on the LCD shield.

For number of pins, you should be fine. You can use pins 0 and 1 (TX/RX) as long as you aren't connecting to the computer or any other UART device  (i.e. using the Serial() library). Don't forget you can use the analog pins as digital pins by referencing them as A0 to A5.

As long as you don't have a microSD card in the microSD slot, the fact that you have a wire going there that is energized is irrelevant. You don't need to bend any pins. Just don't put a SD card in the slot. You can't "enable" something that's not physically connected.

Note: there is a voltage translator in there too, but it doesn't matter if it's not connected to something at both ends, so you can ignore it. Also, it doesn't "switch the SD card on/off" anyways. It's a chip-select line, not a power line. It just controls the bus-arbitration electronics in a already powered on SD card.

@Connor I know that you probably don't have to do that, IMO it's more of a "best practice" thing. I'm editing to clarify my post. It also prevents accidental problems if you were to plug in a SD card forgetfully.

If you don't have to do it, and it involves damaging one of your devices somewhat, I'd qualify it as "worst practices", rather then "best" practices. It's not like you can damage anything anyways, the level translator has limited drive capability.

Thanks guys, the but what about pin 7? it's used in both shields, and unlike the pin 4, it's something that i'll use, because it's used for the "initialization of the communication protocol between the shield and Arduino WiFi"

@user3504192 Sorry, forgot to add that. I edited my post.

@Connor BTW you do have to "damage" your board either way with pin 7; I forgot to add that in my answer. The OP could also do this manually with a breadboard for the WiFi, but that would be a pain.


text:
How does this code work?
I've found this code below, but I can't figure out how it works. Can someone explain to me the flow of the program?
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 10, 7, 5, 4);
int mem=0;
void setup() {
    pinMode (12,OUTPUT);
    pinMode(13,OUTPUT);
    // initialize the LED pin as an output:

    // initialize serial communications:
    Serial.begin(9600);
    lcd.begin(16, 2);
}

void loop() {

    lcd.setCursor(12,1);
    int se25 = analogRead(A4);
    int se50 = analogRead(A3);
    int se75 = analogRead(A5);
    int se100 = analogRead(A2);
    if(se100>=1000){lcd.print("100%   ");mem=100; }
    else if(se75>=1000){lcd.print("75%   ");mem=75; }
    else if(se50>=1000){lcd.print("50%   ");mem=50; }
    else if(se25>=1000){lcd.print("25%  ");mem=25; }
    else{lcd.print("emty");mem=0;}
    if(se100<1000&&se75<1000&&se50<1000&&se25<1000){
        digitalWrite(13,LOW);
        lcd.setCursor(12,1);
        lcd.print("emty");
    }

    if(digitalRead(6)==HIGH){digitalWrite(13,LOW);}

    if(digitalRead(6)==LOW&&mem>0)
    {// read the value of the potentiometer:
        int tempw = 0;
        //digitalWrite(12,LOW);
        int tempa = analogRead(A1);
        delay(20);
        int tempb = analogRead(A1);
        delay(20);
        int tempc = analogRead(A1);
        delay(20);
        int tempd = analogRead(A1);
        delay(20);
        int tempe = analogRead(A1);
        delay(20);
        int tempf = analogRead(A1);
        delay(20);

        int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);

        int temp = avg;
        // map it to the range of the analog out:
        temp = map(temp, 0, 1023, 0, 4900);
        float tempx = temp * (0.1);
        // change the analog out value:
        int tempy=analogRead(A0);
        tempy = map(tempy, 0, 1023, 0, 150);
        // print the results to the serial monitor:
        lcd.setCursor(0,0);
        lcd.print("act T=" );
        lcd.print(tempx);
        lcd.print("'C  " );
        lcd.setCursor(0,1);
        lcd.print("set T=");

        lcd.print(tempy);
        // Serial.println("'C ");
        lcd.print("'C  ");

        if(tempy<=tempx){digitalWrite(13,LOW);}
        if(tempy>tempx){digitalWrite(13,HIGH);}

        delay(200);
    }

}

who voted this down? This is a legit question from a new user.

I'm assuming you already have some understanding of programming, so I won't literally explain everything line-by-line (that would probably be beyond the scope of this site, and would result in a very long answer). I'll try to explain the important points though. If you need to lookup more information about specific commands, I recommend checking out the Arduino reference.
At a very broad level, the program is taking some readings, and reporting data to a screen (LCD). I would guess that the data is the fluid level in a tank, as well as some kind of temperature reading. It's impossible to be sure about that though, as I don't know what's actually connected to the inputs.
This line creates an object for talking to the LCD screen. The numbers specify which pins it's connected to:
LiquidCrystal lcd(2, 3, 10, 7, 5, 4);

The setup() function gets run once when the device starts up, and is typically used for initialisation tasks. In this case, the lines within setup() initialise two pins as outputs (#12 and #13), initialise serial communication (which isn't actually being used), and initialise the LCD object/screen:
pinMode (12,OUTPUT);
pinMode(13,OUTPUT);
...
Serial.begin(9600);
lcd.begin(16, 2);

The rest of the program is in the loop() function, which runs repeatedly as long as the device is on.
The following lines take 4 analog-to-digital readings (from different inputs), and output the approximate result:
int se25 = analogRead(A4);
int se50 = analogRead(A3);
int se75 = analogRead(A5);
int se100 = analogRead(A2);
if(se100>=1000){lcd.print("100%   ");mem=100; }
else if(se75>=1000){lcd.print("75%   ");mem=75; }
else if(se50>=1000){lcd.print("50%   ");mem=50; }
else if(se25>=1000){lcd.print("25%  ");mem=25; }
else{lcd.print("emty");mem=0;}
if(se100<1000&&se75<1000&&se50<1000&&se25<1000){
    digitalWrite(13,LOW);
    lcd.setCursor(12,1);
    lcd.print("emty");
}

My guess is that each of the analog readings comes from a different fluid sensor in a tank. If the top sensor shows a strong reading, the tank is considered full. Otherwise, it checks the next sensor down, and so on. If none of them shows a strong reading, the tank is considered empty. Interestingly, the condition for an empty tank is actually checked twice, which is presumably a mistake.
(Once again, bear in mind that I'm just guessing that the readings are from fluid sensors in a tank. I don't know for sure.)
The remainder of the code only runs if a particular input (#6) is low, and if the tank is not empty. Input #6 could be from some kind of override switch, but again that's just speculation.
The following block takes 6 analog readings, all from the same input. There's a short delay (20 millisecond) between each reading. The results are then averaged. This is a common approach when you want to try to eliminate noise spikes in an analog signal.
int tempa = analogRead(A1);
delay(20);
int tempb = analogRead(A1);
delay(20);
int tempc = analogRead(A1);
delay(20);
int tempd = analogRead(A1);
delay(20);
int tempe = analogRead(A1);
delay(20);
int tempf = analogRead(A1);
delay(20);

int avg = ((tempa + tempb + tempc + tempd + tempe + tempf ) / 6);

The next block re-maps that reading onto a different range (presumably related to the expected temperature range). It then takes another analog reading from a different input, and remaps that to a different range:
int temp = avg;

temp = map(temp, 0, 1023, 0, 4900);
float tempx = temp * (0.1);

int tempy=analogRead(A0);
tempy = map(tempy, 0, 1023, 0, 150);

The following block outputs the two re-mapped readings. It looks like both of them are treated as temperatures. One is presumably from a temperature sensor, and the other is presumably from a potentiometer used to calibrated the system:
lcd.setCursor(0,0);
lcd.print("act T=" );
lcd.print(tempx);
lcd.print("'C  " );
lcd.setCursor(0,1);
lcd.print("set T=");

lcd.print(tempy);

lcd.print("'C  ");

These lines compare the two readings from above, and set output pin 13 high or low depending on which reading is higher. I'd guess it could be connected to a warning light or similar.
if(tempy<=tempx){digitalWrite(13,LOW);}
if(tempy>tempx){digitalWrite(13,HIGH);}

Lastly, this delay stops the loop from running too fast. Interestingly though, the code only reaches this point under certain circumstances. In other circumstances, there's no limit on loop execution speed:
delay(200);


text:
What should be the delay to be given for reading accelerometer
I have five accelrometer sensors (MMA 7361) connected to the analog channels of Arduino Duemilanove. I am using the following code to read the data. (I am reading from only one axis from each sensor.)
#include <avr/io.h>
#include <avr/wdt.h>

int sensorValue = 0; // value read from the pot

void setup()
{
    Serial.begin(9600); // initialize serial communications at 9600 bps:
}

void loop()
{
    // read the analog values:

    int i=1;

    Serial.print("ACS#");

    for(i=0;i<5;i++)
    {

        sensorValue = analogRead(i);
        Serial.print(sensorValue);
        Serial.print("#");

        delay(10);
    }

    Serial.println("");

}

I am using a delay of 10 after reading each sensor. What should the value of the delay I should be using after reading one sensor to get the correct values from the sensors?

Why do you need any delay?

No delay is needed. Note however that the serial communication might not be able to keep up. If that happens your Serial.print calls will block/delay until the TX-buffer is no longer full. No big deal, but might be useful to know.

What are you trying to do with the data? This will help us give you an answer about sample rates

A delay is not needed.
What can be more beneficial, though, is making a dummy reading between each real reading.  This gives the ADC more of a chance to settle on the right reading without the Sample and Hold capacitor being influenced by the previous reading.
The simplest way is just to duplicate your analogRead line so it's done twice.

what is the time required for the ADC to settle on the right reading?

You'll find that kind of information in the datasheet. Cross-reference that with the analogRead() code to see what the current settings are.

@ukg You don't need to wait for the ADC to settle for any of the readings, each pin uses a different ADC, and they are continuously tracking the input.


text:
arduino boot loader problem
I am using atmega 328pu instead of atmega328p-pu. I am trying to upload the bootloader using AVR pocket programmer.
I have changed signature from 0x1e 0×95 0x0F to 0x1e 0×95 0×14.
(Relevant link)
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

How about removing the screendump from the question and pasting the text from the screen in your question so we can actually read it?

@jippie larger image

@Gerben why would I download a 52kB image for under 100 bytes of text? It is less effort to copy the text in the first place and not a single search engine will be able to index the question properly, rendering the question useless for future visitors.

Have you set Tools -> Programmer to AVR ISP?

(Note for the Arduino Uno: you'll need to add a 10 uF capacitor
  between reset and ground.)

From http://arduino.cc/en/Tutorial/ArduinoISP

The cap is only needed on the UNO that is used as the ISP. Where in this case there is a "avr pocket programmer"

It sounds as if you are using the Arduino IDE to "Upload using Programmer". If so; in the preferences enable Verbose output for upload. From this you should see all of the avrdude output. Not just the error message. Hopefully with this you will see signature of the chip you actually read. You will also see the full and exact avrdude.exe command that is being executed. Note the path/filename of the avrdude.conf, to ensure it is the one you changed.
Using this you can attempt it manually, and tweak it. Try adding the -F to it. Or execute the equivalent to :
avrdude -b 19200 -p atmega644p -C avrdude.conf -c stk500v1 -P COM4 -n

where the "-n" is "Do not write anything to the device." just read the signature.
I prefer to use a GUI in front of avrdude. Yuki's GUI is a good example. Just need to point it to the EXE and have a copy of the conf file in the same directory.

I should mention the Arduino way of doing this, is to create a new boards.txt file with this chip and add (not change) the avrdude.conf file. This will allow programing either from selecting the correct board. but that is another subject.

This sounds like the programmer is not seeing the ATMega328 MCU, or the Arduino IDE is not seeing the programmer. Changing the signature won't be of any help as the IDE (or AVRDude) is not seeing the ATmega328.
I would suggest that you double-check your connections, and set the options in the IDE to verbose output - then repost the info here.


text:
updating firmware on arduino wifi shield
I'm trying to upgrade firmware on my wifi shield by following the upgrade instructions for Mac. I was wondering what this means?:

Connect a jumper on the J3 connector, that put the shield in the programming mode. Then connect the USB cable to the shield USB mini socket

How can I do this?

A "jumper" is a little piece of metal (or a 0-ohm resistor) that connects two pads or pins together. So, create an electrical connection across J3 ("DFU programming jumper" in all the pictures). You will then be able to program the shield via USB.

Ok so on the wifi shield i just place the cap over the DFU programming pin (the one that comes with the shield)? Like shown on this picture http://www.dfrobot.com/community/how-to-upgrade-arduino-wifi-shield-firmware-on-windows.html

That would be the one.

The jumper is only neccesary if your device is not R3 (revision 3)
Be carefully if you connect the shield and your computer does not
recognice the port.
You gonna need a driver in the link below there are all the steps
include other links to download software as Flip 3.4.7 who has
the executable batchisp which one you can made the changes
read the web site:
http://www.dfrobot.com/community/?p=3760
and extra information about that in official site of arduino
WiFi Shield Firmware Upgrading
there you gonna have an idea how to do it.
for me was more clear as in this site describe everything
and also teach to probe if there is an update
having sucess in the process to installing something it
could be as a question answered with non the specific
thing you need.
http://www.binarytaskforce.com/Weblog/2013/09/21/arduino-wifi-firmware-update/
I am also in the process to update my device if I will have success
I will write to how I do it.
At the moment reading a bunch of differents forums beacuse arduino team itself
appearently had some troubles to provided a guided how to do it sucessfully.


text:
Connecting to network with wifi shield
I just bought a WiFi shield and I cannot connect to my wireless network (WPA2).

I used the sketch from the Arduino site for connecting to WPA network and put my SSID and password on but it doesn't connect (I know the credentials are correct as I used my phone to connect with these WiFi credentials).
When I read the serial monitor it just keeps trying to connect. The WiFi-shield board error light is red
I checked my network settings and my block level is at is lowest (NAT only).

Why can't I connect?

In the loop:
// attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

Can you add Serial.print(status); before the delay so you can see if any of these arise:

WL_IDLE_STATUS = 0
WL_NO_SSID_AVAIL
WL_CONNECT_FAILED
WL_CONNECTION_LOST
WL_DISCONNECTED

They are defined in wl_definitions.h

I was facing the same issue using the Feather M0 board from Adafruit. After updating the Arduino IDE as well as the IDE's libraries and firmware, I was able to connect to WiFi.


text:
How do I use Arduino and node.js?
I am new to Arduino, however I have experience in web development, lately I have been using, meteor js and the mean stack for different projects. However, I am open to trying any language for development.
What I am trying to do is build a simple application to control the LED on the Arduino over the web.
I am working with another person, and the Arduino will be behind a firewall so I am not sure how to access it via the internet. I do have access to an Arduino Uun that I can use for testing at home which does have linio connected via bridge, which I don't quite understand what that does.
I've also heard of this, but would like to stay away from third party builds as much as possible if I can do it myself.
Whats the common way to do this with an Arduino behind a firewall? How do I do this with a Arduino Yun? Is it easier with a Yun?

I am working on similar project that uses internet to communicate with external device (mobile). I am reading data from sensors and passing them over the web with web sockets. I am using Arduino Yun for this project and Spacebrew (for web sockets communication). It's very interesting approach but quite a challenge in some cases. You will probably run into asynchronous/synchronous problem, which in my case lead me to running some Python scripts on Yun triggered from Processing code. I am currently running Spacebrew server on my VPN, so I can connect my Yun left at home and use my iphone from everywhere to get the readings.
It's also worth mentioning Yun comes with pre-installed Temboo library, which is great starting point for web communication. The configuration is really easy and quick. You will also find official documentation very handy and easy to understand. It's really great starting point for experimenting with web-like applications integrated with Arduino Yun.
Spacebrew

http://docs.spacebrew.cc/
Spacebrew is an open, dynamically re-routable software toolkit for choreographing interactive spaces. Or, in other words, a simple way to connect interactive things to one another. Every element you hook up to the system can subscribe to, and publish data feeds.
http://github.com/Spacebrew/pySpacebrew
This repo contains the Spacebrew Library for Python along with documentation and example apps.
http://github.com/julioterra/yunSpacebrew
The Spacebrew Yun library features two main components - a set of python scripts that run on the linino, and a library that runs on the atmel chip. You find there information how to install both of these components so that you can connect to Spacebrew from an Arduino sketch.

Temboo
Yun has also build in Temboo library, it's a great way to start experimenting, once you prove the concept you can start narrowing your environment and moving away if you don't want to use 3rd parties software.

http://www.temboo.com/arduino
The Temboo Library makes it easy to connect to over 100 web-based resources and services with Processing. Currently you can find libraries for Android, Arduino, iOS, Java, Node.js, PHP, Processing, Python, REST API, Ruby, Twyla

Node.js
You can also run node.js on the Yun itself, here's good article and some packages ready to install:

http://giorgiocefaro.com/blog/installing-node-js-on-arduino-yun
https://github.com/giorrrgio/nodejs-linino
This is an openwrt package for node. It probably only works on mips (not mipsel, or arm). It runs an outdated v8 as well.

What is Bridge library for Arduino Yun?
You also asked about Bridge library. As you know Yun has two processors on board, one is running your Processing code, the other one has Linux on it (Linino). Bridge basically simplifies communication between them so they can "talk" to eachother, more information here:

http://arduino.cc/en/Reference/YunBridgeLibrary
(Taken from arduino.cc documentation:)
The Arduino Yún has two processors on board. One is an ATmega32U4 like on the Arduino Leonardo. The other is an Atheros 9331, running Linux and the OpenWRT wireless stack, which enables the board to connect to WiFi and Ethernet networks. It is possible to call programs or custom scripts on the Linux system through the Arduino to connect with various internet services.
The Bridge library simplifies communication between the ATmega32U4 and the AR9331. It inherits from Stream, and many of the methods should be familiar from Serial and other derivatives of Stream.
Bridge commands from the 32U4 are interpreted by Python on the AR9331. Its role is to execute programs on the GNU/Linux side when asked by Arduino, provide a shared storage space for sharing data like sensor readings between the Arduino and the Internet, and receiving commands from the Internet and passing them directly to the Arduino.
Bridge allows communication in both directions, acting as an interface to the the Linino command line.

Where to start?
I would start with Temboo if I were you, it's a great learning curve and quite simple step to start. You will also learn and understand how the board works and how you can communicate with "external world". Once you have proof of concept, start experimenting with different libraries and improving the approach. Perhaps you will find Spacebrew more handy later or even discover different solutions.

Welcome to Arduino Stack Exchange! Can you please add more detail to your answer? Answers that are all or mostly links are not acceptable on Stack Exchange because the answer is useless if the site goes down. The links to libraries are fine, since the library is useless if the site goes down; articles and tutorials should be paraphrased. Maybe just quote a few sentences and add some example code? Thanks!

first of all you need to have clear what you need to do.
Arduino UNO is just a microcontroller with a serial (over USB) connection.
To make your arduino accessible from the internet, it need to be connected with the internet, or to have something that act like a bridge.
You can use an ethernet shield, a wifi shiled, or a YUN witch is an arduino UNO + a micro linux with has ethernet and wifi (programmable in phyton, or the chip can command the linux sending command to bash shell using the special bridge library)
You can even connect arduin on the pc by usb and create a bridge program, or, if your firewall/router is a unlocked linux/similar, you can use it.
How many option, and we event startint to decide how o talk with it. As you want to use node.sj, you can use socket or get/post.
Using socket is faster, lighter, and can create a pull connection, and js wil be a requisite. With get/post you don't even need js, pure html form will do.
then, after you decided witch sistem you like (arduino as http server or plain socket) you can open the corresponding port on the firewall/nat. but is just the last part

I have a yun so I will be using that. I have hooked up to the yun via wifi and ssh. How do I setup the linux server, and than how do i open a port?

see official tutorial, it altready has a webv server, you just need to add your own page :) http://scuola.arduino.cc/lesson/b4EoRkV/Arduino_Yn_Intro_to_web_server#step_4


text:
How can I communicate Raspberry Pi and Arduino (in both ways) using a 10-15m distance wires?
I am starting a personal project of home automation and I have a raspberry pi and an arduino Uno board.
I want communicate raspberry pi and my arduino where my raspberry should be able to write and read signals to and from arduino.
The distance between them I think its going to be something around 10 to 15 meters.
What do I need for it? what kind of wires or other components I'll need to achieve my goal? I repeat: I do not want to communicate raspberry pi and arduino wirelessly.
Thanks!

for length such as this, you should be using protocols that are designed for length, such as:

UART,
CAN,
Ethernet

for UART, you can't of course use a direct connection between the two boards, you need to upgrade the connection and wiring to either rs232 or rs485, using a driver between the arduino pins and the cable.
Though, the simplest solution would be to plug the Arduino on the Raspberry Pi using a lengthy USB cable (or more likely 3 five meters cable), which should work fine as long as you only do serial communication. The USB 2.0 limitation of 5 meters are for "hi-speed" connections, which is not our concern for simple serial data communication.
HTH


text:
Uploading bootloader to ATMEGA328 P
I have a duemilanove which originally had a 168.  I have some ATMEGA328 P chips and I've put one into the duemilanove.  I am using a Uno as a programmer for the duemilanove.  I am running Arduino 1.8.2 on a PC which I understand doesn't need a capacitor installed on the Uno.  I've uploaded the sketch which makes the Uno an ISP, I have edited the avrdude.conf file, have wired up in accordance with http://www.crash-bang.com/resource/bootload-atmega328/ and the tutorial on this site.  When I run burn bootloader using the preferences set to verbose, the returned signature is correct for the P version of the chip I believe (0x95 0x14) and this is the value I have put into the avrdude.conf file.  However, avrdude is still insisting it is expecting to receive 0x95 0x0F and will not burn the bootloader.  I have no idea where it is getting this value from (I've even tried editing the iom328p.h file...). Any ideas?

Why do you want to use a duemilanove?  Why not use UNO which has better spec and is actually still supported?

What board did you select, to "burn bootloader"? From what I know, putting an ATMega328 in a duemilanove board, will make it (more or less) identical to an UNO. So select the UNO from the boards, and press "burn bootloader", should work.

I've had the same issue with some standalone 328P project.
If you enable "Show verbose output during: upload" in the preferences menu, you can see the command which the Arduino IDE uses to flash your device - avrdude.
Copy it from the terminal window into a command prompt, and add "-F" to that to disable the device signature check.

@TobiasWeiß disabling the device check is not a good practice when you want to write to the chip and besides is not elegant. There must be a simple misconfiguration which has to be found and fixed

The signature bytes are:
ATmega328 0x1E 0x95 0x14
ATmega328P 0x1E 0x95 0x0F
So it looks you have the wrong bytes for the 328P.

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


text:
Why can't I see the serial plot with the following code for arduino?
const int GSR=A0;
int threshold=0;
int sensorValue;

void setup(){
  long sum=0;
  Serial.begin(9600);
  delay(1000);

  for(int i=0;i<500;i++)
  {
  sensorValue=analogRead(GSR);
  sum += sensorValue;
  delay(5);
  }
  threshold = sum/500;
   Serial.print("threshold =");
   Serial.println(threshold);
  }

void loop(){
  int temp;
  sensorValue=analogRead(GSR);
  Serial.print("sensorValue=");
  Serial.println(sensorValue);
  temp = threshold - sensorValue;
  }

In what way are you attempting to "plot" it? I see data arriving on serial fine.

"serial plotter" command

Maybe you should get rid of the "sensorValue=" cruft and just prinln() the value? I have never used that plotter so not sure how it handles the data, but from what I have read it just wants raw numbers.

what does cruft mean?

"badly designed, unnecessarily complicated, or unwanted code or software."

so you're reffering to "sensorValue=analogRead(GSR)"?

No, I'm referring to Serial.print("sensorValue=");

I will try to delete it. Plan B?

it works! Any idea on how I can save the data and bring it to excel?

Use a terminal emulator that can save the incoming data to a text file.

I'm trying coolTerm

The serial plotter requires just numbers and nothing else.
It can't understand the data in the format:
sensorValue=49

It just expects:
49

Remove the line
Serial.print("sensorValue=");

and it will start working.

I didn't understand how much readings it takes in a second. It's 1000milliseconds/ delay (=5) = 200?

It takes as many readings as it can. You have no timing specified, so the number of samples will be defined by the speed of the serial data, and the quantity of the serial data. The quantity of the serial data depends on the values being sampled.

How can I specify the timing?

Either with delay() (crude), millis() (pretty good) or a timer (most accurate).

I don't understand how to use the timer. Which kind of argument does it accept?

Timers are hard. Stick to millis(). Look at BlinkWithoutDelay for an example.

You haven't looked at BlinkWithoutDelay, have you?

I don't understand why it uses 3 variables for one function. Is there an easier way to do it? I

Um.... I am sorry, but I have no idea what you are talking about.

const long interval = 1000;           // interval at which to blink (milliseconds)
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

It has been written in long hand so you can understand what is going on. You can do it with just one variable to store the timestamp - the rest is just the millis() function or a simple numeric literal.

Why do you use dalay is crode and that millis is better?

Delay doesn't take into account the time taken to perform the sampling and send it through serial, so you get clock drift. Millis takes that time into account so you don't get clock drift.

so the best way to make 4hz of sampling is with millis?

It's a good compromise between the simplicity and inaccuracy of delay and the accuracy and difficulty of use of using a timer.

Still, even seeing the example and this page
https://www.arduino.cc/en/Reference/Millis
I don't know how to use it in my case

It's not exactly a difficult concept - millis() gives you the time. If you know what the time was the last time you ran your sample routine, and you know what the time is now, you can know when you should run your sample routine next.


text:
Issue in long ON OFF timer using millis()
I have 3 components: a relay and two LEDs...I want two timers using Arduino... In timer one, relay should be off on; one LED is off; and other is on...In second timer, relay is off; one led is on; other is off...
This is my Code:
//const unsigned long onTime = (2 *3600000); // 2 Hours in miliseconds;
const unsigned long onTime = (3 *1000); // 3 seconds;
//const unsigned long onTime = (5 *60000); // 15 minutes;

//const unsigned long offTime = (0.5 *3600000); // 1/2 Hours in miliseconds;
const unsigned long offTime = (2 *1000); // 1 seconds;
//const unsigned long offTime = (5 *60000); // 5 minutes;

const unsigned long start_delay = (5 *60000);  // 5 minute in miliseconds

// Tracks the last time event fired
unsigned long previousMillis=0;

// Interval is how long we wait
int interval = onTime;

// Used to track if relay should be on or off
boolean relayState = true;

void setup()
{
  pinMode(13, OUTPUT); //Relay
  pinMode(3, OUTPUT); //LED Green for ON
  pinMode(4, OUTPUT); //LED Red for OFF

  digitalWrite(13, LOW);   // Relay Off
  digitalWrite(3, LOW);    // Green LED off
  digitalWrite(4, LOW);    // Red LED OFF

  //delay (start_delay);  // wait for 5 minute
}
void loop()
{
  if (relayState == true)
  {
    // Relay ON
    digitalWrite(13, HIGH);   // Relay ON
    digitalWrite(3, HIGH);    // Green LED ON
    digitalWrite(4, LOW);    // Red LED OFF
  }
  if (relayState == false)
  {
    // Relay OFF
    digitalWrite(13, LOW);   // Relay Off
    digitalWrite(3, LOW);    // Green LED Off
    digitalWrite(4, HIGH);    // Red LED On
  }

  // Grab snapshot of current time, this keeps all timing
  long currentMillis = millis();

  // Compare to previous capture to see if enough time has passed
  if ((unsigned long)(currentMillis - previousMillis) >= interval)
  {
    // Change wait interval, based on current relay state
    if (relayState)
    {
      // Relay is currently on, set time to stay off
      interval = offTime;
    }
    else
    {
      // Relay is currently off, set time to stay on
      interval = onTime;
    }
    // Toggle the relay's state
    relayState = !(relayState);
    // Save the current time to compare "later"
    previousMillis = currentMillis;
  }
}

Now issue is; when I make timer for seconds like OnTime is 3 second and offTime is 1 second... It works perfect... But timer for hours or minutes does not simply works... it does not switch state from on to off... It constantly remains on... What could be  the problem... Thanks!

You declare interval as an integer, while onTime and offTime are unsigned long.
Change int interval = onTime; to unsigned long interval = onTime;
The maximum value of int is only 32767 (215-1), which is only 33 seconds.
An unsigned long can be as high as 4294967296 (232-1). Which is around 49.7 days worth of milliseconds.

He has also an overflow in (5 *60000), which should be 5 * 60000UL

@EdgarBonet you’re right! Nicely spotted.

Just to point out: On PCs and Macs it is very likely that an int is 32 if not 64 bits. You have been surprised by the fact that it is only 16 bits on this platform.

You should not depend on millis() function for long time delays, use an extra rtc chip(DS3231/DS1307) instead.
Theoretically millis() function should produce 1 millisecond time frame, but it is not exactly that. There will always be a difference; and if you multiply that small time difference with a big number, then there will be a significant delay.

No clock is perfect. millis() long term accuracy is typically around 0.1%. An RTC should be significantly better. Whether or not millis() is suitable for the application has little to do with the length of the delays: it only depends on the required accuracy.


text:
How do i power recycle on SD card
I am working on my home made project where i am using SD card to log GPS data into it,As well as i have to access that data from the SD card on my computer while all the system is connected to battery power, so i also have a USB to SD chip USB2240 from Microchip, this SD controller suits best to my application, Because USB2240 has a card detect pin connected to one of the pin of Arduino, from which i can control interface of SD card between Arduino for logging and the computer for the USB..
But I have to Recycle power to the SD card whenever SD Card is interfaced with the USB controller USB2240.
So for an Example : when the device is powered 'ON' , The SD card is interfaced with the Arduino - which logs data to the card, But when i connected the system to my computer to get the logged file on my computer, Then it's not working, Here i have to disconnect power to SD card and Reconnect it...
How do i achieve Power recycle all on it's own when i connected to the USB OR to the Arduino.
Thanks

I just read the
USB2240 Part listing
and it looks really handy for interfacing a PC to the flash.
However, I believe you are taking the wrong approach by trying to power recycle it yourself.
To address your question about how to power recycle it:  If you are physically moving the connection cable then that should power recycle it automatically.
If not, then you have some other problem with your software not tolerating the disappearance then reappearance of the SD card.  In other works, it is likely a software problem.  The SD card should always remain connected so the software does not get confused and require a reset.
It is like how you need to eject USB devices in Linux.  If you don't, then you can get file corruption because the buffers may not be fully flushed.  Back in the day we used sync; sync; sync to ensure buffers were written out to storage devices, even just to do a normal shutdown.  Fortunately, modern Linux takes care of that, with the exception of USB flash memory.  With that you need to actually go through the eject process to avoid damage or system confusion.
But a much better approach would be to just leave it on one or the other.
Then use some sort of communications (it doesn't have to be USB) between the two computers for memory access.


text:
How to use Atmega1284AU with Arduino IDE
Is there any support to this chip in Arduino IDE, like bootloaders and boards definitions.. i want to use this chip with 3.3V and 8Mhz crystal speed..
I have seen Nick Gammon bootloaders supports this chip for bootloaders, but not with 8Mhz.? and how to add this chip to Arduino IDE.
anybody help..
thanks you

Please check out MightyCore library by MCUdude.
https://github.com/MCUdude/MightyCore
I have used it and can verify it works pretty well with ATmega1284.


text:
changing device signature in avrdude
I am trying to burn bootloaders to Atmega2560V and when I hit burn bootloaders it shows me this error

avrdude: Device signature = 0x1e9803
  avrdude: Expected signature for ATmega2560 is 1E 98 01

I know this device should have 0x1e9801, But I don't know why it's showing me this error.
I tried my luck by starting threads at AVRFREAKS but no joy.
One of my friend told to try changing the device signature in the avrdude from 0x1e9801 to 0x1e9803 for a temporary try.
How can I do that.? please please please anyone help.
Thanks

You should have, somewhere in your hard drive, a file named
avrdude.conf. My copy of the file has the following lines:
#------------------------------------------------------------
# ATmega2560
#------------------------------------------------------------

part
    id               = "m2560";
    desc             = "ATmega2560";
    signature        = 0x1e 0x98 0x01;
    ...

Try changing the line with signature. Alternatively, you could make a
new entry for your MCU like this:
#------------------------------------------------------------
# ATmega2560V
#------------------------------------------------------------
# Identical to  ATmega2560 but for the signature

part parent "m2560"
    id        = "m2560v";
    desc      = "ATmega2560V";
    signature = 0x1e 0x98 0x03;


text:
Atmega2560V, trying to burn bootloaders of MegaCore
I am trying to burn MegaCore bootloaders to it, I have setup my custom PCB  with Atmega2560V-8AU and 8Mhz Crystal + Load Caps all assembled on using PCBA process.
I am trying to burn MegaCore bootlaoders to it, I am using Arduino UNO as ISP Programmer. My connections are all correct, It shows different Device Signatures (see below) whenever I hit Burn Bootloaders....

0x0000ff
  0x00003f
  0x0000ff
  0x00ff00
  0x001000
  0xff0000
  0xfc0000
  0x00fe00

This is complete output with different Device Signatures

Arduino: 1.8.3 (Windows 10), Board: "ATmega2560, Arduino MEGA pinout,
  2.7v, Disabled (default), 8 MHz external"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude
  -CC:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-avr-100-pin\avr/avrdude.conf
  -v -patmega2560 -cstk500v1 -PCOM4 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xf7:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
           Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
           Copyright (c) 2007-2014 Joerg Wunsch
     System wide configuration file is "C:\Users\mudas\OneDrive\Documents\Arduino\hardware\MegaCore-avr-100-pin\avr/avrdude.conf"

     Using Port                    : COM4
     Using Programmer              : stk500v1
     Overriding Baud Rate          : 19200
     AVR Part                      : ATmega2560
     Chip Erase delay              : 9000 us
     PAGEL                         : PD7
     BS2                           : PA0
     RESET disposition             : dedicated
     RETRY pulse                   : SCK
     serial program mode           : yes
     parallel program mode         : yes
     Timeout                       : 200
     StabDelay                     : 100
     CmdexeDelay                   : 25
     SyncLoops                     : 32
     ByteDelay                     : 0
     PollIndex                     : 3
     PollValue                     : 0x53
     Memory Detail                 :

                              Block Poll               Page                       Polled
       Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
       ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
       eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
       flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
       lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
       calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 2
     Firmware Version: 1.18
     Topcard         : Unknown
     Vtarget         : 0.0 V
     Varef           : 0.0 V
     Oscillator      : Off
     SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions
Error while burning bootloader. Reading |

  ############################################ | 100% 0.02s

  avrdude: Device signature = 0x00fe00 avrdude: Expected signature for
  ATmega2560 is 1E 98 01
           Double check chip, or use -F to override this check.
avrdude done.  Thank you.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
What should be the problem.??? How to solve this.?

Also posted at:https://github.com/MCUdude/MegaCore/issues/63 and http://forum.arduino.cc/index.php?topic=494076

Yes and also at http://www.avrfreaks.net/forum/atmega2560v-trying-burn-bootloaders-megacore

Now that the problem has been solved, would you mind taking the time to answer your question so that it might help others? From the GitHub issue report, I know that once you were able to start reading a consistent (though incorrect) device signature the final step was to use the -F AVRDUDE option to override the signature check but it's not clear what the change was that you made to get from the inconsistent device signature readings to the consistent readings. I believe it was a hardware change?

I removed 8Mhz from board and followed this instructions LINK, and burnt bootloaders using -F override check, then i returned 8Mhz oscillator to Atmega2560V and see device signature and it's automatically appears 0x1e9801 rather than 0x1e9803

This is an answer.


text:
Running Atmega1284P at 3.3 and 8Mhz
can i run Atmega1284P at 3.3V and 8Mhz speed.? can i burn Nick Gammon Arduino bootloaders into the chip.?
Thank You

Atmega1284P 8MHz @ 3.3V?
Yes, you can. Documentation states this is permitted voltage for that frequency:  0 - 10MHz @ 2.7V - 5.5V http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42719-ATmega1284P_Datasheet.pdf
Nick Gammon Arduino bootloaders?
On this page http://www.gammon.com.au/bootloader it states Atmega1284.
In code https://github.com/nickgammon/arduino_sketches/blob/master/Atmega_Self_Read_Signature/Atmega_Self_Read_Signature.ino
there is signature for Atmega1284P so it should work without issues.

Thank you for replying,
Nick Gammon supports Atmega1284 with 3.3V and 8Mhz.? I am confused - web page states only with 5V and 16Mhz not with 3.3V and 8Mhz. :/

You may be right, I understood you asked only for burning bootloader in chip. If that is the case, than you either need to modify code (so to enable correct working on that frequency) or ask Nick Gammon to support that combination also. Please take note that only frequency is "problematic", voltage is ok if MCU can work at that voltage and speed.

The bootloader doesn't need to know the voltage at all - you set the fuses for the brownout detector via ISP.  And it will work even with a slower clock, however in the case of a 16 MHz bootloader actually running at 8 MHz, you'll have to configure the upload baud rate in Arduino (boards.txt or whatever it is these days) to half of what it would be if running at the designed clock rate - so if it was designed to be 115200, half clocking would result in 57600.


text:
Trying to turn off fading RGB LED after 30 secs
I am trying to get something to work so that an RGB LED fades through the color spectrum, and when a button is pressed some music plays.
That is not the problem.
Assume I am using any loop that functions can be called at any time in.
I am trying to make it so that if the button is not pressed for a certain amount of time, say 30 seconds, the light stops fading through the color spectrum and when the button is pressed in this 'sleep mode', first the light starts fading, and then the next press plays the music.
I am aware this could be done somehow with millis();, but how would I approach this?
I am using an Arduino Uno.

If it is working now as you want it. Please consider accepting the answer that helped you in order to indicate to others that this issue has been resolved. Thank you for your cooperation to make this forum better.

Here is a little snippet of logic that you can implement in your code :
if(millis() - getOutOfSleepTime >= 30000) {
    activateSleepMode();
    while(!buttonPress);
    getOutOfSleepMode();
    getOutOfSleepTime = millis();
}

if(buttonPress)
    activateSleepMode();


text:
Arduino uno r3 not powering up
i bought two arduino uno r3 card (not original)
one is working perfectly:

the other is not powering up (no led is lit), i did some measuring and i found that two usb connector pins on the board are shorted, how can i proceed to repair it taking in account that it works from time to time !

thank you
More images:

Use a De-Solder and remove the solder that is shorting the two USB connector pins.

hi mathsman, there is no solder between the pins, i guess it's one of the electronic component of the board that is causing the two pins to short, but the problem is how to identify it

Is there any connection in the PCB itself?

yes, on of the pins is connected to ground

No, not that, I meant that is there a connection between the shorted USB pins on the PCB itself?

Check the board under a loop/microscope, to see if any components or connection look off. A short between 5v and GND is pretty difficult to detect. You can check the resistance on different location, and see if it's slightly lower/higher. The lower the resistance, the closer you are to the faulty component. But for that you'd need a high precision multimeter. My first guess is the electrolytic capacitor, but that's just a wild guess. Could you post a hi-res photo of the defective board?

If not, it is really difficult to do anything as almost all components in your board are surface mounted.

Hi @Gerben I don't suppose that everyone has a Microscope or Very High Resolution Cameras . Instead , a magnifying glass is much better.

ok i'll upload more photos in a few seconds

Take pictures with a Magnifying glass If you have no High Resolution Cameras.

Sorry. I meant loupe, not loop

no problem sir, i added two photos,
http://s23.postimg.org/y8o4fj9mz/SAM_1432.jpg

http://s11.postimg.org/6ukiv3khf/SAM_1434.jpg
the photos in the post are resized, check the direct link for full size photos
thanks

I see nothing that's obviously wrong. Can you be more specific about "works from time to time"? What happens if you power it from the Jack (only test for a few seconds, as there is no polyfuse, like there is on the USB)?

the first time i connected it it worked for a few seconds then went off, after disconnecting and reconnecting it a few times it worked again, i programmed it and everything was fine, and now it won't work again, thats what i meant by from time to time, for the jack it's the samething as the usb port, i plugged a 9v battery to it and it didn't work

oh man, it's working again right now, this is confusing
http://s30.postimg.org/aesf9tvgx/work.jpg

It looks as though there may be material between at least one USB pin and the ground layer. This may be flux of solder 'splash'.
If visual inspection shows that this may be the case I would try carefully scratching with a sharp poibt (eg scriber) along at least the green arc on the image below. Be careful not to break intended conduction paths (eg as shown in black).

Since it's intermittent I'd try two things:
Easy: Briefly reheat each pin of the USB connector and it's pad, the goal being to make sure the solder joints are solid. Clean away any solder bridging the pads. Of course you can only reach the back side of the board, but this is an easy first step.
More thorough: If the first step didn't get it working, then try desoldering the USB connector, using a solder pump and desoldering braid to remove as much of the solder as possible from all four pins before you try to actually remove the part. Work slowly giving it time to cool between steps so you don't overheat anything. When the part is removed, inspect the top of the board and clean up any solder bridges. Inspect the bottom of the USB connector where it touches the board and clean it, too, if necessary. Then solder it onto the board again using as little solder as necessary to make solid connections.

i'm going to desolder the usb connector because i'm pretty sure it is the source of the problem, when i partially plug the usb cable it works. thanks


text:
How can I add phonebook entry to sim card using Arduino GSM shield?
I am using Arduino GSM Module and Arduino UNO

I want my GSM module to be stand alone once I programmed it. It will store the phone number of the user if he sends a correct passcode. Since I want the data to available even after I power off my module. I need to store it to my sim. I don't want to use an SD card shield or store data to arduino's EEPROM.
I have read Getting the contacts/ storing contacts to SIM card. The only clear reply is reading from the SIM.
Is it possible to add phonebook entry to SIM card?
Do you know a tutorial?

.
Hope this helps.
Go check out (http://m2msupport.net/m2msupport/sim-phonebook-at-commands/) I use these commands on my AI Tinker A7 board for the Arduino.... 95% work perfectly...
Cheers,
Capt.K
ps. I made these numbers up but the formats are all correct.
//----------------------------------------------------------
//---Add Entry To PhoneBook:
//----------------------------------------------------------

AT+CPBW=1, "+61416199234",145, "Paul"    //-- add entry x1

OK

//----------------------------------------------------------
//--DELETE phonebook entry:
//----------------------------------------------------------

AT+CPBW=1  //-- delete entry x1

OK

//----------------------------------------------------------
//-- AT+CPBW=[<index>],<number> [ ,<type> [,<text>]]
//----------------------------------------------------------
//
//<index>   = Entry Number in SIM Memory
//<number>  = "The Phone number"
//<type>    = "The Phone Number" (TYPE ) ie. 129,161,145,177..
              //  129 – National number type
              //  161 – National number type
              //  145 – INternational number type
              //  177 – Network specific number
//<text>    = "Person Name" etc.

//----------------------------------------------------------
//  Add 4x new entries to the SIM card
//----------------------------------------------------------
AT+CPBW=1, "+61416199234",145, "Pops"
AT+CPBW=2, "+61420921234",145, "Mum"
AT+CPBW=3, "+61733728171",145, "Wendy"
AT+CPBW=4, "+61356821234",145, "Mr Smith"

//NOTE:  In Australia (above examples) the actual phone numbers
//       above are of these types
//
// Int.Format    Aust. Dial Internal       Phone_Type
// -----------------------------------------------------------
// +61416199234  (0416) 199 234             Mobile/Cell
// +61420921234  (0420) 921 234             Mobile/Cell
// +61356821234  (03)   5682 1234           Landline/PSTN


text:
Duemilanove serial TX/RX: which is what?
I want to use the GSM shield. For my project, I will hook it up directly to pins 0 and 1 (TX/RX). Will it work right away? Do I have to know which is TX and which RX and declare it?
I will not be using SoftwareSerial.

I will not be using SoftwareSerial

That means you'll use the standard Serial() library.

Do I have to[...] declare it?

Not if you use the standard Serial.begin() instruction. The Duemilanove uses pins 0/1 automatically for TX/RX

Do I have to know which is TX and which RX?

Kinda... you have to know which one is which so you wire it correctly. The TX of the board should go to the RX of the GSM shield, and vice versa. Pin 0 is RX and 1 is TX.


text:
Arduino diy wireless
Is it possible to do simple wireless on an Arduino, digital, or analog (SDR)? I would like to hook one pin to an antenna (or piece of wire) and generate signals with simple modulations (analog or digital).

You really need to expand on your question: what is it you are trying to achieve, what data rates are you looking for, what range. Be more specific

"AVR-based FM-transmitter" describes a FM audio transmitter implemented by an overclocked ATTiny45. Within limits, this idea should be adaptable to an unmofdified Arduino but probably this would cause an FM transmission on a frequence not covered by common receivers.

"Hook an antenna to your Propeller, and listen to the radio! (New shortwave prog)" describes a shortwave receiver implemented unsing a Parallax P32x8A controller. Maybe some other readers here can estimate the power needed for this hack... perhaps a DUE could do this too?

You might also like this (quite unrelated) raspberry PI PWM FM modulation.

here there's a nice tutorial on how to obtain it.
Basically it sets the registers so that a pin outputs a PWM signal at 800 kHz and then modulates that signal in code by just switching the pin and off (pinMode set to INPUT or OUTPUT). If you plug a cable (20 cm and on) to pin 8, and tune your radio to 800Khz you'll hear some noise going on and off.
If you read down the forum you'll see people suggesting how to actually send tones, by putting a very small delay (delay(1)) between the on/off of the pin.
In this link they guys have ogn further and they even implemented a morse code library.
Now I am trying to figure out a way to do the same for a receiver.

Based off of what you have said, the simplest way to achieve what you want to do with your Arduino would be to use a WiFi shield, and setup the Arduino to function as a web server. I have included two links: the first link shows you Arduino's sponsored WiFi shield and explains the basics of how to use it. The second link addresses your question of using the Arduino+WiFi shield to generate WiFi signals, by setting it up as a web server. Both links contain sample codes from Arduino that you can copy and paste. Assuming that you are using the native Arduino software, you can also go to: File > Examples > WiFi > WiFiWebServer, and the same code from the Arduino websites that I listed will be there for you to use.
http://arduino.cc/en/Tutorial/WiFiWebServer
http://arduino.cc/en/Guide/ArduinoWiFiShield
Personally, I would always recommend that whenever you want to accomplish a certain task, such as WiFi signal generation, displaying characters on a LCD, or anything else, you search for a shield to use for that application. Shields always make life extremely easier. I hope this helps. :)


text:
Building a gps system
I'd like to build a simple GPS system. It should be very little. For the software side, I will build an API, so from my PC/smartphone/whatever else I could ask the GPS system where it is located (I think Google provides this kind of feature).
How can I do this? My main problem is the GPS and the its building. I'd like to build the smallest thing possible, because I have to hide it. My idea is to hide this GPS system in my bike: I'd like to locate my bike if someone stole it. As you can see, internet is a problem.
I'm not asking to design anything. I would only know what I need to build a basic GPS system that has just the feature described. What do I need? Is it possible to do it? Does GPS require Internet connection? I would know if I could make it or not without internet access.

I reopened this and cleared out the comments. FYI just be as clear as you can next time :)

"I'd like to build the smallest thing possible, because I have to hide it." ... check out http://www.dx.com/ or similar sources for e.g. "GSM/GPRS/GPS Tracker". I bet building something like this yourself will cost much more and will end in a much bigger size.

"Is it possible to do it?"
Well... everything is possible :-)
"Does GPS require Internet connection?"
GPS doesn't require internet. A GPS receiver (e.g. http://www.modulestek.com/prodts/GPS/Mars740-mini/Mars740-mini_SPEC.pdf) is connected to the reading unit via USB or a RS232 interface. The protocol is very simple. However it only provides latitude and longitude. If you want to have an address, map data is required (for this you would need internet - or a large memory).
And of course such a system requires good signals from the GPS satellites.
"What do I need?"
First you need a GPS receiver (see above).
Second, you need a microcontroller unit which runs your application and does all the control of the external units.
Third, you need a GSM module (e.g. http://www.exp-tech.de/Shields/Wireless/GSM-GPRS/adafruit-fona-mini-cellular-gsm-breakout-sma.html) to send a message.
Don't forget the antenna for connection to the mobile communication network.
Fourth, you need a power supply. Ideally it has a battery which can be reloaded when driving.
As you may see, if you put all this together you are far from the "smallest thing possible".
Actually any modern smartphone could be enough. Mount it "invisible" under your saddle, connect it to a bike charger, find the proper App and that's it - although it might not be the smallest solution.
I don't know any, but I'm sure there are products off the shelf that fulfil your requirements, designed and developed by experienced engineers, and thus smaller and maybe cheaper than what you ever could achieve on your own.


text:
Arduino Wire Types?
I don't know what wires to get for my first Arduino project. I am planning on getting a pre-made light strip that I would control with an Arduino from across my room. Is there any specific type of wire to get? It needs to be about 15 feet. There are so many choices, but I don't know what I need. Does anyone else know?

What light strip? How long do you want the wire to be? What are your needs? Do you have an unusually hot/cold room? (Kidding with the last question :D)

Choosing wire all depends on what you're going to do with it, and most of the choice is based on how much current it will carry and how durable it needs to be. Generally, you're going to use insulated copper wire - aside from that, your answers are mostly here: https://electronics.stackexchange.com/questions/16948/choosing-the-right-type-of-wire
For experimentation - which you will need to do a lot of before attempting your goal project - you can use the little wires which come in the Arduino starter kit. They are "jumper wires" designed for use on a bread board - they can not carry large amounts of electricity.
This product here: https://www.sparkfun.com/products/8431 - these have "male" ends designed to be stuck into the holes in the breadboard, and connect to the holes on the headers of the Arduino.
Here's an example of a project laid out on a breadboard:

None of those wires carry a lot of current. If you're hooking up 50 LEDs that might be almost a full 1-AMP of current, so I would use thicker wire. Do yourself a favor and start with a kit like in this video, learn the basics, then attempt a 'real' project. Every Arduino user should be able to do all the experiments in the training book and understand them. You will be lost if you jump in deep right away...
https://www.youtube.com/watch?v=pf4qosqpv3A

While you can indeed use these stranded wires with solid ends, they may tend to break at the junction.  Plain 22 gauge solid wire works too, and is cheaper.  High power loads should not be drawing their power through the arduino board anyway.

Thanks Chris. Yes that's very important. It's covered in the video how to do that. Shows how to run the lights and the Arduino on two different power sources.


text:
Lockup while evaluating Wire.requestFrom function (Arduino)
I am currently working on a Arduino project that combines an InertiaOne IMU sensor board (from Atmel), with an Arduino UNO and two motors driven by a Makeblock driver board. All sensors communicate using I2C, with different addresses. My issue is that the program runs just fine for a while (everything between 1 second and 2 minutes), but suddenly lock up inside the Wire.requestFrom-function that handles I2C communication. More specifically, I believe that the code hangs at one of these points in the Wire library (the code is a direct copy):
...
// wait until twi is ready, become master receiver
while(TWI_READY != twi_state){
    continue;
}
...
// wait for read operation to complete
while(TWI_MRX == twi_state){
    continue;
}

As far as I know, there are only two units that utilise I2C in the system, both of which are embedded onto the InertiaOne circuit board. What I find very strange is that reading these two sensors works just fine when no motors are running, but that the problem occurs when the motors are activated. My first reaction was to use separate power supplies for the motors and sensor board since the issue could have been caused by a dip in the voltage and a reset of the sensor board, but without any change of result.
I am running out of things to try, and do simply not have the required understanding of I2C and embedded systems to see what exactly the issue is. Could it simply be that some of my parts are faulty, or am I perhaps overlooking something?

Thanks for your comment, Dan! I'm starting to believe that the Arduino itself locks up / resets / whatever, and not the IMU unit, which I previously though was the problem. I will try adding timeout methods and recovery code for the TWI library, as was previously suggested above. Without the equipment to investigate the I2C communication or power levels accurately, I believe recovering from the issue will be much easier than actually solving it at this point!

The Wire library has an issue in the lines you posted, that if an interrupt is lost, it will stay in that loop forever. There are two things you could do to fix this:

Stop the interrupt from being lost (ie. fix electrical problems)
Use a library that has a time-out.

For the electrical issues, I would make sure you have pull-up resistors from SDA and SCL to +5V - typically 4.7k (for each one), but that would depend a bit on whether the device already has them. Also make sure you have decoupling capacitors on the Vcc lines as appropriate.
For the software side, there is an alternative library (master only) at
Arduino I2C Master Library.
I haven't personally needed to use that library, as with pull-up resistors and short cable runs, I haven't had problems with the Wire library. However if things are marginal you may well find that it helps.

It is a shame that a library which is so horribly bad programmed found it's way into Arduino core. Obviously there must be a timeout!

True, some parts sacrifice reliability for simplicity. The good part is, you can always write your own, or just take the existing one and modify it. It's not like the libraries are distributed in binary form only.


text:
Moving an item on a pole, can an Arduino work for my project?
I'm a computer programmer, but I've never done anything with Arduino. I'd like to build something that holds a polisher (this one, in specific: http://www.homedepot.com/p/BLACK-DECKER-6-in-Random-Orbit-Waxer-Polisher-WP900/202516385) on a metal pole, and moves the polisher up and down (vertically) on the pole at varying speeds (I'd like to use arduino to control the motor/speed)?
Is this the sort of thing Arduino would be able to do? If so, can anyone point me to any motors that would work? If not, any tips on where else I should look?

Any MCU will do. Arduino happens to have one.

I'd suggest moving the polisher horizontally. That way motor doesn't have to be as strong, as it doesn't have to contest with gravity.

@Gerben - If you use a vertical configuration with a counterweighted pulley, then the motor would hardly have to contest with gravity at all. It would just need to overcome friction.

I am also a software guy by profession. I've always liked tinkering with electronics, and have recently gotten into Arduino. It is an excellent platform for developing hybrid hardware/software solutions for problems like this. It is very easy to use, both hardware and software.
There is a large ecosystem of add-ons called "Shields" that just plug in. You can probably find a motor control shield that will do exactly what you want.
Your biggest challenge, I think, is going to be mechanical. How will you hold the polisher in position, and make a mechanism that will raise and lower it?
Off the top of my head what I come up with is a U shaped metal bar with a threaded rod in the opening of the U. You'd build a "sled" that would grip the bar and would have teeth that would grip the threaded rod. Then your would have a motor on the end of the assembly that would turn the threaded rod to move the sled up and down on the bar. You'd attach the polisher to the sled. You'd probably need a spring or rubber holder so that the polisher would press gently on the surface being polished but with some freedom of motion.


text:
Alternatives to Wire library for I2C
I am looking for (reasonably easy to use and well tested) alternatives to the Wire library. Wire works very well, but: I only need the Arduino to act as I2C master and the Wire library seems to be a real waste of resources:
My goal is to send out data en bloc (e.g. 32 or 64 bytes). This data is already sitting in an array in SRAM. Now when you use the Wire library, you call the TwoWire::write function which copies your data into a 2nd buffer. Afterwards, Wire makes use of the TWI library where twi_writeTo copies the data again into a 3rd buffer. That's a bit clunky, isn't it?
I have seen the DSSCircuits / I2C-Master-Library but I am not sure how mature it is because there hasn't been any commit after the initial commit which is 3 years old now.

Do you actually have ram usage problems? Optimizing something before it becomes a problem is often a wasted effort.

It all comes down to the question of wanting to make it work soon and/or portably vs wanting to make it work optimally.  You are of course free to get the ATmega programmer's manual and write to the peripheral registers yourself.

dsscircuits' Arduino I2C master library webpage shows five revisions of the I2C library that your github link is for.  It probably is an ok starting point for the revisions you have in mind.  If Wire has had corrections since Jan. 2012 you might need to add them to I2C.

Alternatives to Wire library for I2C write your own. i2c is one of the easier protocols to write from scratch.

I don't see any objection to using DSS Circuits I2C Master Library.
It may not have been updated for a couple of years, but if it works it doesn't need to be. It's not as if libraries for micro-controllers have to support new printer drivers, video drivers, etc.
If it works, it works.
The chip hasn't changed, and the only real reason for updates these days is if the IDE changes (or the compiler changes) in such a way that it introduces compile errors. Such things have happened fairly recently with things like PROGMEM having tighter rules, for example.

This library looked very promising, but note it does only support AVR targets. Since Arduino cores have been developed for a variety of architectures, this library will not "just work" for any Arduino-compatible board. For example, it is not compatible with Adafruit's STM32F405-based Feather

Also Procyon AVR library worth be checking. It is a bit old now but very professional and kinda minimalistic. Not much dependencies, should be fine to use just I2C module only. There is hardly anything new in AVR I2C part since.

Cosa TWI class is a very different approach to I2C device driver support. It does not use any extra SRAM for buffers at all. If a device driver is non-blocking it must handle the necessary buffering. Also the Cosa TWI class supports typical interaction with I2C devices such as master/slave, "write register-read data"-patterns, and transactions when using multi-threading.
A software and hardware Arduino-TWI library is available. It uses the Arduino-GPIO library and can be used on AVR and SAM based boards.
Some examples: TWI Scanner, DS3231 Real-Time Clock/Calender, I2C LCD Adapter with PCF8574.

You can use completely different approach to the top question. Asking for alternatives you have given reason to this: getting rid of unused code in the binary. You can achieve removal of unused code without actually using alternative library. Please keep in mind, that you can instruct the compiler and linker to exclude unused code from the compiled binary. Just use compilation flags:
CFLAGS += -Wl,-static
CFLAGS += -ffunction-sections
CFLAGS += -Wl,--gc-sections

Rach function will be in its own section.
LDFLAGS += -Wl,-gc-sections

This tells GCC to send the -gc-sections flag to the linker which will remove
unused sections. And voilla! Unused sections are removed.

I made 2 libs myself for easier use and consistant calls:
one for AVR targets:
cI2C
another using the same functions for all other targets (which basically is a wrapper for Wire library):
WireWrapper
Both are available within the IDE library manager.
They both work as master without using interrupt and are tested on different targets with different slaves:
- UNO, Nano for cI2C
- Zero, Due & ESP8266 for WireWrapper


text:
Transient and reverse current
Does anyone know (1) how much transient current can be output from a pin and (2) how much (and how long) reverse current an output pin can take?  For instance, consider the following circuit (driven by a series of 10 ms pulses at 5V):
  o----------------
       |          |
       = 10µF    1k LOAD
       |          |
  o----------------

which would be a classical filtered (smoothed) PWM circuit.  When the pin goes to +5V, the capacitor would act like a short and allow very high current (assuming about 20 ohm impedance, maybe 250 mA) for a millisecond or so.  Similarly, when the voltage drops to 0V, the charged capacitor will discharge, leading to a reverse current until it bleeds through the load.  Will either of these damage the diodes in the pin or even the IC?  Thanks.  (Worse comes to worse, does this mean that a resistor and diode are needed to protect the pin?)
More info
1)  It's 10µF.  10 pF would be useless in a power supply, it would only store 0.05 µC of electricity at most, which would only be able to smooth the output for a few microseconds.
2)  The load is resistance, 1 k ohms.
3)  A diode would be handy if you wanted to prevent reverse current, since you could put a much larger diode outside than the protective diodes in the Arduino.  They are classically used with motors (inductive load) as a clamp diode.
4)  My general question is about high transient current or reverse currents.  A capacitor is just an example of a situation that could cause this.  Another example would be a pin that is putting out only occasional (for example) 1ms long 100 mA pulses, separated by many seconds.  Such a circuit is really not delivering much power, but for very short periods it exceeds that recommended 40 mA.  Would this burn out the pin or not?
5)  A capacitor in parallel with the load is pretty much the classic filtered DC power supply.  Open any wall wart you have and you'll see a transformer, a rectifier and several large (electrolytic) capacitors (along with a couple small ones) and a voltage regulator.  Closer to this example, say you want to deliver current at 2 volts DC.  You can do this by alternating 2 ms pulses (at 5V) with 3 ms at 0V.  Then have a capacitor in series to smooth it to closer to DC, making it more like analog output.  That is, in fact, exactly how adjustable power supplies often work.

By 10 mmF do you mean 10 pF?

Without a resistor the filter won't do much filtering anyways. So just add it. Don't see why you'd need a diode. Voltages won't go below 0v or above 5v (unless the load is an inductive load (e.g. motor).

It sounds like you are trying to make a digital to analog converter driving some type of load.  Look at this link: http://emesystems.com/BS2PWM.htm
It will give you a start. Please note they use an opamp as a buffer.
This 'buffer' has a very high input impedance and a low output impedance.  It can drive from a few mills to over an amp depending on the opamp chosen.  Additional circuitry can get you into thousands of amps if desired.  The schematic is a 2 pole filter originally designed for the Stamp microcontroller.
The filter soothes it out but adds a delay on the final output value (settling time).  The greater the filter capactance the lower the ripple and the slower the response.  You can add another pole to filter if you want.
As a bit of information from an old semiconductor guy absolute ratings are just that.  If you exceed them even for a few nanoseconds you can be sure you damaged the device, you just do not know when it will fail.
I have seen a lot of microcontrollers damaged because of capacitors connected to the pins, power excluded, doesn't matter if the pin is input or output.  When the power supply collapses it will inject current into the microprocessor substrate possibly damaging it.
Good Luck

I have had fairly lengthy discussions with Mike Cook from the Arduino forum about this sort of thing. I asked, for example, if it was OK to drive LEDs by PWM providing the duty cycle was short enough that "on average" the pins put out a current in specified range.
His answer always is: no!
The datasheet does not say you can exceed the absolute maximum ratings for a certain amount of time (like 1 µs). You are not supposed to exceed them at all.
It doesn't take a particularly large series resistor to limit current to the recommended 20 mA (250 Ω at 5 V).
Now you can probably "get away with" not using it, but you are basically moving into unsupported territory. If the chip fails after a year, don't blame the manufacturer.

It's 10 microFarad = 10mmF. 10 picoFarad would be useless in a power supply

According to Wikipedia:

A "micro-microfarad" (μμF, and confusingly often mmf or MMF), an obsolete unit sometimes found in older texts, is the equivalent of a picofarad.

Your use of mmF as a replacement for µF is confusing. I suggest either copying and pasting "my" µ from this post, or using a simple "u" instead.

... useless in a power supply

Surely you are not seriously suggesting that you are going to make a power supply, powered by an Arduino output pin?
I am presuming not, so perhaps if you describe your application?


text:
Serialprint and analogRead time
How much time takes to print each sample using Serial.print and analogRead in each iteration?
#include <SoftwareSerial.h>
#define Sensor A0
void setup() {
  Serial.begin(250000);
  pinMode(Sensor,INPUT);
    }
void loop() {
  Serial.println(analogRead(Sensor));// RUN TIME??
}

It depends on how full the buffer is and how big the value being printed is.

@Majenko The sensor output is between 0 and 100 in serial printing.

It is quite complex to work out how "long" it will take to print.  Why?

If there is room in the serial buffer then the text just gets placed in that buffer. Takes almost no time at all to print.
You are printing a variable length string. The longer the string the longer it will take to print if the buffer is full.

However:

Each character consists of 10 symbols (8 data bits plus 1 start and 1 stop bit).
Characters are transmitted at 250000 symbols per second
Thus each character takes 1/(250000 / 10), or 40 microseconds to transfer through the actual wire.

So printing the number 100, which also has \r\n appended to it (characters 13 and 10) would need 5 characters. If the buffer is full it will take about 5*0.00004s = 200µs. If the buffer isn't full, it will take a fraction of that to just copy the data into the serial buffer.

1000 rounds of analogRead() takes about 100ms.
sustained serial writes will depend mostly on the baud rate picked.

Thanks, do you have a document indicating CPU cycles for different operations?


text:
Identification of IoT
For a school project I Have to make an IoT solution in the retail. We were thinking of a smart clothing hanger. We want to make the hanger smart enough to recognize what clothing is hanging on it. In order to do so the clothing has to be able to send some sort of ID to the hanger.
first thing we thought of was RFID but the hanger next to an one hanger would pick up the signal from the other hanger so that wouldn’t be an option.
Does anyone have any other ideas on what we could try to let the piece of clothing talk to the hanger?

if it's not too late, i would re-roll the dice on a topic (if it has to be practical)

What about manikins that move when a LDR detects movement nearby.

@sa_leinad Interesting idea but I think people will be scared if a manikin suddenly moves.

Well I guess the signal strength could be measured but clothes hanged in wardrobe are too close to each other to distinguish them. Maybe close range NFC?
I have other solution to be considered.
Maybe you look at the wrong touchpoint of that interaction. What if the desired action occurs not while it's already hanged but when user put the clothes on hanger? During that, it's not with other clothes (as you grab the hanger in your hand to put the clothes on it).
There are a few things to consider. I guess people put things only on one hanger at once while having clothes in second hand. How many % of users puts clothes on hanger by grabbing it outside of wardrobe (as mundane event/behavior)?
Why it's important?
During that interaction there is a moment when user tries to pair single cloth with single hanger separated from the rest.
The hanger could have additional sensor to know when it happens:

Magnetic field sensor and small magnet in collar?
Capacitive sensor?
Accelerometer?

...so the device will know when that interaction occurs and then activate the reading from single rfid tag.
I guess my answer is more about user experience and the aesthetics of interaction but it can give you some clues to finish your project.

Your answer is great. It opend my mind a little bit. Thank you!


text:
Power maximum output power for each pin
A have Arduino Mega 2560. I found in the spec that the maximum output current for each I/O pin is 40 mA.
Can i use 40 IO in parallel? That's mean 40*40ma*5 volt = 8000 mw = 8 watt.
What about the heat?!

There are also limits on the total power of groups of pins,

The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed
  200mA.
The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.
The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA.
The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.
The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.

So you are already limited to 800mA.
Secondly, you have to be careful to change all the pins at exactly the same time. Otherwise some pins will be low, and others high creating effectively a dead short. Or if you make sure the pins are inputs before changing, some pins will be on sooner, and those pins will then for a short period, handle all the current, and thus exceeding their limit for a brief moment. Which isn't that bad, but still not ideal.
So definitely don't use digitalWrite to change all the pins, one after the other.

No, you can't.  Read the rest of the specifications and you'll see why.  Also the 40mA is wrong. That is the absolute maximum. 20mA is the guaranteed limit for steady-state IO.


text:
Programming arduino with Objective-C
Can you use clang, with --mpu=arm, etc. and avrdude to program an Arduino Due (Arm Cortex M3)?

theoretically possible or practically possible?

It's actually the other way round: C/C++ is a subset of Objective C (or more accurately, Objective C is based on C/C++).

OK So programming directly in Obj-C is not a good idea, but if you where dead set on doing it you could look at a tool which translates the Obj-C into C/C++ and then compile the output.  There are/were tools like this around I had to use one to do C++ to C many years ago.

It can be done, however, it is inadvisable. In order to implement this, one must implement the Objective-C runtime, which, though not insurmountable, is very near insurmountable as far as difficulty is concerned. Perhaps someday some brave soul will see fit to grace the world with their custom Arduino Objective-C runtime, but until that day, the rest of us mere mortals have naught to do but wait for the coming of the Objective-C prophet.
If there are any brave souls in the audience who wish to take on this ultimate challenge, then let them. But otherwise, keep the code in C and hold your peace.

Simple version: No, you cannot program Arduino using Objective-C.
Long version:
The Arduino IDE uses avr-gcc as it's compiler, and avr-gcc is a C/C++ compiler, not an Object-C compiler. The Arduino libraries are written in C/C++.
There are other compilers that exist for AVR processors, and so it is possible to use other languages for the AVR.
However, if you switch to a different compiler for your code, you will not be able to use the Arduino libraries with it, because they are written in C/C++ for the avr-gcc compiler. (It may be possible to compile the Arduino libraries with avr-gcc, and then link them to your code using external language linking methods, but that could be a significant challenge.)
Also, I do not know of any existing Objective-C compilers for AVR; it's possible one may exist, but after a quick web search, I didn't find any.

Theoretically, many things are possible. There is an easy way to code Arduino on Xcode with EmbedXCode (http://playground.arduino.cc/Main/EmbedXcode), but in C and CPP.
You need a compiler that will compile your Objective-C to for the AVR (if you are using an AVR-based Arduino), this may be difficult to find. Once your code is compiled, then you need to upload it to the Arduino.
So in any reasonable means, it is at least very challenging.