text:
Trying to understand Arduino products
Background:
I am new to Arduino world, and I like to buy a board. I am a bit confused how Arduino products are being sold. Coming from Raspberry world, it seems that I don't know what actually Arduino is.
Question:
I am trying to understand what is it that this product offers:

.

Why it says "For Arduino UNO R3"? 2. Isn't it actually an "Arduino UNO R3"? So why it says "For"?
What are MEGA328P and CH340? Does "Arduino UNO R3" comes with other chipsets?

It sounds to me like an Arduino Uno clone.

Why it says "For Arduino UNO R3"?

I would read that as "For Arduino UNO R3 projects" (ie. Uno-compatible).

Isn't it actually an "Arduino UNO R3

No, it's a clone. Or not really a clone (see below) because they used different hardware. It is compatible with the Uno in most respects.

What are MEGA328P?

That is the main chip on the board (actually an Atmega328P).

and CH340?

They have saved money by using a CH340 USB-to-serial chip instead of the Atmega16U2 used on genuine Uno boards. You may need to install a different driver to make that work. I disagree with the other answer(s) that this is a separate board or chip. It is clear from the photo of the chip near the USB socket that it is a CH340 chip there. See, for example https://hackaday.com/tag/ch340/ from which I quote:

The cheapest USB to serial chip on the market appears to be the CH340G, available for 20-40 cents apiece from the usual retailers. There is, however, almost no English documentation, and the datasheet for the CH340 family doesn’t include this chip

They used it because it is cheap.

Does "Arduino UNO R3" comes with other chipsets?

Yes the genuine one comes with an Atmega328P (main processor) and Atmega16U2 (USB interface).

Having said all that, the Uno is a good all-rounder starting board to get going with Arduinos.
Note that they are using the SMD (surface mounted) main processor chip. If you fry it you need to replace the whole board, not just the chip. However the entire board is quite cheap. :)

This was very helpful. Thank you!. One more set of questions and I am good to start :).Is there any good reason I should avoid this type of Colne?  Should I try to find a clone that uses both Atmega328P and Atmega16U2?  This board was sold 222 times all five stars, but I wonder if I should avoid CH340?

@AllanXu The CH340 is ultra-cheap. That tells you most of what you need to know: you get what you pay for.  When it works its fine. Don't expect it to be rugged. There are reports of them being killed very easily by static. The drivers aren't good and have caused problems in the past for people. Avoid it if you use OS X Yosemite or you may end up crippling your whole system. How did they get it so cheap? By cutting corners of course - and that means it's less reliable.

You can't really lose much by trying it at that price. However my experience of a cheap Ethernet board from eBay was that it didn't work nearly as well as the official one.

The board in the picture is not an official Arduino board. It is a clone.  You will note that in the picture the board does not say "Arduino"  It may be 100% compatible or it may not, you have to decide if the low price is worth it.
If you want an official board you should check either http://arduino.cc or http://arduino.org to find official distributors. (see this question for information about why there is both arduino.cc and arduino.org).


text:
Best way to make an Arduino switch 8 12V LED's
I'm trying to switch multiple 12V LED's with my arduino, based on the input of a (serial-in parallel-out) shift-register.
The 12V comes from a separate battery, so I can use 8 mosfets to get my 12V, and I might even put a parallel-in serial-out shift register in between.
But I'm hoping that there is a cleaner way of doing this.
Is there some kind of component that combines a shift register and a mosfet?
Any ideas on the best way to solve this?

What kind of amperage do these leds use?

The manual that came with my LED lights mentions 90mA per LED.

How about using optocoupler pc817?

ULN2803 FTW, 50v 500mA max, 8 channels, available everywhere, including as boards to plug onto an Arduino

I would recommend using something like the STP08DP05.  ST Microelectronics makes 16 and 24 bit versions as well.  You can also find TI and NXP parts that will do basically the same thing.
With these parts you can hardwire your max current value with a resistor to make sure you don't overdrive the LED.  Just because you can drive the LED at 90mA, doesn't mean you should... it will probably be way to bright.  The IC's can also be daisy-chained to your shift register and you can drive very large strings of LEDs... or use them for RGB LEDs.
Hope that helps!
EDIT - Based on Comments
There are a couple of options.  Note the Vdd represents the voltage supply to the IC itself and the nominal operating voltage is 3.0V up to 5.5V (I'm honestly not sure why they even added 7V as a max value when they specify 5.5V on the next page).
So, Vdd is not necessarily the voltage that your LED's are driven at.  You can drive the LEDs at 12V  (if you need to) and add a series resistor to the OUT pins of the IC's to dissipate the extra heat.
You would probably be fine with 200 ohms per pin.  If you set your current at 20mA, and assuming a 2.2V drop through the LED, that would give you approximately 5.8V at the OUT pins and the IC wouldn't have to dissipate much heat in terms of power.
However, if you don't need to drive them at 12V then I wouldn't bother.  Usually the forward voltage of an LED is 1.8 to 3.3V and you don't need 12V.  However, if you are driving a lot of them then it may be easier to use the 12V.  There are always trade-offs.

That one indeed looks like what I want. I only do no fully understand the schematics. When the max Vdd is 7V. How can I get a Vo of 12V. Or do I have to hookup the OUT pins to the LED cathodes?

I agree with Embedded_Guy. Here's a link to an instructional YouTube video I made for this. It includes a schematic and Arduino code. https://youtu.be/x20uNWz1Res

source: Stack Exchange

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

sort: votes


text:
Math with analog input values coming out wrong
Im getting stuck in a while loop because Im having trouble running a calculation on some sensor values. When I read my four sensors values and compare the ratio of the first two to the second two, I keep getting 0.00, no matter what the values are. Here's my code:
while ( ( (frontleft + frontright) / (backleft + backright) <= 0.8 ) || ( (frontleft + frontright) / (backleft + backright) > 1.2) ) {
    if (backleft + backright > frontleft + frontright) {
      myStepper2.step(10);
    }
    if (backleft + backright < frontleft + frontright) {
      myStepper2.step(-10);
    }
    int backleft = analogRead(A0);
    int backright = analogRead(A1);
    int frontleft = analogRead(A2);
    int frontright = analogRead(A3);

    Serial.print("Backleft Reading: ");
    Serial.println(backleft);
    Serial.print("\n");
    Serial.print("BackRight Reading: ");
    Serial.println(backright);
    Serial.print("\n");
    Serial.print("Frontleft Reading: ");
    Serial.println(frontleft);
    Serial.print("\n");
    Serial.print("Frontright Reading: ");
    Serial.println(frontright);
    Serial.print("\n");
    float ratio = (frontleft + frontright) / (backleft + backright);
    float math = (5 + 6) / (4 + 5);
    Serial.print("Math: ");
    Serial.println(math);
    Serial.print("Ratio: ");
    Serial.println(ratio);
    Serial.print("\n");
    delay(500);

  }

Im getting values for my sensors (backleft, backright, frontleft, frontright), but 'ratio' always comes out 0.00. Because of that, Im getting trapped in the loop I believe. What's going on here?
Also, just to check, I added 'math' float as that quick calculation, but I'm getting a value of 1.00 in Serial Monitor. Why? It should be 1.222.

Read this: Integer arithmetic and overflow.
float math = (5 + 6) / (4 + 5);
Serial.print("Math: ");
Serial.println(math);

The compiler is treating your expression (the RH side of the "=" sign) as integers. Thus it is working out:
11 / 9 = 1

Then you assign that 1 to a float. Too late to make it a float! It is already truncated.
Try:
float math = float (5 + 6) / float (4 + 5);
Serial.print("Math: ");
Serial.println(math, 4);  // 4 decimal places

You get:
Math: 1.2222

This also looks wrong:
while ( ( (frontleft + frontright) / (backleft + backright) <= 0.8 ) || ( (frontleft + frontright) / (backleft + backright) > 1.2) ) {
    if (backleft + backright > frontleft + frontright) {
      myStepper2.step(10);
    }
    if (backleft + backright < frontleft + frontright) {
      myStepper2.step(-10);
    }
    int backleft = analogRead(A0);
    int backright = analogRead(A1);
    int frontleft = analogRead(A2);
    int frontright = analogRead(A3);

How many backleft variables do you have? The one in the while instruction will not be the one you are doing the analogRead on. It doesn't "forward read" variables. I bet you have a different frontleft / backleft etc. set of variables declared earlier. These will not be updated inside the loop.
(To make them get updated drop the word int from inside the loop).

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


text:
Cloud function getting stopped Parse.com in loop when calling from Arduino-yun
I have created a cloud function using the Parse.com Javascript SDK and I am calling those functions from Arduino. Following is code for the hello function:
Parse.Cloud.define("hello", function(request, response) {
                response.success("This is hello function");
}); //hello function Block

I am calling this function from the Arduino side using the following code:
void setup() {
  Bridge.begin();
  Serial.begin(9600);

  while (!Serial);

  Parse.begin("***zE0uUjQkMa7nj5D5BALvzegzfyVNSG22BD***", "***Ssggp5JgMFmSHfloewW5oixlM5ibt9LBSE***");
  //commented my keys with * here only

  // In this example, we associate this device with a pre-generated installation
  Parse.getInstallationId();
  Parse.startPushService();
}

void loop() {
  Serial.println("Start loop");
  demoBasic("meeting", 0);
}

void demoBasic(String functionname, int light) {
  char fnname[11];
  functionname.toCharArray(fnname, 11);

  Serial.print("In ");
  Serial.print(functionname);
  Serial.println(" Function");

  ParseCloudFunction cloudFunction;
  cloudFunction.setFunctionName(fnname);
  cloudFunction.add("light_sensor", light);
  cloudFunction.add("value", "Arduino Hello");//parameters

  ParseResponse response = cloudFunction.send();
  Serial.println(response.getJSONBody());
}

Problem is that I am getting response 8 times only. After that whole program flow gets blocked. What is the problem?

Not sure what your problem is, but I'd try a "delay" in loop after the call to demoBasic. I'd start with 100 ms. Maybe your code execute "too fast" then the js function gets blocked.

@fabrosell i tried doing that also but still there was problem.Can you suggest any othing thing which might solve issue.

If you have any working code which continuously able to push data to Parse.com,can you share that ?

I'm sorry, I do not have any. Either way, it's a very strange behavior if function gets called just 8 times and no more...

At what point in the code does the program flow "get blocked"?

Give this a shot, I really hate String, maybe that 8-times thing has to do with memory issues caused by it.
void loop() {

  char functionToCall[8] = "meeting";
  Serial.println("Start loop");
  demoBasicCharArray(functionToCall, 0);
}

void demoBasicCharArray(char *functionname, int light) {

  Serial.print("In ");
  for (byte i=0;i<sizeof(functionname);i++){
    Serial.print(functionname[i]);
  }
  Serial.println(" Function");

  ParseCloudFunction cloudFunction;
  cloudFunction.setFunctionName(functionname);
  cloudFunction.add("light_sensor", light);
  cloudFunction.add("value", "Arduino Hello");//parameters

  ParseResponse response = cloudFunction.send();
  Serial.println(response.getJSONBody());
}

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


text:
what is the fastest shield to add to the sparkfun v3.2 Arduino Uno that will enable me to playback and record hour of short audio dictation
I have almost no eexperience building electronic kits. I just buoght and began tinkering with sparkfun 3.2 and want to adapt its simon sketch to real audio files
What isis theeasiest to assemble add on shield or breakout not surew hat you call this looked at this one
VS1053 Codec + MicroSD Breakout - MP3/WAV/MIDI/OGG Play + Record - v4


text:
Arduino keypad matrix example? ( teensyduino )
I'm a beginner using Arduino with a Teensy 3.2 board and programming it as a usb keyboard. I have two 4 button membrane switches. Their button contacts are on pins 1-8, and the 9th pin holds a soldered together wire of both membrane switches' "ground" line or whatever it's true name is; the line that completes the circuit.
Basically when you press the buttons they are supposed to simply type "a, b, c..." respectively. I've been told I need to use a matrix for this.
I'm looking for an example of how to code a keyboard matrix that effectively supports a one row/9 column line (or vice versa?) I've been unable to find that solution online.
All I have so far is this code which, when the button on the second pin is pressed, sends tons of "AAAAAAAAAAAAAAAA" keystrokes.
void setup() {
  // make pin 2 an input and turn on the
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  //if the button is pressed
  if(digitalRead(2)==LOW){
    //Send an ASCII 'A',
    Keyboard.write(65);
  }
}

Would anyone be able to help?

How long do you hold the button down for? Half a second? How many "A" do you think you can print in that time. You need to detect a transition from button-not-down to button-down and then send the "A".

By your description, you don't have a matrix.  You have them wired as just 8 straight switches.
A matrix would be if you had the 4 switch pins of one keypad wired to the same switch pins of the other keypad, and the two common connections from the keypads wired to two separate IO pins.
At the moment your code is responding whenever a button is in the low state. Instead it needs to respond only when the button transitions from the high state to the low state.  To do that you need to know what state all the buttons were in the previous pass through loop to compare them to what they are in this pass through loop - and if any have changed then they have either been pressed or released.
You should also implement debouncing to that you don't get false presses.
If you don't want to learn how to do all that yourself I have a handy library that will do it all for you:

https://github.com/MajenkoLibraries/DebouncedInput

If you want to convert your setup to an actual matrix to save on IO pins you want to read the Arduino Keypad tutorial:

http://playground.arduino.cc/Main/KeypadTutorial

I'm using 2 of these: http://s1250.photobucket.com/user/09016/media/1_zps7b32fbcc.jpg.html Everyone I spoke to on forums (and my testing) concluded that I couldn't get the buttons to function without taking those 5th connections and merging them.  I'm too new to get much done with what you've said. Compiling your program can't find the DebouncedInput.h include and while it's in there I'm not sure where to copy it. (tried many) I've read the Matrix tut thrice and tried it with no success when I press the buttons. The only thing that has displayed anything was my example code and it was a mess~

Follow this guide to install a library: https://www.arduino.cc/en/Guide/Libraries I know those keypads well - I have one stuck to the top of my home-made keyboard (old Amiga A500). They are just 4 buttons with one common connection, not a matrix.


text:
Measure low current with variable voltage
I want to make a system that always have the same current (about 1ma) in a water with silver electrode. At start it will be purified water so conductivity will be really low.
But with time silver particle will be released in water, raising his conductivity so if I don't lower the voltage the current will raise too (meaning that bigger particle will be released which I don't want too).
So, is there any way I can measure low current and adapt voltage with the result (since deducting resistance wouldn't be hard).
I know about ASC712 but It seem that he can't be precise enough (steps of 13ma max) to my use.
I precise it's not that long I'm trying to get back in electronics with arduino so many school things have been forgotten.

What you want is called a constant current source. You can actually build a simple one using one transistor ; but a better one uses two transistors - as in the left example below - see this page for explanations.

Here the leds would be your load, R=680 Ohm would give you about 1mA - and you would need to increase the value of the 2k2 resistor to somewhere around 22k.
The problem is that, as John Williams noted, forcing 1mA through a high resistance requires high voltage : 1MOhm would need 1kV, 10MOhm needs 10kV etc. That's very dangerous voltages! and quite some power as well : 10kV at 1mA means 10W.
I think you need to define your needs first :

What is a tolerable error on the absolute value of current? (Would constant 1.1mA be OK?)
What is a tolerable error on the current variations? (Would current varying between 1.19mA and 1.21mA be OK?)
Do you absolutely need 1mA right from start? Or can you accept a lower current at start, growing with increased conductivity until 1mA is reached and then being held nicely constant?

If the above examples are fine, a current source as described above would do the job nicely for less than 1USD.
If you really need a constant current source right from the start, then be prepared to work with expensive and dangerous pieces of equipment.

I maybe not need 1mA from the start I think that's mostly for the end of the process but that's not very well documented anywhere :/. And I don't need to be precisely 1ma either, I even think that I can go to 10 or 50ma without issue but again there is no really exact value to refer out there

Alternatively, you can buy ready made unit. Random search from web give example like this has 3 models for, 1.5, 3 and 6kV 1mA constant current.  http://www.matsusada.com/high-voltage/sc/
Safety first if self make (do you need a unit for use or you want to do exercise trying to make it). May not be a easy project.
Your post stated 'purified water', resistance will be really high, in many mega ohm range, if it is really pure.
First measure resistance with multitester to get realistic ohm reading in pure and later stage when "with time silver particle will be released in water".
The hi and then lower ohm will get you voltage needed. to drive 1mA through multiple mega ohm need kilo volt and need special circuit and suitable experience for hi volt safety.

if you may describe more about your intended application, people may be more help in alternate idea/method. Like, it that hobby or 'real' use? Why you need to drive that much current into purified water? At 10 watts, 10KV, it will be quite a bit of hydrogen/ oxygen gas for REAL explosion risk. Today news, gas explosion kill 100, hurt 300, damaged kilo meters of road and car flied 30 foot and landed on rooftop.

Correction. 10 watts make a lot of gas at more typical low volt case. At high voltage (if purified in original post refers to distilled or RO water, at commercial/industrial/factory/lab quality level), 1 to 50mA, gas quantity is much less.


text:
Shortest time interval that Arduino Uno R3 can read
I am doing a light speed determination experimsmt. Lightspeed is around 3*10^8 m/s. For this, I need to measure time interval between 2 light sensors in nanoseconds, Somewhere about 50ns. Is this possible using the Uno R3? I know the clock is 16MHz only but is the clock irrelevantto the topic? If it is not possible, Some tips would be helpful. Thank you.
Sorry for irrelevant tags. No suitable tags found.

You may be able to do much better with other parts having faster timer clocks; a lot of relatively easy to work with ARM chips may push this close to if not over 100 MHz.  The ATtiny 25/45/85 have possibility as well, but may need some calibration trickery as the PLL seems only to work with the imprecise internal oscillator.

At 16MHz, the quickest operation that the cpu can do (a one cycle operation) will take 62.5 nanoseconds (1/(16*10^6) seconds). That means the best resolution you could conceivably have is 62.5 ns chunks. It will take considerably longer than one clock to respond to an outside event though, so making an experiment will be really tough even then.
Maybe you could build an experiment like the Fizeau apparatus where the arduino measured pulses of light that make it back through the slit? Those would be measured in microseconds. The arduino could change the speed of the grooved wheel and maximize the returning pulse width, reading the rpm then gives you the speed of light.
I'll note that since the meter is defined by the speed of light, and the foot defined by the meter, You would not be measuring the speed of light in feet or meters per second; you would be measuring the length of a meter given how long a second is, or vice versa.

When I use h=1 metre and use a motor of 4000 rpm, theta will come in range of 10^-6. I wouldnt want this.

This would be done with a hardware timer, not the CPU.

The meter is defined by the speed of light in a vacuum. So you are actually measuring the refractive index of the air q-:


text:
Knowing the Arduino memory capacity
I am using Arduino uno. My data is storing into EEPROM whenever i run my program, it will store multiple data depend on the loop. For my program it calculate 10 sample in 0.1 sec, so 100 sample in 1 sec. How can i know how much memory i can run?
I have added this code to my program it display 895.
#include <Arduino.h>
int freeRam () {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
void setup(){
Serial.begin(9600);
Serial.println(freeRam());}
void loop(){}

The freeRam() method you are suggesting calculates the "space" between the heap and the stack, thus it returns the free SRAM.
There is no way to calculate free remaining EEPROM (if that is what you are asking), since it just contains some arbitrary data at arbitrary locations. Get the EEPROM capacity from the device data sheet and make sure to write within its boundaries.

Writing to EEPROM is relatively slow. Check EEPROM speed (older and new EEPROM differs greatly, some only do page write, some do byte write) and your sample size (number of byte to write) to see if 10 sets of sample in 0.1 sec is ok.

@JohnWilliams: ATMEGA internal EEPROM is indeed very slow. One erase/write operation takes easily 3ms. Thus, writing 10 values every 100ms (OPs requirement) you spend >30ms only storing the data. This is assuming that one value only has 1 Byte width.

I wonder if it is against rules to response with 'not asked' info, when the info is important for success of the original poster. EEPROM in UNO and Mega2560 is 100,000 times write life (less than 1 day in this case), as per Arduino web link to factory data sheet, page 1 http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf  People actually test it to death in http://hackaday.com/2011/05/16/destroying-an-arduinos-eeprom/  EEPROM was designed to store in frequent changing data, like calibration data, last power down and restore, etc


text:
Is it possible to program an Attiny85 with a USB-to-TTL converter?
I currently use my Arduino to program Attiny85. As I have one of these USB-to-TTL adapters I am wondering if it is possible to program Attiny85 with it, to free up my Arduino. I know it is possible to program Atmega's with such a thing.
If it is in fact possible to use the converter as a simple programmer for Attiny's, how should I connect the converter to the Attiny?

Without addressing complications and tricks for that particular interface, ATtiny's and ATmega's have basically the same sort of ISP programming scheme, just needing different details and data.  If you are talking about serial download to a bootloader, that is possible as well, though an ATtiny85 bootloader has to do something comparable to software serial as the chip lacks a hardware UART.

Yes, it is possible.
Note that the FTDI chip (assuming that is what you have) can be accessed as either Virtual Com Port VCP or D2XX. Where VCP is the traditional method of using them as Serial Ports with avrdude calling "-c arduino -P COM3 -b115200". However the later D2XX method allows for the pins to be Bit Bang'ed.
One can see in this tutorial it is possible to call avrdude with a programmer of "-c ftdi". Assuming that the D2XX drivers are installed.
Where I see in the current releases 1.0.5r2 and 1.5.7's avrdude's config files that a programmer of type "avrftdi" is supported, as opposed to the article "ftdi"
However, that is not to say the IDE natively supports its. You will have to either call avdude manually. Or add the "avrftdi" to "\arduino-1.5.7\hardware\arduino\avr\programmers.txt" so that the IDE will be aware of it.

That all said I see "Tiny AVR Programmer" that are very in-expensive.

Your are right, they are very cheap. I had no idea! I just ordered one at about USD 5 incl. shipping :-)


text:
arduino serial comminucation
my vb.net app produce this result as 2d array :
01110000000111000
01110000000111000
01110000000000000
01110111000111000
01111111100111000
01110011100111000
01110011100111000
01110011100111000
01110011100111000
01110011100111000
00000000000000000
i want to send every single column to my arduino over serial port and use the column to turn on this leds :
* leds connected from pin 2 to pin 13

anyone can help me ? :(

And what have you tried so far? What part of it are you having problems with?

the problem is how to send array over serial port and recieve it in arduino  ? i've no idea how to do that :|
*i am new with arduino.

So basically everything then?  We can't help you with the VB side of things - try stackoverflow.com for that. For the Arduino side of things, this may help: http://hacking.majenko.co.uk/reading-serial-on-the-arduino

I don't see resistors in your LED circuits.  You run the risk of damaging your Uno if you drive LEDs without series resistors to limit current.  Eg 330Ω for 10 mA, 3300Ω for 1 mA, etc.


text:
SIM900 Modem is not responding
I'm working with arduino nano and it has interfaced with SIM900 GSM. I'm sending "AT\r" to GSM modem, but not getting response.
void setup()
{
  Serial.begin(9600);
  Serial.println("Setup is Ready");
}

void loop()
{
   Serial.write("AT\r");
   delay(1000);
   if(Serial.available() > 0)
   {
     Serial.println("Data received");
     Serial.println(Serial.read());
   }

}

Serial monitor:
Setup is Ready
ATATATATATATATATATATATATATATATATATAT
I've set the 9600 baudrate to modem and my rx and tx is connected correctly...
What is the problem?
Thanks

You should not use the same Serial interface to debug and talk to your SIM900. You should use a SoftwareSerial interface to talk to the SIM900 and use the hardware Serial to send response back to your computer.
Try this code:
#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of SIM900
const byte txPin = 3; // Wire this to Rx Pin of SIM900

// We'll use a software serial interface to connect to SIM900
SoftwareSerial SIM900(rxPin, txPin);

void setup() {
  Serial.begin(115200);
  SIM900.begin(9600); // Change this to the baudrate used by SIM900
  delay(1000); // Let the module self-initialize
}

void loop() {
  Serial.println("Sending an AT command...");
  SIM900.println("AT");
  delay(30);
  while (SIM900.available()){
     String inData = SIM900.readStringUntil('\n');
     Serial.println("Got reponse from SIM900: " + inData);
  }
}

You aren't talking to the SIM900. You are just communicating with the serial monitor.


text:
How do I compile the Marlin firmware?
I have a folder of mostly .h and .cpp files for the Marlin firmware (3D Printing) from here.
How do I compile that so I can upload it to my Arduino Mega with Ramps?

Your question is very broad. What have you tried?. In what way did it not work? Does the linked site not have a tutorial? In what way did the tutorial not help?

You need to open the .ino file. that is the project file for the Marlin Firmware. then upload that. Also do some research about the settings for Marlin. It isn't just plug and play, you have to enter some information about your individual stepper motors.
http://solidutopia.com/marlin-firmware-user-guide-basic/ - heres a guide for Marlin.
the cpp and h files are c++ files that are apart of the project. the Arduino IDE cannot open these individually. the .ino file is the project file that will allow you to open up the entire project and not just one portion of it.


text:
Is it possible to accept multiple web requests at once?
I have an Arduino with ethernet shield and there are 8 different URLs that can be called to perform different actions.
The program loads and runs as expected for the most part, but, if it is busy doing an action, it won't accept the next one until the current action has finished.
Basically, the code's main loop listens for a client connection, then has a bunch of ifs that look in the URL that was called (for a query string) and then process the command.
I have looked at a few answers on here, but none deal with listening to HTTP requests. One recommended a library, but, I couldn't quickly get it to compile, and the other answer recommended a state machine - I do like this approach, however, I haven't had time to implement and it doesn't "feel" right as the listening for a HTTP request works on a if(client) basis.
I was wondering if anyone has done this before and/or has any advice?

What sort of action would it be busy doing? Generally I would expect the server to decode the HTTP request almost instantly, and then do the action (eg. return some data). Is your setup such that this might take some time?

@NickGammon - it needs to operate a solenoid for ~2 seconds which doing inline in the http request code means that it stops listening for new requests.

Then you need to start with the basics.  Look at the BlinkWithoutDelay example to see how to write non-blocking code. I'll bet your sketch is littered with delay() calls.  There is no place for delay() in a proper program, except for tiny (a millisecond or so) delays for timing purposes.  Also, get to grips with the concept of the Finite State Machine (there are many resources and tutorials online).

Not sure if it will work for your case, but you can try using interrupt to quickly jump to some signal and back to your main loop. This is similar to concurrency in a web server, since Arduino cannot run things in parallel.

it needs to operate a solenoid for ~2 seconds which ... means that it stops listening for new requests - as the other comments point out you just need to restructure. Turn the solenoid on, remember when you did that, and check in the loop which is listening for new requests if the time is up to turn it off again.

The official Ethernet Shield advertises ability to run 4 simultaneous sockets...

It can be done. The Arduino is a single tasking environment so you have to make sure your code is non-blocking.
BlinkWithoutDelay is a good starting point (thanks @Majenko) but you should also look at the Timer1 library.
Basically your programs needs to do all the steps it can right away and whenever it does something that could block, it must do it asynchronously and during a later loop() run check if it's finished and continue with the next task. The alternative (if you know how long your task will take) is to use the timer interrupt with the library mentioned above.


text:
Did I break my new Arduino Leonardo Eth by restarting it?
I just bought a new Arduino Leonardo Eth, and, it was working perfectly.
I probably uploaded about 30 different sketches, and it did everything as expected.
The basic sketch was using the fade demo on pin 9 to ground with a LED attached.
I was then curious on how long the unit takes to restart, so, I unplugged the USB and put it back in.
When it started back up, the LED was on solid. I then restarted it again, and I honestly can't remember the state of it.
When I plug it in, it gets detected in the Arduino application and I see the port, but, after about 20 seconds, I get a popup on Windows saying about a malfunctioning USB device.
Pressing reset on the Arduino or unplugging/plugging it back does the same - I get about 20 seconds, and then it "goes bad".
Even if I am real quick in the IDE, or press restart after compiling/before upload, it just hangs.
I'm really annoyed with myself if I did break it, but, I'm not really sure what else I could have done differently... after all, there isn't an off switch.
Does anyone know what I have done, and, is there anyway to fix it?

Can you communicate with it via ISP?

@IgnacioVazquez-Abrams I just read another post about bricked Arduinos, and I am going to give that a shot... Honestly, this is my first official arduino device - I have purchased a few low end Arduino Micro compatible units, but, I am not sure that they have the ISP function... This is my first experience with arduino/electronics, and I do feel a little out of my depth! ... I was hoping there is a certain combination of restart button pushes to factory reset or similar! I'm traveling at the moment, but will try again normally and look at ISP when I get home

You should be able to use my board detector sketch on one of your other Arduinos to check out the problem board.
See also Have I bricked my Arduino Uno? Problems with uploading to board
Also my bootloader uploader sketch will reflash bootloaders on quite a few devices. I'm assuming that the "Arduino Leonardo Eth" has the same bootloader as the Leonardo.
Hmmm - I see that the "Arduino Leonardo Eth" is from Arduino.org, not Arduino.cc. The bootloader is probably slightly different. I'm really not an expert on what those boards use.

Before worrying too much, try the approach of holding down Reset and then uploading a sketch, letting go of Reset as the sketch starts to actually upload.

Comment by William Hilsum

I didn't realise there was a difference between .org and .cc, and, I guess by using the leonardo template from .cc, I broke "something". The moment I downloaded the IDE from .org, & uploaded with the eth template , it worked flawlessly. I guess there are some changes between leonardo and leonardo eth. I wanted an arduino with ethernet, so I didn't need a separate shield. No idea if I picked the right "side" after reading all the crap with cc vs org!

That is very annoying that the split of the Arduino camps now produces a support nightmare for people who just want to use their virtually identical products, but have to go through this.
Thanks for the update.

Sorry to sound dumb, what's the difference between Arduino.org and Arduino.cc? The Leonardo Eth was from a trusted supplier (Farnell) and I didn't know there was a difference here! I thought it was just one was a community and one was the company... Anyway, as for the "cheap" Arduinos, I just bought them from eBay and have never actually used them, ... Being honest, I'm not even really sure how to right now/there is only headers/no pins, so, I have to look in to that when I have more time! I'll give the reset thing a try though. Thank you....

It's worth saying, I have a theory... I read from the Arduino troubleshooting page that it doesn't auto start if it gets a signal - I am wondering if the first time I connected, it was simply "empty" and worked, the second time, my machine/vmware/something intercepted the call and tried to do something causing it to pause. This doesn't explain why it gets detected and disconnected straight after uploading though.

The Leonardo presents as a USB device initially so you can upload a sketch to it. After a certain time (mine took around 9 seconds) it exits the bootloader, and that USB device "goes away". Then it runs your sketch. If your sketch does not open Serial, a keyboard or mouse, then it is no longer a USB device. So this is expected behaviour.

what's the difference between Arduino.org and Arduino.cc - various of the original Arduino founders have had a dispute about who owns the "Arduino" name. See, for example: Arduino Wars: Group Splits, Competing Products Revealed?

Thanks so much, and found a really good answer on here shortly after writing that... I used the Arduino download from cc, I used Leonardo as the base... I just downloaded it from .org and now have the Leonardo eth template - I am guessing that as much as it worked, it may not have done a lot of good! I swear the .cc download only had ~2 drivers, the .org one needed around 10 - I hope it hasn't screwed anything up on my pc...

Please let us know how this turns out, so that the question may eventually have an answer that will help other people. :)

Unfortunately, I can't find a bloody USB cable when I need one :( Guess I'm going to have to wait to do this at work! I certainly will share back!

This isn't exactly the correct answer, but, you pushed me on to the correct thing, so, if you can modify/add the following, it may help others... I didn't realise there was a difference between .org and .cc, and, I guess by using the leonardo template from .cc, I broke "something". The moment I downloaded the IDE from .org, & uploaded with the eth template , it worked flawlessly. I guess there are some changes between leonardo and leonardo eth. I wanted an arduino with ethernet, so I didn't need a separate shield. No idea if I picked the right "side" after reading all the crap with cc vs org!

I added your remarks for the benefit of future readers.

Difference between Arduino.cc and Arduino.org


text:
MAX72XX with 8 digit 7 segment display library
A while ago, I found a library for the MAX72XX that had functions for writing text to the display, but unfortunately cannot find such library now.
Which would be the best library to use for a text and number display? I'm using LedControl but it is very awkward to use.

Are you aware that it is not possible to represent all alphabetic characters with just 7 segments? That means that some characters cannot be printed or would be printed in a strange way.

Cosa library for Arduino has this text support for MAX72XX but this is not compatible with standard Arduino libraries as Cosa is a whole "framework" for Arduino: https://github.com/mikaelpatel/Cosa

You might be able to just extract the library files from Cosa  https://github.com/mikaelpatel/Cosa/tree/master/cores/cosa/Cosa/LCD/Driver
and modify them.

Try this one: http://playground.arduino.cc/Main/LedControl#CharSeg7Control

I have a library for driving the MAX7219 chip connected to a 7-segment display. It is at: https://github.com/nickgammon/MAX7219
Example of use:
#include <SPI.h>
#include <bitBangedSPI.h>
#include <MAX7219.h>

const byte chips = 1;

// 1 chip, bit banged SPI on pins 6, 7, 8
MAX7219 display (chips, 6, 7, 8);  // Chips / LOAD / DIN / CLK

void setup ()
  {
  display.begin ();
  display.sendString ("HELLO");
  }  // end of setup

void loop () { }

In operation displaying a number:

More details at: Interfacing LED displays with the MAX7219 driver

Another reply of mine with no acceptance, no upvotes, and now it has been bumped by "Community" in the hope that someone will give a better answer. Good luck with that one.

Sedition! We'll be watching you.


text:
I2C RTC returning bad times - sometimes
I have a TinyRTC I2C clock in one of my Arduino projects, and it works most of the time. But occasionally, it will report the time as 165 hours, 85 minutes and 25 seconds (165:85:25) for a couple of seconds, then go back to the correct time.
I think this has got something to do with a fairly complicated I2C bus that I'm running: it has 12 devices connected to it (the clock, an LCD and 10 BlinkM LED programmable lights).
Here's what I've tried to debug, to no avail:

Replaced the RTC and battery
Replaced I2C pullup resistors
Redid the I2C wiring
Checked current draw of my project (.2A) and made sure the power
supply can handle that (it can)
Used 3 different power supplies in case I was getting noise

I think this is something to do with the I2C bus... the clock works fine when nothing much else is happening on the bus, but as soon as there's lots of activity (LEDs being sent messages, or perhaps other things) it starts reporting the time as 165:85:25).
Any idea how I could (a) isolate the cause of this problem; (b) get right to implementing a solution?

http://arduino.cc/en/Reference/WireEndTransmission Did you try the stop parameter and/or check error conditions that are returned? Hard to tell what's wrong without circuit or code.

What code/library did you use? What was the expected time for 165:85:25?

It might be an error code for I2C or it could be a status report from the TINY RTC. So how are you sure that it is responding with the current time?

@jippie - Your link was useful... am going to try slowing down the I2C bus in case there's a problem communicating with so many devices.

@Gerben - www.pjrc.com/teensy/td_libs_DS1307RTC.html

@Lean - 4.7k pullup resistors

@Treesrule14 - The clock works fine for hours at a time... then reports these weird times, which happens when there's other activity on the bus

Did you check you have no devices with conflicting addresses on the bus?

Make sure you have only one set of pull-up resistors.

Such intermittent issue looks to me a hardware signal integrity problem, specifically around the I2C bus RTC chip. Did you experience any problem from any other device on the same I2C bus (e.g. when all the LEDs are on)? If not, then check on the noise level on RTC chip power and GND. Also, the I2C spec has limit on the bus capacitance load as max as 400 pF. When there are too many I2C device loads on the same bus, the bus may become vulnerable to the system noise.
Debug Suggestion: To narrow down if it is I2C load issue, add an I2C bus driver chip between the main Arduino board and your peripheral. For example, P82B96 from TI. See the spec here. http://www.ti.com/lit/ds/symlink/p82b96.pdf


text:
The difference between "time_t" and "DateTime"
I've run into an issue trying to combine 2 different Arduino timer projects I've found online.
For both projects I'm using a DS3231 RTC, but have been able use the DS1307 library just fine in my code.
The first set of code I picked up started with:
#include <DS1307RTC.h>

The second set of code I tried to combine did not have this 'include', but instead used
RTC_DS1307 RTC;

as found here:
https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/understanding-the-code
As a novice coder, I'm not really sure what the difference between the above two ways to call this library. But I do know the first way using "include", if I want to access the current time on the RTC I use
RTC.get();

as opposed to the second method which requires:
RTC.now();

And while it was easy to find documentation to sync the RTC to computer time over the USB cable using this handy bit of code:
// Notify if the RTC isn't running
    if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running");
  }

   // Get time from RTC
  DateTime current = RTC.get();
  DateTime compiled = DateTime(__DATE__, __TIME__);
  if (current.unixtime() < compiled.unixtime()) { //CHECKS AGAINST COMPUTERTIME
    Serial.println("RTC is older than compile time! Updating");
    RTC.adjust(DateTime(__DATE__, __TIME__));  //UPDATES FROM COMPUTER IF OLD TIME IS OFF
  }

I can find no easy alternative using "#include DS1307RTC"
I first thought that the difference between RTC.now() and RTC.get() was just a matter of word substitution. But later on when I want to use a "time_t" call after initializing with "RTC_DS1307 RTC;"
 time_t timeNOW = RTC.now();

I get the error "cannot convert 'DateTime' to 'time_t {aka long unsigned int}' in initialization"
So I'm assuming one method uses "DateTime" and one method uses "time_t". But I'm not sure if this is the case, and if so, how to convert a "DateTime" value to a "time_t" value.
I have two goals in writing this post.
1- Can someone please explain to me the difference between "#include DS1307RTC.h" and "RTC_DS1307 RTC;" and how it impacts my code.
2- I'd like to stick with using ""RTC_DS1307 RTC;", only because it seems easy to sync my RTC to my computer. But if I do, I get the above error. So can someone please tell me how to convert a "RTC now()" call to a "time_t" value? Or is the issue more complicated than just a mere conversion between data types?

A DateTime is a full class with lots of methods to it - a time_t is just an unsigned long.
time_t is used to store the number of seconds since the epoch (normally 01/01/1970)
The Arduino Time library returns a time_t to the now() function - but RTCLib return s a DateTime object.
The DateTime object, though, has a unixtime() method which will return a time_t representation of the time stored in the DateTime object.
So you can do:
DateTime dt = RTC.now();
time_t time = dt.unixtime();


text:
Can anyone tell me about the onboard accelerometer of LightBlue Bean?
I would like to know the specs of the accelerometer used on a LightBlue Bean before buying one, but I couldn't find any info online. Anybody has an idea?

They seem to have a web site. How about asking on that?

There is a reference to the accelerometer datasheet from the Arduino Reference page

I would like to know the specs of the accelerometer used on a LightBlue Bean before buying one, but I couldn't find any info online. Anybody has an idea?

Start by checking the Adafruit LightBlue Bean product description. There you can find a link to the schematics and board layout. On page two there is accelerometer, a BMA250 just as @Jason links to.
That took "30 seconds" web search plus writing this answer :)
Cheers!


text:
Arduino Nano v3.0 with ESP8266
I am attempting to connect and use an ESP8266 board with my Arduino nano v3.0 and I am not have much luck.
I have read a bunch of tutorials and articles, the most recent is http://elektro-blogger.blogspot.co.nz/2015/07/arduino-and-esp82666.html
Any help would be greatly appreciated.
I have connected it like below and am using some simple code to try and get it working.

Code:
#include <SoftwareSerial.h>

SoftwareSerial esp8266(10, 11);

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

  Serial.flush();

  esp8266.print("AT+RST\r\n"); // reset for esp8266
  delay(500);
  esp8266.flush();//clear serial1
  // Check AT
  esp8266.print("AT"); // reset for esp8266
  esp8266.print("AT+CIFSR\r\n");// learn the ip which token for esp8266
  delay(500);
  if (esp8266.find("ready"))
  {
    esp8266.flush();
    esp8266.print("AT+CIFSR\r\n");
    delay(500);
    Serial.println("CIHAZ IP ADRESI:" + esp8266.readString()); // print esp8266 ip

  }
  else
  {
    Serial.println("there is no internet connection");
  }
  esp8266.print("AT+CIPMUX=1\r\n");//ser mux 1 so we want to connect as multiple users
  delay(500);
  if (esp8266.find("OK"))
  {
    Serial.println("Mux ok");
  }
  else
  {
    Serial.println("MUX failed");
  }
  esp8266.print("AT+CIPSERVER=1,23\r\n");// set esp8266 as server
  delay(500);
  if (esp8266.find("OK"))
  {
    Serial.println("SERVER started");
  }
  else
  {
    Serial.println("SERVER failed");
  }

}
void loop()
{

  if (esp8266.available())
  {
    Serial.print(esp8266.readString()); // get message which comes from clients.
  }
}

At a glance, your picture shows that you've connected RX to RX and TX to TX. They need to be swapped, so that each module receives what the other transmits.

To expand on that, I'm not sure if the logic lines of the ESP can handle 5V of the arduino. (5V exceeds the 3.3V, that could cause some problems)

@FuaZe are you suggesting separate 3.3v power ?

@Rennex Thanks for that. I will test it out tonight.

@Yonkee I'm suggesting a TTL logic converter or a resistor-divider on the logic lines. As the logic (Rx/Tx) may not be 5V tolerant.

Did you get anywhere with this?

I'm using this exact combo of nano and esp8266 but I picked up these real cheap to handle the 5v to 3.3v difference. http://amzn.to/1Qz27S2  You should too or eventually you'll blow the esp8266.

Do not Connect your ESP8266 Module Directly to an Arduino Board, Always try your best to use Divider resistors for better communication. you need to use Arduino IDE serial Monitor Window for ESP8266 setup instead of writing At Commands in Source Code. I successfully Setup My ESP8266 Module by using just Arduino Nano and Arduino IDE Serial Monitor.
Download Simple Source Code and List of Necessary AT Commands

The Esp8266 module has different firmware, the old one was running at 9600 and the new one is running at 115200.
Try to upload this code on  your arduino Nano and send AT commands over the Serial monitor of the Arduino.
If you send AT it should returns "OK", if not, try to swap RX to TX and try to play around with the baudrate 9600, 57600, 115200.
It might be that your Wifi module doesnt have any firmware loaded which might need to be done.
#include <SoftwareSerial.h>

SoftwareSerial wifi(10,11); // RX, TX

void setup()
{
Serial.begin(9600); // FTDI
wifi.begin(9600); // GPS; 9600 first time, 38400 second time
}

void loop()
{
if (Serial.available())
wifi.write(Serial.read());
if (wifi.available())
Serial.write(wifi.read());

}

Thanks for the answer. I will test this out when I get home. I will reflash my ESP board to make sure the firmware is up to date.

I have the same problem. I had no results in running your code. Do you know how to load a new firmware on to the ESP board?

If I am not wrong, you need to short a pin then you power it, the device boots up in a special mode where you can upload a different firmware. Further info you might want to see some youtube videos.

Remember that ESP8266 Uses 3.3v logic and arduino 5v. So use a voltage divider to get 3.3v at esp8266 rx pin. Also esp8266 must be connected rx->rx tx->tx to communicate with pc and rx->tx tx->rx to communicate with arduino.

I would suggest against using nano provided 3.3V. Instead use regulator separately to power it up and connect grounds. ref bbs.espressif.com/viewtopic.php?t=133


text:
Motor shield and wireless transceiver compete for same pins
I would like to use these 2 components with an Arduino Uno:

Arduino Motor Shield R3
nRF24L01 2.4GHz Wireless Transceiver

I use Stepper for the motor shield, and SPI + RF24 for the wireless transceiver.
I could write 2 sketches that work perfectly, but how can I combine them together?
My issue is that they both require access to pins 11, 12 and 13.
Any help is greatly appreciated!

You can't really. You could use Channel A, if you disable the motor (keep D3 low), while performing your SPI communication. I think, but am not sure, you can use both channels if you enable the break (D9 and D8) while using SPI. But you can't have any motors running while using SPI. (BTW the person that designed that shield should be fired for using the SPI pins. That's just bonkers)

For prototyping, use male to female jumper wires to connect the Arduino Uno to the robot shield. It is a bit of a pain, but it makes it easy to free the conflicting pins for the wireless transceiver.
For a more permanent solution, look at Chris K's answer.

This is the core of embedded design and "hacking" and highlights one of my peeves about Arduino design: too much focus on the pin numbers and physical location on the PCBs, rather than the actual functions on those pins.
So? Physically move the pins on the Motor Shield. Here are 3 options in order of the most hack-ish to most-clean:
1) Use an edge cutter to cut the bottom of the pins off the motor shield then solder jumpers to the nub to other pins that are free.
2) Use a hot air station to desolder that header row, solder in your jumpers, and put back only the pins you want. Board designs with such limited foresight (like your situation) is what led me to buy my hot air station. And now I pretty much use sensor shields for my interfacing outside the stack or proto shields to be intermediate layers to translate pins.
3) Cut the trace on the motor shield PCB itself to free the SPI pins. Then find pins that have your function (pwm?) and also are NOT used by any other shields in your "stack". Solder a jumper from the exposed trace on SPI pins to your free "new" pins.
If you stalk through my answers there are write-ups on two test benches I made and you can get ideas from the various work-arounds I have employed to get my hardware working.


text:
Multiple buttons activating different methods for an LED strip
I am trying to use different buttons to activate different methods for an LED strip. However, when one button is pressed after another has been pressed, I want it to interrupt the first buttons method and begin the second. For example: one button sends a rainbow pattern through the LED strip when pressed, however, while it is cycling through the rainbow, the second button is pressed which sends a white cycle through the LED strip. There will be 24 buttons total. I have gotten this to work with 2 buttons but am having trouble getting it to work for a third. The code is below:
     void loop(){

       if (digitalRead(inPin(1)) == HIGH && lastState == LOW){//if button has just been pressed
           stopCycle();
           theaterChaseRainbow(50);
       }
       if (digitalRead(inPin(2)) == HIGH){
           stopCycle();
           theaterChase(strip.Color(127, 127, 127), 50); // White
       }
       if (digitalRead(inPin(3)) == HIGH){
           stopCycle();
           rainbowCycle(0);
       }

     }

     //Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<100; j++) {  //do 100 cycles of chasing
    if (digitalRead (inPin(1)) == LOW) { //checks that other button(s) have not been pressed
      if (digitalRead (inPin(3) == LOW)){
      for (int q=0; q < 3; q++) {
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, c);    //turn every third pixel on
        }
        strip.show();

        delay(wait);

        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, 0);        //turn every third pixel off
        }
      }
    }
    }
  }
}

void rainbow(uint8_t wait) {
  int i, j;

  for (j=0; j < 384; j++) {
   if (digitalRead (inPin(2)) == LOW) { // 3 cycles of all 384 colors in the wheel
    if (digitalRead (inPin(3) == LOW)){
    for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel( (i + j) % 384));
    }
    strip.show();   // write all the pixels out
    delay(wait);
   }
   }
  }
}

uint32_t Wheel(uint16_t WheelPos)
{
  byte r, g, b;
  switch(WheelPos / 128)
  {
    case 0:
      r = 127 - WheelPos % 128;   //Red down
      g = WheelPos % 128;      // Green up
      b = 0;                  //blue off
      break;
    case 1:
      g = 127 - WheelPos % 128;  //green down
      b = WheelPos % 128;      //blue up
      r = 0;                  //red off
      break;
    case 2:
      b = 127 - WheelPos % 128;  //blue down
      r = WheelPos % 128;      //red up
      g = 0;                  //green off
      break;
  }
  return(strip.Color(r,g,b));
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for (j=0; j < 384 * 5; j++) {     // 5 cycles of all 384 colors in the wheel
    if (inPin(1) == LOW) {
      if (inPin(2) == LOW) {
    for (i=0; i < strip.numPixels(); i++) {
      // tricky math! we use each pixel as a fraction of the full 384-color wheel
      // (thats the i / strip.numPixels() part)
      // Then add in j which makes the colors go around per pixel
      // the % 384 is to make the wheel cycle around
      strip.setPixelColor(i, Wheel( ((i * 384 / strip.numPixels()) + j) % 384) );
    }
    strip.show();   // write all the pixels out
    delay(wait);

      }
    }
  }
}

void stopCycle(){
    int i;
    for (i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, 0);
    }
    strip.show();   // write all the pixels out
}

Inside each inner loop, just test the switches and return if they are pressed.
eg.
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<100; j++) {  //do 100 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3)
      {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();
      delay(wait);

      // give up if switches pressed
      if (digitalRead (inPin(1)) == HIGH ||
          digitalRead (inPin(2)) == HIGH ||
          digitalRead (inPin(3)) == HIGH )
        return;

      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

am having trouble getting it to work for a third

If that doesn't help please explain the nature of this "trouble".

You may need to debounce the switch presses. And you may need to wait for them to release the switch, eg.
 if (digitalRead(inPin(1)) == HIGH && lastState == LOW){//if button has just been pressed
           stopCycle();
           while (digitalRead(inPin(1)) == HIGH)
              {  }   // wait for switch release
           delay (10);  // debounce
           theaterChaseRainbow(50);
       }

This is an excellent solution but is there a way to move the return statement to the loop? This way, I could call theatreChase multiple times with different buttons at different paramenters.

I'm not sure what you mean by "move the return statement to the loop". Can you elaborate?

I would normally do this (pseudocode):
void loop() {
    static state=state_off;
    if (button_1_pushed) {
        state=state_1;
    } elseif (button_2_pushed) {
        state=state_2;
    }
    if (state==state_off) {
        turn_all_leds_off();
    } elseif (state==state_2) {
        shownextframe_rainbow();
    } elseif (state==state_2) {
        shownextframe_chaser();
    }
    delay(1);
}

In shownextframe_chaser/shownextframe_rainbow, I would probably work out what should be shown based on the current millis() - e.g. if your chaser has 10 lights, and you want it to pulse over 1 second, then each led should be on for 100 millis, so at any instant, the led that should be on is (millis()/100)%10 (assuming the led's are numbered for 0 to 9).


text:
Arduino Uno Rx/Tx + Arduino Serial
I was wondering if I can use the Rx and Tx Hardware on the Arduino Uno and also add another Rx/Tx pins using SoftwareSerial at the same time ? cause I need two to communicate with two motor Controllers (Roboclaw controller)
Thx

Yes, you can.  That's the purpose of the SoftwareSerial - to allow you to complement the hardware TX/RX with other pins defined by software.
One thing to note with SoftwareSerial - it's half duplex. It can either send or receive, it can't receive while it's sending.

Agreed. See MIDI decoder demonstration - that reads a MIDI device using SoftwareSerial and outputs using HardwareSerial. As you can see it keeps up with the MIDI gadget. As Majenko said, you can't transmit and receive simultaneously using SoftwareSerial.

You can, but be aware that SoftwareSerial can cause problems if you need strict timing, as it will keep the Arduino stuck while it is receiving, as it polls in interrupt context.
I would recommend to check which one of the two serial channels is more likely to receive data and use the real HW Serial port for it.
The duration of the polling of the SoftwareSerial library is also influenced by the bitrate used on the port: the higher the bitrate, the shorter the duration of the lockups, so try to use the highest bitrate you can afford, on the Software Serial port.
In case you find out that you cannot afford letting SW handle one of the 2 serial ports, you can try the Arduino Mega 250, which has several UART HW blocks.
About the specific use case: if either of your motor controllers supports I2C or SPI, you could consider using that, as alternative to the SoftwareSerial.


text:
Arduino Blocks at Uploading

I am trying to make an operating hours counter with arduino, i started with a basic script to make the arduino work as a stop watch, This is my script:
unsigned long start=0, finish=0, elapsed=0;

 void setup() {
 Serial.begin(9600);
 Serial.println("Clock START");
 }
 void displayResult(unsigned long elapsed){
   float h,m,s,ms;
   unsigned long over;
   h=int(elapsed/3600000);
   over=elapsed%3600000;
   m=int(over/60000);
   over=over%60000;
   s=int(over/1000);
   ms=over%1000;
   Serial.print("Elapsed time: ");
   Serial.print(h,0);
   Serial.print("h ");
   Serial.print(m,0);
   Serial.print("m ");
   Serial.print(s,0);
   Serial.print("s ");
   Serial.print(ms,0);
   Serial.println("ms");
   Serial.println();
 }

 void loop() {
   start = millis();
   delay(200);
   Serial.println("Start");
   Serial.println("doing Operations and stuff");
   delay(800);
   finish=millis();
   elapsed=finish-start;
   Serial.println("Ended !!!");
   displayResult(elapsed);

 }

Unfortuantly the arduino compiler blocks at the Uploading part, i tried compiling it at first without uploading, it gave me no warning errors. I tried compiling other scripts they worked, it only blocks for this stop watch code.
Thank you for your help

What's the error message?

I don't get any message error, it just hangs there for 5 minuts at it just gave me :  avrdude: stk500v2_ReceiveMessage(): timeout

Weird. I have no problem uploading and running this on my Mega. Looks like a communication problem. What is your OS? BTW: there is no point in using float variables here.

I use windows 7, i also tried other usb ports but it just hangs for this exact script.

There is a bug in early versions of the Mega2560 bootloader.  It crashes on !!! (or enters some other special state that stops uploading happening).
Your string that contains !!! will be breaking it:
Serial.println("Ended !!!");

Simple solution: don't use so many exclamation marks.


text:
Serial communication with two devices
I have two devices connected to my Arduino using the SoftwareSerial library. However, it seems that they cannot communicate at the same time. I can only communiate with both by switching between which one I am listening to every 1000ms (they poll for 1500ms), but this slows down overall communication significantly. Is there anyway to communiate with both at the same time? Could this be achieved by using SoftwareSerial with one and the hardware serial port with the other?

See SoftwareSerial Write to return Read in Serial Monitor? - SoftwareSerial cannot both read and write at the same time.
However HardwareSerial can.

Could this be achieved by using SoftwareSerial with one and the hardware serial port with the other?

Yes.

So, likewise, there is no way to read from both devices using only SoftwareSerial?

That is correct. Not at the same time. SoftwareSerial uses an interrupt to detect the start bit of incoming data. So far so good. But once it gets it, it leaves interrupts disabled while it goes into a timed loop to read all the bits.
Thus, it is impossible for it to react to another incoming byte on another pin at the same time.
Still, you could receive on SoftwareSerial on one pin, and HardwareSerial on another. With HardwareSerial the hardware will run in the background, receiving the byte.

So, likewise, there is no way to read from both devices using only SoftwareSerial?

See amended answer.


text:
Can I program the Arduino without having an actual board with the able to emulate a COM connection to the computer?
I have ordered my Arduino, but it is not going to arrive until 2 months, and I would like to be able to emulate a COM connection to the emulated Arduino. I am writing a program that listens on the com port, and would like to test it.
The program needs to run on Windows, and emulate a COM connection, and a breadboard with a LED, and motors on it.

You could use the Simulator in Atmel Studio or something like Virtual Breadboard which looks good
The Atmel Studio simulator might take a bit of work to simulate your devices but if you have 2 months then maybe that's okay :) If you want to use the simulator in Atmel Studio then you might also find the Arduino plugin for Atmel Studio useful.
I think there are quite a few other solutions if you search google.

To verify communication via COM port (to send messages as well as to receive) you can use arduino emulator from wokwi.com
with the Wokwi arduino emulator, it is easy to do the changes, add input devices as well.
To create a COM port
You just need to have a
Serial.begin(9600);
Serial.println("Text message");

you will be able to see the virtual serial window in the bottom right where you can see the messages printed out as well as you will be bale to key in the serial data you want to send to Arduino.


text:
Send and Receive with ESP8266 and arduino
Hi i would like to implement a sensor and control system for my home. Basically, i would like to send and receive data to my arduino uno using esp8266. I am able program the esp8266 using at commands to send http request to my server. How can i make my server send commands to my arduino uno using esp8266?

Do you want your "server" to send instructions direct to the esp8266 (esp8266 is a server), or do you want your esp8266 to connect to the server, send a request, then the server returns commands as a response (esp8266 is a client)?

Im not using the esp8266 alone, but using the esp8266 chip as a way for me to connect to the internet. I would like the esp8266 to be able to initiate a command to the server and be able to receive commands at any time without sending a command to get the response.

Then you need your esp to run as both a client and server. Open a listening socket and respond to the requests that come in.

Is there a library for socket for esp8266?

No idea. I always program my ESPs directly in C.


text:
Can a WiFi enabled Arduino make a HTTPS request to my Web Server?
I need my Arduino to connect to my web server through HTTPS, can the Arduino handle it?
It only has to act as a client.

Please state which Arduino. There are quite a few different ones.

I was just checking if it was possible to do some secure cloud connected sensors with the cheap non Linux Arduinos.

It sounds like a better way to do it would be to have a PHP script act as handoff server (maybe protected by originating IP address) to access the HTTPS site and provide the data over a less processor-intensive protocol.
How to get HTTPS on Arduino?
However, another answer suggests that we are working towards a solution to your issue, but it's not quite there yet (~12 seconds to encrypt a packet).
https://evothings.com/is-it-possible-to-secure-micro-controllers-used-within-iot/


text:
Error AT%13% With GSM/GPRS Shield
I've been trying to control a relay with a GSM shield for an Arduino project. I haven't had any success with either the Software Serial or the GSM library. I've declared the GSM variable in debug mode and it gives me the error AT%13%.
Using Software Serial, it hangs at SIM900.read().
The SIM card connects to the network, I can see that on the board - the LED flashes every 3 seconds and gives me signals for incoming calls and SMSs.
I can't tell if the error is with the SIM card, the connections to the Arduino board, the power supply (12V) or something completely different. Here are the two code examples I'm using with the different libraries.
Anyone else getting this error? What is the best way to make it go away?
Thanks in advance for any help!
SoftwareSerial.h
#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);

int Relay1 = A2;
int Relay2 = A3;

void setup()
{
  Serial.begin(19200);
  //Set up relay control pins
  pinMode(Relay1, OUTPUT);
  digitalWrite(Relay1, HIGH);
  // wake up the GSM shield
  SIM900.begin(19200);
  delay(10000);  // give time to log on to network.
  SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  // output contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
  Serial.println("Ready...");
  }

void loop()
{

  //If a character comes in from the cellular module...
  if(SIM900.available() >0)
  {
    inchar=SIM900.read();
    Serial.println(inchar);
    if (inchar=='#')
    {...}
    SIM900.println("AT+CMGD=1,20"); // delete all SMS
  }
}

GSM.h - in this case I haven't even gotten past the .begin() command. This code is from the example at http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS
#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess(true);
GSM_SMS sms;
GSM3_NetworkStatus_t   gsmStatus;
// Array to hold the number a SMS is retreived from
char senderNumber[20];

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("SMS Messages Receiver");
  char code = 'X';
  Serial.flush();
  gsmStatus = gsmAccess.begin(PINNUMBER,false,false);

  int retrycount = 60;
  while (gsmStatus != GSM_READY && retrycount-- > 0) {
    delay(1000);  // lower delay value could lead to unstable state
    theGSM3ShieldV1ModemCore.manageReceivedData();
    gsmStatus = gsmAccess.getStatus();
  }

  if (gsmStatus != GSM_READY) {
    Serial.println("\n[ERR]: GSM connection failed\n");
    Serial.flush();
    gsmAccess.shutdown();
    delay(250);
    digitalWrite(3,LOW);
  }

  Serial.println(" [DONE]");

  // connection state
  boolean notConnected = true;
  // Start GSM connection
  while (notConnected)
  {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
  {
      notConnected = false;
  }
    else
    {
      Serial.println("\nNot connected");
      delay(1000);
    }
  }
  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}

You seem to be using different baud rates in each example. Which is the correct one?

Do you get a AT%10% error if you change your \rs with \ns?

Sorry for the mix-up with the baud rates. They are actually irrelevant since both are correct, the codes are from two different examples.
Unfortunately I was not able to resolve this problem using GSM.h. I stuck with SoftwareSerial.h but have found a reliable, reproducible solution to the problem.
First, I now useSIM900.print("AT+CNMI=1,2,0,0,0\r"); to initialize my SMS mode, it seems to enable properly every time.
Second, after the read() from the SIM card I clear out the contents with SIM900.flush() which seems to prevent phantom messages from appearing.

I used Mega 2560 connected to GSM shield as following:

GSM TX --- pin 10 on Mega
GSM RX --- pin 3 on Mega
GND to GND

Check your baud rates. They appear to be different. That will cause problems.

They are two different codes, not meant to run together. But true, the baud rates for the top and bottom don't match, but that does not solve the problem.


text:
Linking the Arduino Bootloader In Atmel Studio
I have been trying to get the Arduino bootloader to compile into my firmware binary in Atmel Studio. I got the bootloader project to link and compile. I use ArduinoCore and the bootloader as a dependencies to my main code. The dependency tree looks like:

ArduinoCore
bootloader
Main firmware

The Bootloader
It took me a bit to get the bootloader to accept the rest of ArduinoCore as a dependency but it compiles into a static library. I use the bootloader linker to specify the memory location of the bootloader binary. It should start at 0x0 and provide a jump to the main firmware, located at 0x2000.
Bootloader linker flags:
-Tbootloader_samd21x18.ld -Wl

And here are the contents of the linker script:
  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x2000 /* First 8KB used by bootloader */
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000-0x0004 /* 4 bytes used by bootloader to keep data between resets */

This is based off of the .cProj file that comes with the linker. It is compiled as a static library so I can include it into my final binary.
Main Firmware
My code has both the ArduinoCore and the bootloader static libraries as dependencies:
libm
libArduinoCore
libbootloader

And I am using these linker flags:
-Tflash_with_bootloader.ld -Wl,--cref -Os -Wl,--check-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align

The contents of this linker script are moved out by 8KB in order to accommodate the bootloader at the start of the binary:
    FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000  /* First 8KB used by bootloader */
    RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000

And yet, my entry point does not appear to ever hit the bootloader. It jumps straight to "main.cpp" from ArduinoCore. The firmware runs as expected, but the bootloader does not appear to have been included.
Is this some kind of dependency issue? Am I misusing the linkers?
Any help with getting this to compile under a single binary would be very much appreciated. Thank you very much!

it is not really an Arduino question

" .cProj file that comes with the linker." I'm guessing you meant "with the bootloader."  Is the goal just to wind up with a single binary that has both the sketch code and bootloader in it, because the IDE and arduino-cli do that.  Or do you really really want to use ATMEL Studio for some reason?

My whole project is in Atmel Studio. Doing it in Arduino IDE is not possible at this point, especially after modifying some of the core files. I think I have solved it for now using srec_cat.

This isn't exactly 100% the answer I was looking for, because I still want to know how I can use a static library build, as I mention in my post, and compile everything as a single binary. This method is essentially gluing two binaries together.
I found this great and informative post over here:
https://www.avrfreaks.net/forum/can-you-combine-appbootloader-using-as7
It uses srec_cat to concatenate two binaries after building them:
https://www.keil.com/support/docs/2666.htm
I use the offset specified from the '.ld' file using
srec_cat <firmware1.bin> -Binary <firmware2.bin> -Binary -offset 0x2000 -o <firmwareOut.bin>
As the post suggests, I set this up as a post-build event and set my build dependencies accordingly so that a full clean and make will produce a consolidated binary including the bootloader.
If anyone tries this, make sure you only use the non-bootloader binary generated by your main project build. The bootloader places new firmware at location 0x2000 and your firmware will break if it finds a bootloader at the location where the firmware is supposed to be. When uploading firmware to the bootloader, it does not overwrite the bootloader.

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


text:
Short Occuring Between Digital IO Pins on Arduino ZERO
I have a couple custom SAMD21 boards (similar to Arduino Zero) connected to a screen from which I am trying to read PWM screen touch signals.
The two boards are identical - same components and same setup. The PWM lines are run from the MCU to a connector and then to the screen. There are no components on the PWM line (there can be an optional ESD suppresor but I have unmounted it for now).
On one board, I do not experience any problems - the screen works, touch signals are received and processed accordingly.
On the other board, the PWM does not work at all, in fact, the digital pins used to control it do not work at all. The PWM lines are hooked up at PA04 (Digital Pin 17) and PB09 (Digital Pin 15). When I try to write a value (high or low) to one of these registers, the code freezes. When I remove the screen, the problem goes away.
I set up an example, which just involves writing a HIGH signal to one pin and a LOW signal to the other.
So I took the two PWM pins (15 and 17) and connected them with a 220ohm resistor. On the functioning board, everything works, the code completes, and I read about 1.3V between the two.
But on the bad board, using the same setup with the 220ohm resistor, the board freezes in the same way as with the screen. Removing the connection (including the resistor) clears the error.
Is there a way inside the firmware to correct this? The operation is so simple and it freezes even when I try to write directly to the register - meaning I can't check the rdy bit for completeness while the pointer operation is not complete. Should hardware components be added the digital IO lines? I am unclear on how to proceed given that one identical setup works and the other does not.
Thank you very much for any help!
void setup() {

  uint8_t _yp = 18; //PB08
  uint8_t _ym = 16; //PA05
  uint8_t _xp = 17; //PA04
  uint8_t _xm = 15; //PB09

  SerialUSB.begin(115200);
  while (!SerialUSB);
  SerialUSB.println("Serial initialized...");

  pinMode(_yp, INPUT);
  pinMode(_ym, INPUT);
  pinMode(_xp, OUTPUT);
  pinMode(_xm, OUTPUT);

  SerialUSB.println("pinMode set successful");

  SerialUSB.println("Write xp high");
  digitalWrite(_xp, HIGH);
  SerialUSB.println("Write xm low");
  digitalWrite(_xm, LOW);

  SerialUSB.println("Finished");
}

void loop() {
}

consider the possibility that the failing board is actually the good one and the board that works is actually defective ..... i have seen an instance when a defect prevented the board from failing ...... maybe you have two pins shorted on  the screen  ...... one of the pins is blown on the board that works

I certainly hope not. I've made about 350 of these so far. I've checked the screen for shorts, and even removed one of the components I suspected of causing a short. Today I also swapped the two MCUs - the error carried itself along with the chip to the other board..


text:
Write to EEPROM during power down
I am making a counting device, and I would like to be ensure that the count is not lost if the power is lost.
As I need to count to many millions I cannot use EEPROM writes as I will trash the nvm after ripping through the 100,000 max write cycles. I also need to ensure the count is accurate, so can't update 'every-so-often' either.
I want to write to EEPROM when the Arduino detects power down. I am reading on an Analogue input pin and am then planning on using a capacitor to hold the power on to complete the write. I have this set up but am having issues testing as I have found that when Ground is connected to GND pins and then when 5v is supplied to any I/O pin the device powers up. I have now tested a Nano and Uno and have found the same thing on both.
I have looked through the arduino site and tried looking for forums where this has been discussed, but to no avail.
Is this damaging to the Arduino if powered in this way? Does this pass the sanity check as a way of achieving my main objective of not loosing the count on power down?
thanks in advance :)

The name for it is "parasitic power" - it is a well-known phenomenon.

when 5v is supplied to any I/O pin the device powers up - why is this an issue anyway? How does this apply if the power is lost?

I wasn't sure if this was even an issue or not! I just wasn't expecting this to happen and wanted to know if I would damage the device. Thanks for your help

A more sophisticated version of @MikaelPatel's techique is not to store the individual counts, but to store a derivative:

Reserve a block of storage with (say) 8 counters. Each counter has as many bits as necessary to store the largest value - but see below for what "largest" means.
Each time the count goes up, write into the next counter along (modulo the number of counters).
But don't write the value of the counter, write the value divided by the number of counters - counter/8.
Here's the trick: while that looks like you're losing precision, you're not - because the counter location is information too! In fact you're gaining size.

It's best shown with an example. For ease, I'll assume an 8-bit counter, and only 8 counters:
0000: 03 03 03 03 03 02 02 02

Assuming that everything started at 00, that means that it took 8 counts for them all to get to 01, a further 8 counts for them all to get to 02, and only 5 counts to get the first 5 to 03. That's a total of 8+8+5 or 21.
At boot time, look for where the number sequence goes down. That's your current buffer position for future updates, plus the information for the current value:
CurrentCount = [Smaller number] * [Number counters] + [Number of larger];

Once you've worked it out, keep the current value for incrementing, and the buffer pointer for where to store the next count.
Advantages:
A. You write as often as you would storing a counter - but in different locations, spreading the load.
B. Each location (8, 16 or 32 bits) can store a certain maximum - but the total maximum is a factor of Number of Counters larger than that!
Odometer manufacturers use this exact technique to store the current mileage in digital dashboards - they have a legal requirement to maintain the correct number. They only use 16-bit counters (which would overflow after 65,535 miles), but then they use 16 counters, for a total mileage maximum of over a million. Each location only gets written every 16 miles, and they don't need to use 32-bit locations.

I would suggest powering it from the 12V input and monitor the 12V with a power supply monitoring chip or circuit which will send an interrupt to your system when the voltage drops to whatever voltage you design it for. This can be accomplished with a few resistors and a comparator.
Your hold up time will be controlled by the amount of capacitance on the 12V side.  When the interrupt is tripped write the value to EEPROM and then shut down.
The analog input is a good sounding idea but there is a lot of latency between the time the voltage starts to fail and is detected.  The hardware interrupt will be much faster giving you more time to save your counter and the additional capacitance on the 12V side will give you a lot more time then back feeding through the GPIO pins..

A typical method of increasing the number of writes to EEPROM is to use a vector of counters instead of a single value. The counter value is written to the EEPROM vector in a cyclic fashion.
On startup the vector is searched for current counter value, i.e. the highest counter in the vector. The write index is restored by locating the lowest counter value.
The number of writes is increased with the length of the vector.
Please read more about this method here.

The arduino chips have clamping diodes on all the GPIO pins. So if the voltage on one of the pins is above Vcc (which is 0v is there is no power applied to the chip), the internal diode will 'redirect' this voltage to the Vcc line. This will damage the chip, is too much current is going through the clamping diodes.
Instead, connect the 5v signal via a large resistor (e.g. 100k) to the input pin.
Using a capacitor (plus diode to prevent backfeeding) will work. You just have to be careful if you have connected anything to an output pin that uses current. An led running at 20mA will drain a charged capacitor pretty quickly.
What I've done in the past is use the entire EEPROM space to store a single value. Just write every next value to a higher address. On powerup read the entire EEPROM till you find two adjacent address that don't contain successive numbers. Then you know where the last written value was, and you can read this last value, and continue writing the the address right after that one.

As you have mentioned, the caps are draining quickly. They need to need to be too big for the space I have available. I am now going to work on using the EEPROM in blocks. Thanks for you help

Connect all external stuff, that uses power, via transistors. Also make sure signal outputs have resistors on them, as some ICs have clamping diodes, which would result in the external IC being power though the signal pin on the atmega if power is disconnected. Also make sure you have low voltage caps. The lower the maximum voltage the small a cap can be. Also you can parallel to smaller caps together to get double the capacity. I wouldn't dismiss the original idea too soon. But without some wiring diagram I can help you beyond the above hints.


text:
Connect my arduino with ethernet shield to new router
I just changed the router for my webserver and I'm having trouble to connect my arduino with the LAN.
I'm using a router which uses Zhone technology, and I've been working with NetGear for a while without problems.
The procedure I've done so far is:

Connect the arduino with the ethernet and run the DhcpAdressPrinter example
Once I got the adress, in my case 192.168.1.125 I run the WebServer example, using the IP assigned by the DHCP.
In the serial monitor, I see it has started the program with the correct IP.

Problem: WHEN PUTTING THE IP INTO A BROWSER, NOTHING CHARGES
More info:

In my router page (192.168.1.1) I can see that each ethernet port has
assigned a MAC adress, I don't really understand why.
I also can see that the arduino has been successfully added to the DHCP with the IP assigned and the MAC adress that I wrote on the code
Finally, add that I've read in another website that sometimes the problem is due to the fact that the router just let the access to some specific MAC adress, but i'm not sure.

Any help will be apreciated! Thanks!

Did you try to strip down the problem to a tiny test snippet to share?

Can other devices on the same ethernet connections communicate with your PC?

If there is something maybe wrong with your MAC, you should: 1)Make sure your cellphone can connect normally. w) change your IP to your cellphone's, and close your phone's wifi connection. Then try arduino program again. This idea mainly is based on using your phone's known-as-available mac.

Finally, I was capable to solve it by just creating a port forwarding with the IP that was assigned by the DCHP.
It looks like my router for security reasons don't let you comunicate with other devices within the lan, so it's necessary to open a port and access the device through it!

Sounds like "wireless isolation" to me - which is where I was heading with my comment above.

Yes you are right Makenko, I think this is the correct term :)


text:
Consulting and inserting a string into an array if it doesn't exist (Arduino IDE) 1
Sorry that I repeat my question, I can't enter to my user...
In the project I'm doing, I connect an arduino mega with ethernet and Post some Strings to the server. The arduino mega has a receiver(315MHz). I have some arduinos nano connected with PIR sensors that sends a some int with transmitters (315MHz). What I want to do is a list in my arduino mega that stores the values sent by the arduinos nanos to use them to my server (using POST). my question is the following:
If I had an empty array, what I would like to do is
listOfSensors[]={}

void funtion (String sensor){
    if (sensor is inside listOfSensors){
         //dont do anything
    }
    else {
         add sensor to listOfSensors
    }

I have been looking for hours, but I haven't found anything so far... Anyone has any idea? Thanks!!

Don't just double-post. Work out how to log into your earlier user. I'm sure StackExchange has ways of retrieving your password, or whatever-it-is that went wrong.

I registered with my mail but I didn't confirmed, then I accesed with my facebook, wich is related with my mail, so when I try to access the other account it says I'm already registered...I know I shouldn't but I really can't acces to my account

In C there is no such thing as an "empty array".  All arrays have a finite pre-defined size.
String sensors[10]; // Room for up to 10 sensors

The usual way of storing an unknown number of entries that will be added to "as and when" is to use a linked list or doubly-linked list.
A linked list is a list of items where each item also contains a pointer to say where the next item in the list is located.
Also you shouldn't use the String class as it is not good when working with linked lists (or in general - stick to C strings).
Warning: linked lists aren't for the faint of heart.
First you would define a struct to store the data you want in the linked list:
struct sensor {
    char *name;
    int currentValue;
    struct sensor *next;
};

That would store the name of the sensor ("name"), the current value from the sensor ("currentValue") and also contains a pointer ("*next") to the next entry in the list.  That last bit is the most important.
Now you create a "head" pointer variable to start your list off:
struct sensor *mySensors = NULL;

That starts out as NULL to say "This variable has nothing in it at the moment".
Now that was the easy part.  The hard part is adding entries to the list...
A couple of helper functions can be of use here.  Let's start by defining a function that will look for a specific entry by name in the list:
struct sensor *findSensor(const char *name) {
    for (struct sensor *scan = mySensors; *scan; scan = scan->next) {
        if (strcmp(scan->name , name) == 0) {
            return scan;
        }
    }
    return NULL;
}

That will start off with a pointer variable scan pointing to the first entry in the linked list (mySensors).  While it's pointing to a valid entry (not NULL) compare the name to the given string and if they match then return the entry we are pointing to.  Next point to whatever the "next" pointer is pointing to, so you move down the list.
Now to add a sensor:
struct sensor *addSensor(const char *name, int value) {
    // First look to see if it exists:
    struct sensor existing = findSensor(name);
    if (existing != NULL) { // We found it
        existing->currentValue = value; // Update the value
        return existing;
    }
    // We haven't got it in our list, so create a new entry:
    struct sensor newsensor = (struct sensor *)malloc(sizeof(struct sensor));
    // And fill in the data:
    newsensor->name = strdup(name); // Create a COPY of the string
    newsensor->currentValue = value; // Store the value
    newsensor->next = NULL;
    // IMPORTANT: The new entry must point to NULL to mark the end of the list:
    newsensor->next = NULL;

    // Now where to add it in the list? Is there even a list?
    if (mySensors == NULL) {
        // No? Then we just make our new entry the head of the list:
        mySensors = newsensor;
        return newsensor;
    }
    // Otherwise we need to scan through the whole list to find
    // where the tail of the list is:

    struct sensor *scan = mySensors;
    // While the current entry points to a valid next entry
    while (scan->next) {
        // move on to that next entry
        scan = scan->next;
    }
    // There must be no valid next entry now (scan->next == NULL), so
    //  add our new sensor as the next valid entry:
    scan->next = newsensor;
    return newsensor;
}

Removing a sensor from the list is a much more involved process (even more than adding a sensor).  You need to "splice" the list around the deleted entry.  I'll add detail on that if you need it, but by the sound of things you won't be removing entries, only adding them.
The routines shown there (I haven't actually tested them, but it is standard code I write all the time) aren't as efficient as they could be.  If you are adding and removing entries all the time and you end up with quite a large list it can take longer and longer to scan right through the list to find the last entry to add to.  If that is the case you can maintain a "tail" pointer that you always update to point to the last added entry whenever you add one.  That can then be used to rapidly add to the end of the list without having to scan through the whole list every time.
Another optimisation if you do a lot of scanning around within a list is to make a doubly linked list.  This is just like the linked list above except it works in both directions.  Not only do you store a next pointer, you also store a previous pointer.  You can now scan in either direction - from head to tail or from tail to head, or hopping around at will inside the list.  That is especially useful if you want to do things like ordering the list alphabetically.

If you only need to add items of a fixed size to your sensor list (i.e. you don't need to delete items or sort them), you can use an uninitialized array large enough for the maximum number of items it will need to hold:
#define MAXSENSORS 30               // max sensor count
#define SNAMELEN 12                 // max sensor name length

struct sensorData {
    char sname[SNAMELEN+1];
    uint16_t svalue;
};                                  // defines data for 1 sensor

uint8_t sensorCount = 0;
struct sensorData listOfSensors[MAXSENSORS]={0}; // array of sensor data, initialized to 0, 0, ...

You'll also need an unsigned int (perhaps only a byte) to keep track of the count of items in the array, which you'll increment every time you add another sensor (up to the maximum number).
I think this is what you meant by "empty array". You would add your next sensor data at listOfSensors[i], then increment i. Likewise, you would search for a sensor in the array from listOfSensors[0] to listOfSensors[i-1].


text:
Including an arduino library in Eclipse Neon (undefined reference to)
I'm trying for the first time to use Arduino Libraries (Servo.h & Servo.cpp in this case) in Eclipse IDE.
So far I've managed to compile and run Arduino code using this tutorial (I suppose many of you already know it).
The problem comes when I add the Servo.cpp and Servo.h files and try to run the program:
    13:35:08 **** Incremental Build of configuration Release for project Servo ****
make all
arduinoEclipse/subdir.mk:268: warning: overriding commands for target `arduinoEclipse/wiring_pulse.o'
arduinoEclipse/subdir.mk:261: warning: ignoring old commands for target `arduinoEclipse/wiring_pulse.o'
Building file: ../ServoTest.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"C:\arduino\arduinoEclipse" -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega328p -DF_CPU=1600000UL -MMD -MP -MF"ServoTest.d" -MT"ServoTest.o" -c -o "ServoTest.o" "../ServoTest.cpp"
Finished building: ../ServoTest.cpp

Building target: Servo.elf
Invoking: AVR C++ Linker
avr-g++ -Wl,-Map,Servo.map,--cref -mrelax -Wl,--gc-sections -mmcu=atmega328p -o "Servo.elf"  ./arduinoEclipse/CDC.o ./arduinoEclipse/HardwareSerial.o ./arduinoEclipse/HardwareSerial0.o ./arduinoEclipse/HardwareSerial1.o ./arduinoEclipse/HardwareSerial2.o ./arduinoEclipse/HardwareSerial3.o ./arduinoEclipse/IPAddress.o ./arduinoEclipse/PluggableUSB.o ./arduinoEclipse/Print.o ./arduinoEclipse/Servo.o ./arduinoEclipse/Stream.o ./arduinoEclipse/Tone.o ./arduinoEclipse/USBCore.o ./arduinoEclipse/WInterrupts.o ./arduinoEclipse/WMath.o ./arduinoEclipse/WString.o ./arduinoEclipse/abi.o ./arduinoEclipse/hooks.o ./arduinoEclipse/main.o ./arduinoEclipse/new.o ./arduinoEclipse/wiring.o ./arduinoEclipse/wiring_analog.o ./arduinoEclipse/wiring_digital.o ./arduinoEclipse/wiring_pulse.o ./arduinoEclipse/wiring_shift.o  ./ServoTest.o
./ServoTest.o: In function `setup':
ServoTest.cpp:(.text.setup+0x8): undefined reference to `Servo::attach(int)'
./ServoTest.o: In function `loop':
ServoTest.cpp:(.text.loop+0x20): undefined reference to `Servo::writeMicroseconds(int)'
ServoTest.cpp:(.text.loop+0x5a): undefined reference to `Servo::writeMicroseconds(int)'
ServoTest.cpp:(.text.loop+0xbc): undefined reference to `Servo::write(int)'
./ServoTest.o: In function `_GLOBAL__sub_I_myservo':
ServoTest.cpp:(.text.startup._GLOBAL__sub_I_myservo+0x4): undefined reference to `Servo::Servo()'
collect2.exe: error: ld returned 1 exit status
make: *** [Servo.elf] Error 1

As you can see in the console output, it compiles correctly, but when it comes to the linker, it doesn't find the function references from the Servo.cpp.
As I have seen in this post, the problem comes from the fact that I need also to generate an .a (static library) file in order to link both .h and .cpp files. Still, I have no idea how I am supposed to generate this file.
For this project, I have just added in arduinoEclipse folder all the .cpp and .h files from C:\arduino\hardware\arduino\avr\cores\arduino, C:\arduino\hardware\arduino\avr\variants\standard & C:\arduino\libraries\Servo.
Do you see what I could be missing?
Thank you in advance

The article explains 2 roads. You should at least tell which one you took.

I'm using AVR Plugin

The arduino build process is described here: https://www.arduino.cc/en/Hacking/BuildProcess
You do not really need to build a archive. You can link all your source files but that will result in a far bigger file to upload to the embedded device.
The normal CDT process to build a archive is by having 2 projects. One for the "archive" one for your sketch and then use project dependencies.
However since Arduino IDE 1.5 this process is hard to maintain because changing settings for your sketch may force you to change your archive compilation settings.
As far as I know; out of the box CDT does not support creating a library and linking it to a "executable" in one project. This is something Sloeber (road 1 in the article) has added.
I know this because I'm authoring Sloeber.

I don't have eclipse handy right now, so I may not have the menu options verbatim here, but with eclipse there are more steps to including a library than just writing the line in the code.  Go to the project in the project explorer and right click the project name.  Hit import and select the option for importing Arduino libraries into the sketch.  It should bring up a dialog with a list of all the libraries you have installed and you can choose from there.  Then there will be a folder in your project called includes IIRC and it will have a link to the library that you imported.  Now when you compile it will find the library.

There is no "import arduino libraries" if you followed road 2 in the article. This is so because "import arduino libraries" is part of Sloeber.
Note that the latest versions of sloeber just adding the include is sufficient in many cases.
Also note that there is a menu item Arduino which contains "import arduino libraries"

Thanks for the correction.  I just assumed that the poster was using the Arduino plugin for Eclipse.