text:
What is the best way to attach TMP36 sensor to the copper coil?
I am very new to this site and this question may not be strictly related to Arduino, but I do small Arduino project which needs to measure the temperature of the copper coil using TMP36GZ sensor.
What is the best way to glue it to the coil for best measurements?
Shoul I use silikone or epoxy?
Should I take extra steps to ensure proper readings from the coil surface (f.ex.: using thermal paste)?

If you don't have to worry about conductivity from the electrical standpoint, you could use a thermal epoxy such as Arctic Silver which uses "microfine" particles of silver to conduct heat. It's a two part (redundant when using the term epoxy, I think) adhesive that is engineered to transfer heat, but may also short conductors. I've used the stuff and unless subject to intentional separating force, it holds well.

The datasheet devotes a whole page to mounting and thermal conductivity (though not to specific adhesives), particularly with respect to the plastic, through-hole devices, as the leads provide more a direct conductivity path to the sensing junction than the plastic bead does. If the surrounding air is at a different temperature from the coil surface you'll either need to insulate the leads from the air, or better, epoxy them to the coil with a thermally conductive but electrically insulating epoxy.
Here's an excerpt:

Caution should be exercised, especially with T-3 packages, because the > leads and any wiring to the device can act as heat pipes, introducing errors if the surrounding air-surface interface is not isothermal. Avoiding this condition is easily achieved by dabbing the leads of the temper-ature sensor and the hookup wires with a bead of thermally conductive epoxy. This ensures that the TMP35/TMP36/ TMP37 die temperature is not affected by the surrounding air temperature. Because plastic IC packaging technology is used, excessive mechanical stress should be avoided when fastening the device with a clamp or a screw-on heat tab. Thermally conductive epoxy or glue, which must be electrically nonconductive, is recommended under typical mounting conditions.

Update:
I also noticed they didn't specify an epoxy, which I take to mean the feel it isn't critical. You'll need one compatible with "most" plastics and with copper. I'd probably use a big "wad" (that's a technical term :) of any off-the-shelf non-electrically conductive epoxy over the whole sensor and its leads, getting the sensor face as close to the copper as possible. I might even wrap some thermal insulation around the connecting wires for a foot or so, or even wrap that much of them around the coil and tape them to it, just to keep the sensor and the wires at as close to the coil temperature as possible. My guess is that will be more than sufficient to get temperature readings of the coil to within the sensor's limits of accuracy.

Data sheet is a bit too technical for me (a newcomer). F.ex.: it does not specify clearly what type of plastic the enclosure is made of and what type of thermally conductive epoxy need to be chosen. Is any good or does it require special epoxy, suitable for copper, etc..


text:
Can I use Arduino Nano V3 to program another arduino (Pro Mini)?
I was planning to buy serial to USB converter (FT232RL) to be able to program Arduino Pro Mini.
But the shop nearby offers Arduino Nano V3 at almost the same price.
Could I use this Arduino instead (and gain new microcontroller platform for free ;-)?

Have you tried Arduino as ISP?

I did read: http://www.arduino.cc/en/Tutorial/ArduinoISP but it says about programing bootloader and does not clarify if Nano V3 can also b used.

You can flash any sketch with Arduino ISP.

Yes!
Yes, you can substitute the Arduino Nano V3 for the Arduino Uno and follow the instructions here, providing that the Arduino Pro Mini is a 5V version. (Otherwise, you will have to do some voltage conversion.)
Both boards have the same SPI pins as the Arduino Uno. The connections would be as follows:
Arduino Nano --> Arduino Pro Mini
5V  ------------------->  Vcc
GND  ---------------->  GND
D10  ----------------->  RESET (10uF between RESET & GND)
D11  ----------------->  D11
D12  ----------------->  D12
D13  ----------------->  D13
The process detailed in the link can be summarized as follows:

Load the ArduinoISP sketch into the Arduino that you will use as programmer. You find it under Examples > 11. ArduinoISP > ArduinoISP.
Select the serial port of the Arduino Nano (target): Tools > Port > corresponding port number.
Wire up the two Arduinos as described.
In the Tools menu, set the programmer to the Arduino as ISP.
Select the target board: Tools > Board > Arduino Pro Mini.
Open the program to be loaded to the Arduino Pro Mini and program it by selecting Sketch > Upload using programmer

please note, that 10uF capacitor should be connected on Nano board (programmer), instead of pro mini (target)

source: Stack Exchange

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

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

sort: votes


text:
UNO's digital pin continue to read 1 for a while
I'm doing some tests and I notice a bad things with digitals pins. I have a wire that sends 1 signals. If i connect it to a reading pin, I read 1 - and it's ok. But if i disconnect it, for 5-6 seconds Arduino continues to read 1 instead of 0! How can I stabilize it more quickly?

Where is the pin connected to when you disconnect the wire? Probably nothing. You shouldn't have pins floating!

Digital inputs should either be low or high. In this image acceptable input voltages on the left represent common TTL voltages based on a 0 to 5 volt range:

It is bad practice to leave a digital input floating.  A floating or disconnected input implies the voltage is unknown.  I suspect in your case a small amount of input capacitance held a charge for several seconds.  Once leaked off the input appeared to change from 1 to 0.  Even though you know what might be happening, you should not depend on it as it is unreliable behavior.
If connecting a SPST switch use a pull up (or pull down) resistor to pull the input pin to the opposite voltage the switch is pulling.  In this image the switch is connected to ground so the resistor is connected to positive voltage as a pull up:

The fist image comes from this Logic Level tutorial.

For Arduino (Atmega328), at 5V an input of above 2.7V will read as 1 and under 2.2V will read as 0. (https://i.sstatic.net/Dqnbp.png) This doesn't really match the values of your source, but my source is the ATmega328 datasheet. (To avoid confusion on the voltages)

ATMega328P inputs are Schmitt Trigger. There is no such thing as an "unknown" voltage level - only a "last valid" voltage level. The voltage has to drop below VIL for it to start registering LOW and then rise above VIH to start registering HIGH. Anything in between retains the previous setting.

St2000 's reply above gives the background, which is valid for any digital input, not just the Arduino pins.
However, in the specific case of the Arduino, one more thing should be noted: You can skip the use of an external pullup resistor by configuring the pin to use the internal pullup resistor:
pinMode(pin, INPUT_PULLUP) ;

This assumes, of course, that it is easy to modify the part of your circuit that is connected to your input pin to have the following two states:
- ground
- high impedance (floating)

If, for example, it is a switch you are reading, just connect one pin of the switch to your arduino pin and the other to GND.

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


text:
Do arduino librarys require the arduino to be connected to a computer?
The title pretty much explains my question. If I'm using a library for example one for an accelerometer does the arduino need to be connected to my computer because it's using a library? Or is the library uploaded to the arduino and there for can run with out a computer connected?

No.  Arduino libraries (strictly speaking only the utilized parts) are permanently built-in parts of your compiled sketch.  Effectively they are "statically linked" unlike the situation with modern RAM-based computer operating systems where compiled dynamic link library code may be separately loaded into memory for a program to call at runtime.
(This isn't even really a design choice, as the basic AVR Arduino's cannot load new program code into executable memory at runtime anyway - except by reflashing themselves like the bootloader does, which would be a bit slow compared to normal dynamic linking)
Of course if you have a library which is intended to perform communication with a computer, then that connection would probably be required for it to fully operate.


text:
Create own apache web server on Arduino Uno... just like you can on a raspberry pi?
I was wondering if I could create my own apache web server on my Arduino Uno, just like I did on my raspberry pi - https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
Anyone have any idea about this? From my research it seems like I cant achieve the same results on an arduino uno.
Thanks

I do recall someone actually managing to run Linux on an Arduino. It was quite impressive, involving a very large amount of external DDR RAM and bit-banging the interface to it. Basically emulating a virtual computer within the Arduino.  I can't find the original post though - it's been lost in time...
So yes, technically it is possible to run Linux, and thus Apache, on an Arduino.
Is it recommended to even think about trying to do something like this though?
Certainly not.
The Arduino is a microcontroller, not a computer. It is designed for controlling things (hence its name) not for general computing tasks.
It can, though, run its own web server software - that is, you can connect some form of network interface (Ethernet, WiFI, etc) and implement a very very basic web server. It can't really do much, and all interactivity has to be hard coded into it in C++. There doesn't (yet) exist any simple scripting engine or anything like that (PHP, etc) and you are very limited on how much you can implement (lack of memory) as regards anything fancy.
In general a web server running on an Arduino is used as a back-end to a proper web server and interacted with using Ajax calls or other similar methods.  More commonly though a web interface is shunned in favour of much lighter weight protocols or push technologies like MQTT.

You can only make a very, very, very basic webserver, that won't be able to handle more than a few requests per second.
You also need to add something like an ethernet shield, and probably an SD card reader. Which would make it about the same price as a Pi.
It's possible, but very limited, not practical in most cases, and not that much cheaper.

Indeed - essentially, whatever you use as a network interface ends up being a better "computer" than the Arduino, so you might as well just run your code on that instead.  And with things like the ESP8266 port of the Arduino environment, it doesn't even require much of a thought shift to do so.

While you can't make an apache web server with an Arduino Uno, you can if you access the linux module of the Arduino Yun board. I in fact did this and with some testing realized that it can't handle more than a few packet requests per second.
Although a raspberry pi is much cheaper and more capable than a re-programmed Yun if you want a "Mainstream" server
(Namely one Arduino Yun is $75.00 while a Raspberry Pi model 3 B is $35.00 at the time of this writing.)

No you can't. Apache (or any web server of similar functionality) will require:

tens to hundreds of megabytes of RAM
about 50 megabytes of storage
an actual operating system

Perhaps you can get the required storage with the SD shield, but it's practically impossible to get enough RAM or run a suitable OS on arduino.

Yes, you can make a web server.  Here is the tutorial.
You do not need Apache to create a web server.


text:
Connecting arduino and EV3 using I2C
I'm trying to connect arduino uno and ev3 by using this guide (http://www.dexterindustries.com/howto/connecting-ev3-arduino/),
everything works perfectly but when i tried to use analogRead block to display data from arduino it just displays  i2c address of my arduino.

Post your code and setup. What is the 'analogRead block'?


text:
Defining an NFC tag as NDEF using the Arduino Uno and the PN532 NFC module
I bought a bunch of blank Mifare Classic NFC cards and I'd like to write NDEF records to them using my Arduino Uno. When I read them using my Uno and a PN532 NFC module using Don's NDEF library however, it tells me they're not NDEF formatted.
Is there any way to define my NFC tags as NDEF using just the PN532 module and an Arduino Uno? (My Android phone doesn't support NFC.)

I found the answer to my own question right after posting it, while going through the examples included in the library above:
The library contains an example named "FormatTag" which does exactly what I was looking for.


text:
Streaming audio from PC to Arduino over WiFi
Say I wanted to, purely hypothetically, set up a pirate radio station by connecting an Arduino to a WiFi network away from home, streaming music to the Arduino, decoding it, and broadcasting it with an FM transmitter.
Given an Arduino (Genuino) Uno, a Sparkfun ESP8266 Thing Dev breakout board for WiFi connectivity, and an Adafruit Si4713 Stereo FM Transmitter breakout board, how would I go about the actual streaming of music (in MP3 or WAV format) from a (Windows) computer to the Arduino over WiFi? Would an Arduino Uno be powerful enough for this? Which components would I need to decode the audio?

The limitations of the serial out of the ESP8266 and into the Arduino would be one big constraint--115200 baud doesn't leave much time for processing.  Doing stereo D/A conversion with Arduino PWM would be an even more severe constraint.

Well, a sort of... You can stream 64kbps MP3, get it via wifi from esp8266. Then for all the rest, forget the Arduino.
You need a dedicated MP3 decoder chip (many out there, sta013 was one of the oldest beasts) which can take the digital mp3 stream and convert it to analog output.
You can feed the line level analog output to the FM Transmitter, and then you're golden.
Note that you shall develop some application on the PC to actually stream out the MP3 - an off the shelf solution such as a Shoutcast server may not work, as the usual web-radio stations inject station data and currently played track metadata into the mp3 stream what you have to remove from the MP3 decoder chip.
Since the actual wifi bandwidth with ESP is limited (as well as the processing power of the Arduino), you may switch to a more efficient compression format. For example, a 64kbps WMA sounds far better than a 64kbps MP3, and at 64kbps AAC is superior to any of the other formats. Ensure that your decoder chip can work well with a modern codec comperssion format.

Great in-depth answer, thanks! For the encoding, would something newer like the VS1053B do?

Could - but you do have a full PC for encoding, no? If you wish, you can encode real time the microphone plus some music playback on the PC (called "stereo mix") and stream out via internet to your Wifi module in the wild.


text:
Breaking a switch case from an ISR
I'm struggling with something. My CPU sits in a switch case state machine like this:
switch(expression) {

   case constant-expression_1  :
      statement(s);
      break; /* optional */

   case constant-expression_2  :
      statement(s);
      break; /* optional */

   /* you can have any number of case statements */
   default : /* Optional */
   statement(s);
}

I have an interrupt that occurs on a button press. In the interrupt, I change the switch expression to the case I want to go next, like this:
void ISR(void){
   expression = constant-expression_2;
}

After the interrupt has been handled, I want the CPU to return directly to the case being switched to, and to not continue where it left off.
Does anyone have any good ideas on how to implement this, if it's possible? I'd prefer to not have to wait for the code to finish what was happening in the previous case before going to the one being switched to.
Thanks in advance!

A rather drastic, solutions would be be to reset the chip in the ISR.

It is certainly possible, although I do not think there is any clean
way of doing it...
Here is an idea that may work: right before the switch statement,
you save the current context with the setjmp()
function.
Then, in the ISR, you restore that context with longjmp(). This is
kind of like a goto statement that works across functions:
#include <setjmp.h>

jmp_buf env;

ISR(FOO_vect) {
    expression = ...;
    longjmp(env, 1);  // go to start of loop
}

void loop() {
    setjmp(env);  // landing point from ISR exit
    switch (expression) {
        ...
    }
}

Notice that the normal exit sequence of an ISR (the reti instruction)
re-enables the interrupts. Since we are skipping this exit sequence, we
have to enable them explicitly upon return from setjmp()
interrupts are re-enabled not by the reti instruction but by longjmp()
restoring the CPU's status register.
Warning: This is a (very dirty) hack that I have not tested. If I
were to use this trick, I would first:

Carefully examine the generated assembly to convince myself it does
the right thing.
Test, test, test...

In case of problems, debugging this may be harder than just testing the
expression inside every slow function you have.
Addendum: Although I am saying that there is no clean way of doing
what you intend, there certainly is a clean way of achieving the same
end result: just make sure your switch statements return fast. My
preferred way of doing this would be to make sure no function ever
waits. For example:

A routine reading sensors would not wait for them to respond. Instead,
it would return immediately if no reading is available. If a reading
is available, it would retrieve it, send a query to the next sensor
in the list, then return.
A communication routine would not wait for complete messages. Instead,
it would return immediately if no byte is available. If a byte is
available, it would buffer it and return. Unless it's the last byte of
a complete message, in which case it would process the message.

Obviously this could require a heavy refactoring of your code, probably
using finite state machines (see for example the tutorials
here
and here). It may be easier to
just test whether the expression has changed inside every busy-wait loop
you have, as recommended by Gerben's and Nick's answers.

I think longjmp() may return to the mainline but with the ISR's context; I'd expect some surprising behavior. But if you call setjmp() prior to the switch statement (or higher, if appropriate), and the ISR sets a (volatile!) flag to indicate it has been called, then each case could do if( flag ) longjmp(); as frequently as it is appropriate to do without leaving some operation partially completed. ...

... You'll probably want to abstract away as much of the case code as possible into small functions where the actual work and the flag-testing will be done. This way, both setjmp() and longjmp() will have (had) the same context.

@JRobert: “longjmp() may return to the mainline but with the ISR's context” I don't understand what you mean by “ISR context”. setjmp() and longjmp() save and restore quite a bit of context, including all the call-saved registers and the stack pointer.

Longjmp restores the context as it was at the setjmp call. It may be; I just don't know. It sounds like you had similar concerns in your caveat to inspect the assembly code and to test carefully. It's quite possible it will work as expected/desired. On the other hand, allowing the ISR to return first gives me a lot more confidence in the outcome.

@JRobert: I fully agree with you. I posted this because I think it's a fun hack worth sharing. I already stated in the answer I do not consider this a clean programming technique. I just expanded on that consideration, just in case it was not already extra clear.

First, put your major processing into functions. That looks better anyway. eg.
switch(expression) {

   case constant-expression_1  :
      function1 ();
      break; /* optional */

   case constant-expression_2  :
      function2 ();
      break; /* optional */

   /* you can have any number of case statements */
   default : /* Optional */
      function_default ();
}

Now inside your functions do a return if you notice the expression has changed. This will get you out of any number of nested loops. For your 30 sensors, for example, you can now have a loop.
void function1 ()
  {
  for (int i = 0; i < 30; i++)
    {
    if (expression_changed)
       return;
    // take sensor reading
    }
  }  // end of function1

Also, as Gerben suggested, replace any delay calls with a function that does the delay, however which ends early if the expression changes. It can return a boolean to let you know this happened. eg.
boolean myDelay(int ms)
  {
    uint32_t start = micros();
    while (ms > 0)
    {
        if (expression_changed)
           return true;   // early return
        if ( (micros() - start) >= 1000)
        {
            ms--;
            start += 1000;
        }
    }
  return false;   // normal return
  }

Now any function that needs delays can use that, like this:
void function2 ()
  {
  do_something ();
  if (myDelay (1000))
     return;   // bail out
  do_something_else ();
  }  // end of function1

My problem is, one of my cases includes a communication transceiver method, which can take a lot of time to get through

There must be logical spots where you can just test the expression and do a return (preferably cleaning up anything that needs it) when required.

Most of the time this isn't a problem, because code normally runs pretty fast. The problem, most of the time, is the use of delays. What I did was use my own delay function that checks if the expression has changed, and if so, immediately returns.
Below is my code. I had to modify it a bit, so it might not work out of the box, but will give you the idea as to how.
volatile byte expression;
volatile boolean expressionChanged = false;

switch(expression) {

   case constant-expression_1  :
      statement(s);
      myDelay(1000);
      statement(s);
      break; /* optional */

   case constant-expression_2  :
      statement(s);
      myDelay(500);
      statement(s);
      break; /* optional */

   /* you can have any number of case statements */
   default : /* Optional */
      statement(s);
}

void myDelay(int ms)
{
    uint32_t start = micros();
    while (ms > 0 && !expressionChanged)
    {
        //yield();not implemented in arduino
        if ( (micros() - start) >= 1000)
        {
            ms--;
            start += 1000;
        }
    }
}

void ISR(void){
   expression = constant-expression_2;
   expressionChanged = true;
}

Thanks for the answer! My problem is, one of my cases includes a communication transceiver method, which can take a lot of time to get through, and another case does sensor acquisition from about 30 sensors. I would prefer to not have to check in every "slow" piece of code if the case has changed, but if this is unavoidable, it will have to do. Any ideas?

In case of the 30 sensors, you could rewrite the code, so it only check a single sensor at a time, and then in the next cycle checks the next sensor. Your communication transceiver description is to vague for me to make any suggestions. Other that sprinkeling if(expressionChanged)break; around. This is probably unavoidable, since breaking at certain locations in the code, could cause some bad side-effects.


text:
Arduino continually resets when connected to external power supply, but not USB
I'm working on a seemingly simple Arduino project which plays a sound and flashes an LED when provoked by some trigger.
The problem:
When powered by an external power supply, the Arduino continually resets after playing ~1/4 seconds of audio. When powered from USB, it works fine (however the LED, being powered from the external power supply, of course does not work here).
Wiring diagram:

Parts list:

Arduino Pro Mini 5V
Adafruit MAX98306 3.7W amplifier
Sparkfun FemtoBuck LED Driver
4 Ohm 3W speakers
3W LED

I am using a 9V 1A power supply. Again, when no speakers are connected, the Arduino and LED work as intended. It's only when a speaker is connected that the board resets over and over again. Playing roughly 1/4 of a second of audio and then resetting implies to me that there's insufficient current, however, the problem persists even after using a 2.5A power supply.
Things I have tried:

Increasing the power supply to 12V 2.5A
Desoldering the LED driver (even with the LED driver removed, the board still resets)
Checking continuity and staring at the wiring for long periods of time while scratching my head

Overall, I'm at a loss as to why it would work when powered via USB instead of through my external power supply.
What am I doing wrong? Any insights are greatly appreciated!

do you have a few capacitors you can add to the supply lines? 220~1000uF 25V?

I do, but I'm not knowledgeable enough about capacitors to understand what that would provide. Can you elaborate?

@Josh it's best to ask a new question and reference this question instead of piggybacking off of another question. You'll get more eyeballs that way.

Most likely lack of current - lack of current able to be provided by the Mini. The audio is powered from the onboard regulator on the Mini, which has limited current capacity.
If too much current is drawn it will either get too hot and go into thermal shutdown until it cools down enough, or it will drop the output voltage, making things reset and crash.
Power the audio system from an external 5V regulator.

But why would the speakers work when the Arduino is powered via USB? The amplifier is still be powered by the Arduino regardless of what the Arduino is powered by.

Because when powered by USB you're not using the onboard regulator. You're providing 5V directly so the regulator isn't needed.

Ah, that clears it all up! Okay, I'm off to get a 5V regulator. Thank you!

I now have a 5V regulator in the circuit that I picked up from the local electronics supply place today and everything is working wonderfully. Thanks again!

your power supply may be faulty. try a another power supply which can supply more current and common the GND of arduino and power suply..it may have internal short circuit or lack of current.


text:
How do I use Microduino (mCookie) on Linux?
I'm interested in getting the mCookie working in Linux — specifically, in Fedora 23. The Arduino IDE (version 1.6.4) is already available. I'm very familiar with Linux, fine with C, and completely new to Arduino.
The tutorials for Windows or Mac describe installing a customized version of the IDE along with drivers. Do I need special drivers on Linux? On the projects' GitHub site, I found the examples and a directory called 'avr' which has promising subdirectories like "bootloaders" and "libraries", along with files boards.txt and platform.txt.
Can I download this stuff and add it to the existing "system" arduino package somehow? How, and what will I need?

I'd tag this [tag:mcookie] and/or [tag:microduino] if I could....

First you will need the arduino 1.6.x package from updates, not the 1.0.x package from fedora. Then:

You will be adding a URL to the new Additional Boards Manager URLs option: https://github.com/wasdpkj/Microduino-IDE-Support/raw/master/package_Microduino_index.json

source
This tutorial tells you where and how to add that URL to the preferences, as well as how to actually install the required support files.

As of this writing, the platform configuration supplied as part of the above won't work out of the box in Linux; you will also have to edit ~/.arduino15/packages/Microduino/hardware/avr/1.6.7/platform.txt to:

replace compiler.path={runtime.tools.avr-gcc.path}/bin/ with just compiler.path=/usr/bin/
on the line starting recipe.ar.pattern=, change {archive_file_path} to {build.path}/{archive_file}

Hopefully this will be fixed in future versions.

You probably also want to prevent ModemManager from probing the serial device with this udev rule, just replace the vendor and product IDs as appropriate:
SUBSYSTEM=="usb-serial", ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="xxxx", ENV{ID_MM_DEVICE_IGNORE}="1"

Nice, thanks! This resulted in an error: Could not find boards.txt in /home/mattdm/.arduino15/packages/Microduino/hardware/avr/1.6.7. Is it pre-1.5? and exit on startup. However, when looking at that directory, there's an avr subdirectory with boards.txt in; I moved everything up one level and now it seems to be working....

@mattdm: That would seem to be a problem with their files; I also see all boards.txt files (on my system) directly in the architecture-appropriate directories rather than in any subdirectories.

I guess I'll file a bug report.

Ugh, that also hardcodes compiler.path={runtime.tools.avr-gcc.path}/bin/ in ./packages/Microduino/hardware/avr/1.6.7/platform.txt, when it should be (I think) just compiler.path=/usr/bin/ ... fixed that, and now I've got an error about {archive_file_path}. I've got some further research to do here, I see.

So, from here, that should be replaced with {build.path}/{archive_file}. Now a really simple sketch compiles but does not seem to actually upload. That's the next step, I guess. :)

Whoo. Final step was "bad USB cable replaced". :)


text:
Arduino sketch taking forever to upload, followed by multiple issues
I am using Arduino Uno board with Windows 10. From the tutorials on Arduino website, I am trying to upload the following code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1);
}

It had undergone a series of issues:
First,
avrdude: ser_open(): can't open device "\\.\com3"
I searched for his issue, and found that most common solution id to go to device manager and change the name of the port, then unplug and plug again the arduino board. I did that
Second,
C:\Program Files (x86)\Arduino\hardware\tools\axr\bin\avr-ar:
unable to rename 'core.a'; reason: file exists\\

I thiught it could be a memory problem. I used the reset button on the board, and repeated steps from the solution to the first problem. I tried to upload the code again.
But now, I am not getting any error message. But the problem is that it is taking forever to upload the code. I see Uploading... status since a long while. The green progress bar is also complete, but no uploading completed till now.
Any help to understand and solve this will be appreciated.

When the Arduino IDE says its uploading but never uploads, it is most likely a COM port issue. Try plugging the Arduino in a different port and make sure you change the port in the IDE. The problem seems to be you have changed the Arduino port, but not in the IDE. The Arduino IDE registers the previous port as open and tries to upload the program to that port. Go to Tools > Serial Port and it should list the ports(example):
COM 2
COM 3
Arduino Uno at COM 4
•COM 4

Every time you unplug and replug the Arduino you should check your ports and select the appropriate one ( It usually says Arduino *type* at COM *port number*
COM 2
COM 3
•Arduino Uno at COM 4
COM 5


text:
Cannot directly connect Arduino Ethernet to PC
I have been following various tutorials (especially: this) to connect an Arduino Ethernet board to my Ubuntu PC via Ethernet directly.
The IP address of the computer was found to be 10.100.31.128, and so I tried addresses in this range (10.100.31.67, 10.100.31.121, ...) without success. DHCP also doesnt seem to work. For the MAC address I used the sticker on the back of the board. I am using a patch cable, maybe that's the problem?

Did you tell your system that it needs to expect another client on the end of the cable?

No, how do I do that, or where can I find information on that?

uhm.. did you set a static IP on your PC? And then, how do you check the connection?

Who is the DHCP server?  The Ubuntu box?  Or a router?  If a router did you check to see if the router has issued an IP to the MAC of the Arduino Ethernet shield.  Maybe you can monitor the /var/log file w/a "tail -f" while you try to ping the Arduino (sorry, can't remember the exact system log file on a Ubuntu box, please look it up).  In the end, it's much easier to debug network problems on a Linux box as Window boxes tend to give up with out telling you (i.e. window boxes will say they are pinging but actually send nothing out on a failed network).

Also, I doubt you need this, but older Ethernet ports will not automatically detect a cross over problem.  So for direct connections (i.e. w/o a hub or switch between devices) you many need a cross over cable.

I created a new wired connection with a static IP, now this example is running.

So the problem was that your PC was configured to use a DHCP server, but no DHCP server was present. In this case, the PC displays an IP, but no routing tables are created and so you are not able to use any connection over that link. For direct connecitons, either activate a DHCP server on your PC or use static IPs

Network problems can be complex.  If these suggestions are not right I can change the answer later if other solutions present themselves.
If you are connecting two Ethernet devices directly you may need a cross over cable.
To test your connection with out using IP addresses, try to follow what is discussed in this answer where the MAC address is used on a Ubuntu system instead of the IP address.
You also might try using wireshark to monitor the Ubuntu box's Ethernet port.

When you connect your Ethernet Shield to your Ubuntu PC your PC 'looks' at the Ethernet shield as if it were a router and therefore tries to connect to it as an internet source, thus it tries to get an IP and other related stuff from the Ethernet shield.
BUT
What you want is that the Ethernet shield should use the ubuntu PC as an internet/local network source. For this you must have active internet on your PC from Wifi/ USB data etc.
You will have to BRIDGE the connections of your Ethernet shield and your internet source in order to do so.
The link to accomplish Bridging networks in Ubuntu is here
When you bridge two Ethernet networks, the two networks become one single (larger) Ethernet network. Thereby making the Ethernet shield a part of the larger network (Internet in this case). You can now upload any of your sketches onto the Arduino as per your requirements and accomplish your task.


text:
Servo jitter with two atmegas
So i'm building my own quadcopter at this moment and I have designed a flight controller board for it using two atmega328p's. I've programmed it so that the first atmega receives al the data from sensors and the radio transmitter and then calculates the values for the motors, LEDs and servos. To have it run smooth, the motor controller (ESC) gets updated 250 times per second (250Hz). So the first atmega sends all the data via i2c to the second atmega 250 times per second. When the second atmega receives the data it causes an interrupt via Wire.onReceive(event);. This then sets a flag so the main loop starts when there is new data. Here is a really simplified version of my code:
atmega 1:
#include <Wire.h>
#include <CapacitiveSensor.h>

int servo1;
int val, i;

int escLR;
int escRR;
int escLF;
int escRF;

byte send_array[11];
byte error;

unsigned long int loop_timer;

void setup() {

  Wire.begin();                                                    //joins the i2c bus
  TWBR = 12;                                                      //set i2c clock to 400kHz

  GyroAccelInit();

  delay(3000);

  loop_timer = micros();                                     //set the timer for the loop
}

/*************************************************************************************************************************/

void loop() {

  //ReadGyro();                                                              //commented out because not relevant
  //ReadAccel();
  //PPM_get();

  if (error == 1) {
    send_array[10] &= B11111000;
    send_array[10] |= B00000001;                                   //set led bits to red
  }

  SendData();                                                                //send the data

  if (micros() - loop_timer > 4050) {                               //set error if the loop takes too long
    error = 1;
  }

  while (micros() - loop_timer < 4000) {}                          //wait until 4 milliseconds have passed
  loop_timer = micros();
}

/*************************************************************************************************************************/

void SendData() {                                                  //sends the data to second atmega

  send_array[1] = escLR & 0xFF;                                    //isolates the low bits
  send_array[0] = escLR >> 8;                                      //shifts high bits to the right

  send_array[3] = escRR & 0xFF;                                    //isolates the low bits
  send_array[2] = escRR >> 8;                                      //shifts high bits to the right

  send_array[5] = escLF & 0xFF;                                    //isolates the low bits
  send_array[4] = escLF >> 8;                                      //shifts high bits to the right

  send_array[7] = escRF & 0xFF;                                    //isolates the low bits
  send_array[6] = escRF >> 8;                                      //shifts high bits to the right

  send_array[9] = servo1 & 0xFF;                                   //isolates the low bits
  send_array[8] = servo1 >> 8;                                     //shifts high bits to the right

  Wire.beginTransmission(42);                                      //begins the transmission to device 42

  for (int n = 0; n < 11; n++) {
    Wire.write(send_array[n]);
  }

  Wire.endTransmission();                                          //sends the buffer to the slave
}

atmega 2:
include <ServoTimer2.h>
include <Wire.h>

int count;
int servo1_val;

int escLR_val;
int escRR_val;
int escLF_val;
int escRF_val;

byte state;
byte new_data;

byte buff[11];

unsigned long int loop_count;

ServoTimer2 escLR, escRR, escLF, escRF, servo1, servo2;           //initialize ESCs
WS2812 LED(1);                                                    //one LED
cRGB value;

/*************************************************************************************************************************/

void setup() {

  Wire.begin(42);                                                 //joins the i2c bus as a slave with an adress of 42
  Wire.onReceive(event);                                          //sets up the handler that gets activated when there is data coming in

  Serial.begin(57600);

  escLR.attach(8);                                                //set ESC output to pin 8
  escRR.attach(7);                                                //set ESC output to pin 7
  escLF.attach(6);                                                //set ESC output to pin 6
  escRF.attach(5);                                                //set ESC output to pin 5
}

/*************************************************************************************************************************/

void loop() {

  if (new_data == 1) {                                            //start loop if there is new data

    escLR_val = buff[0] << 8 | buff[1];                           //get the two bytes to make a 16 bit integer
    escRR_val = buff[2] << 8 | buff[3];                           //get the two bytes to make a 16 bit integer
    escLF_val = buff[4] << 8 | buff[5];                           //get the two bytes to make a 16 bit integer
    escRF_val = buff[6] << 8 | buff[7];                           //get the two bytes to make a 16 bit integer
    servo1_val = buff[8] << 8 | buff[9];                          //get the two bytes to make a 16 bit integer
    state = buff[10];                                             //get the state byte

    escLR.write(escLR_val);                                       //write to all the ESCs
    escRR.write(escRR_val);
    escLF.write(escLF_val);
    escRF.write(escRF_val);

    new_data = 0;
    loop_count++;
  }
}

/*************************************************************************************************************************/

void event(int howMany) {                                         //handler that gets activated when there is data coming in
  byte count = 0;

  while (Wire.available()) {                                      //wait until all bytes are in

    buff[count] = Wire.read();
    count++;
  }

  new_data = 1;
}

Now here's the problem: because of the interrupt that is activated when there is data coming in, the signal for the servos and motor controller is really unstable and the servos jitter all the time. I know this because when I disable the interrupt, the servos and motors behave perfectly normal. Other forums have suggested to use the servoTimer2 library (which I do) but that didn't change a thing. Also the servos only turn 90 degrees instead of 180 but that could be because I'm running them on 250Hz instead of 50Hz. So if anyone knows how to write to the servos at 50Hz and the motor controllers at 250Hz please let me know.
So does anyone have suggestions? I'm happy with all suggestions so if I have to I will rearrange my entire code to solve this problem. I was thinking about using the using the mills() function, using requestFrom() or disabling interrupt for a while and even using hardware PWM. So maybe that brings you an idea. I'm really stuck here and I have to have it finished in less than a week so any help would be more than welcome!
by the way, english isn't my first language and am really bad at explaining things so if things are not clear I'll be happy to explain!

This seems like a fairly unwise design overall.  If your aircraft is large enough to use ESCs rather than pager motors hanging on tiny MOSFETs, it's probably unsafe to be flying with buggy Arduino code.  If your translator must use soft PWM (another bad idea), then it probably should use polled rather than interrupt based i2c receive.

At the very least, you must get rid of the while() loop in the ISR.

if I use polling, I'd have to use an interrupt on the other atmega right? So when you call the requestfrom() function the program on the first atmega must be interrupted to send the data to the second. Or is this not how polling works? I can't have an interrupt on the first atmega because there I am using another interrupt to read the PPM data.

The core problem is that servo control on an Arduino is done using timer interrupts and not hardware PWM. And of course your I2C reception is also using interrupts.
Since the Arduino only has one level of interrupts you can't interrupt an interrupt, so when you are receiving I2C data the interrupts for the servos cannot trigger and so they get confused with bad timing signals.
You can tackle it in one of three ways (that spring to mind):

Don't use interrupts for receiving your data
Use hardware PWM instead of timer interrupts for the servos
Use a more advanced microcontroller with multiple interrupt priority levels where the timer interrupt can interrupt the I2C interrupt.

thanks for your answer! I solved it now. I used the micros() function to time  the pulses manually. If you (or someone else) wants to see the code just send a message to nemobondt@gmail.com.

Here are two libraries the resolve the problem by using PWM.
https://learn.adafruit.com/neopixels-and-servos/the-ticoservo-library
https://github.com/dadul96/Arduino-Servo-Hardware-PWM-Library


text:
ESP8266 Wifi.setOutputPower - original/default value?
I'm working on dynamically adjusting the ESP8266 WiFi power using the following function, such that it's as low as possible, yet sufficiently reliable:
WiFi.setOutputPower(x)

I've been trying unsuccessfully to find out what the original/default value is before that function is called? There is no function WiFi.getOutputPower(). I know the range of values is 0 to 20.5, but I'm curious to know what it is initially? I guess it could depend on the particular Arduino? I have the following: ESPduino, Wemos D1R2/D1R1/D1R1 mini, NodeMCU, Yun sheild.
I plan to use iwconfig & iwlist on a Pi3 to measure the RSSI, but I'd like to know the baseline if possible.
The best similar idea is expressed in here: : How to optimise TX power for ESP8266?
Thanks in advance ;-)
Geoff

I was looking for the same answer. I found this link: https://gitlab.com/painlessMesh/painlessMesh/issues/51
Someone dug deeper into the code and found it's set to the max value on init


text:
Recommendation for a projector module or approach?
I am looking to create a projector effect similar to one seen in projector alarm clocks like
https://www.amazon.com/Mooas-White-Projection-Alarm-Projector/dp/B07Q6W53LK/ref=asc_df_B07Q6W53LK/?tag=hyprod-20&linkCode=df0&hvadid=343191208006&hvpos=&hvnetw=g&hvrand=4354131467724049360&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9019795&hvtargid=pla-758051396522&psc=1&tag=&ref=&adgrpid=68752454603&hvpone=&hvptwo=&hvadid=343191208006&hvpos=&hvnetw=g&hvrand=4354131467724049360&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9019795&hvtargid=pla-758051396522
and I am looking for some module that would accomplish it
https://www.mouser.com/ProductDetail/Texas-Instruments/DLPDLCR2000EVM?qs=BZBei1rCqCAQetmBz0G1xQ%3D%3D&gclid=Cj0KCQiA-rj9BRCAARIsANB_4ABW01iyq1W96Kd3piCLku3MSKib7xc_TspaZIa364hTXtJ_kYPSg0AaAvSAEALw_wcB
This is the closest thing I can find to what I am looking for but it's very pricey I would think given how popular these sorts of alarm clocks are there would be something much cheaper and easy to get your hands on out there.

This isn't an Arduino question. It would be a better fit in one of the electronics forums.

Retail consumer products have economies of scale working for them. A designer can spend the money to configure a factory to build a consumer product, and then spread that setup cost over millions of units. My guess is that the projected alarm clock you show is a bright LCD or LED display and a simple lens to project it's image. A general-purpose DLP projector like the one you linked is a much more sophisticated product.

These alarm clocks often only have a bright 7 segment LED display, which is then projected by a simple lens. Or maybe a simple custom LCD display, which is then backlight by a bright LED. The linked product from mouser is a complete DLP display with 640x320 pixels. Thats just different technology in a different league

Buy the alarm clock and scavenge the parts you need from it.

Except that I bet those alarm clocks have custom LCD displays that can only display the time, plus a few custom graphics, and nothing else. I very much doubt if they are general-purpose raster displays. If you find an alarm clock that has the display you want, great.

"These alarm clocks often only have a bright 7 segment LED display, which is then projected by a simple lens. Or maybe a simple custom LCD display, which is then backlight by a bright LED." Ok well can you link to parts or explain how I would go about doing that?

As written in the comments, the linked projector is a DLP  projector with 640x320 pixels. Of course, that is expensive. It is a complete pixel display, which can display anything (with the max resolution of 640x320). That is way more, than the projector watches.
The watches often use one of two possibilities:

A bright 7 segment LED display, which is projected to the wall via a lens. The seven segment display needs to be bright enough, depending on the intended brightness of the projection and how big the projected image should be.

An LCD display, which is illuminated from behind by a bright LED. That is then also projected to the wall with a lens. I would guess, that this is, what the linked watch is doing.

How to build that yourself? You can always salvage one of these watches. But when building it yourself, you should also follow one of the above possibilities. Which one depends on your requirements.
Using a standard 7 segment display will be the easiest. Though that might be not bright enough. You could look for especially bright 7 segment displays and test, if that is enough for you.
The second possibility would be more hacky. Most LCD displays, that you can buy, have a LED lit plane in the back as a backlight. You would need to remove that plane, so that the display gets transparent. Also you most likely would need to rotate the polarizing filter on the top of the LCD, because as standard a driven segment of the LCD gets more opaque, while you want it to get transparent. A new filter (up to a few cm) can be salvaged from the passive 3D glasses from a movie theater.
In both cases you install the display inside a tube together with a fitting lens. Look, what you can get from your location and then experiment with it.

can you link to parts

No, we are not really doing that here, because that is really dependent on your location, on your price- and other requirements. Also such part suggestions are usually very fast outdated. But you can look at the electronics shops, that you have at your location and search there for the general description of the parts (for example "7 segment display").

What material are you salvaging from 3d glasses? What sort of lense would I want? I was mostly asking about links to parts as a reference not necessarily a shopping list. I don't know how meaningful of a conversation we can have about this with talking about specific parts.

As reference: search at amazon for "7 segment display" and for "convex lens". I have no other reference for you. What I described is only an idea for the general concept. You still have to design the project itself. Google for unterstanding simple optics with lenses and decide based on that, what lens you need. Similar with the display. There you can also choose beween ready to use modules or the pure displays, which you then would need to drive with extra chips.

For the 3D glasses: I mean the cheap 3D glasses, that you get at the movie theater for 1 or 2€. The ones with just a thin foil instead of glas lenses. Like this one These are polarizing filters, which you can cut out of the frame. But you can also buy polarizing filters.

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


text:
Arduino tool to enumerate where RAM is being used?
In a sketch I have, I use a few libraries and have discovered that a large amount of RAM is being consumed.
Is there a tool that can identify how this RAM is being allocated, e.g. which libraries, which piece of code?

objdump (packaged with the compiler) can show you static allocations but dynamic allocations require running the code with extra instrumentation added to it or in an instrumented simulator, and even then is confined to the branches explored by the run.

How have you discovered this? How much RAM? One trick is to use the F() macro around strings that you are printing. Since you didn't post any code, it is hard to give better advice.

I use this code for Heap memory of AVR (UNO, Mega, etc.):
int freeRam()
{
     extern int __heap_start, *__brkval;
     int v;
     return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
}

To show heap memory just use Serial.print("Write here a name of the function from which you print it"); Serial.println(freeRam()); anywhere in the code.
Compiler shows stack memory but not the heap, so this code helps me to find exact place where my program uses too much of heap memory. I just print it in every suspicious place in my code.
I hope this will help.


text:
Why ModBus RTU Master-Slave Dont Work
I have two mega arduino and want to them communicate with modbus rtu together, i use below link circuit for this :
http://www.microcontroller-project.com/rs485-communication-between-arduino-mega-and-arduino-pro-mini.html
but dont work!! while they work in simple rs485 and without modbus with same above link code !?
my code in modbus mode is based on this forum :
https://forum.arduino.cc/index.php?topic=176142.0
MASTER CODE
    //#include <LiquidCrystal.h>

#include <SimpleModbusMaster.h>

/*
   The example will use packet1 to read a register from address 0 (the adc ch0 value)
   from the arduino slave (id=1). It will then use this value to adjust the brightness
   of an led on pin 9 using PWM.
   It will then use packet2 to write a register (its own adc ch0 value) to address 1
   on the arduino slave (id=1) adjusting the brightness of an led on pin 9 using PWM.
*/

//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 50

// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2

#define LED 9

// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 12

// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
  PACKET1,
  PACKET2,
  TOTAL_NO_OF_PACKETS // leave this last entry
};

// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];

// Masters register array
unsigned int regs[TOTAL_NO_OF_REGISTERS];
int In22=22;

// LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  Serial.begin(9600);
//  Serial1.begin(9600);
//Serial.begin(speed,9600);
// lcd.begin(16, 2);
  // Initialize each packet
  modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 5, 0);
//  modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);

  // Initialize the Modbus Finite State Machine
  modbus_configure(&Serial1, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);

  pinMode(LED, OUTPUT);
}

void loop()
{
  modbus_update();

//  regs[0] = analogRead(0); // update data to be written to arduino slave
//regs[1] =In22;
//  analogWrite(LED, regs[0]>>2); // constrain adc value from the arduino slave to 255
//  regs[1];
 if (Serial1.available()){
//regs[1]=In22;
//if(regs[1]==123){
    Serial.println(regs[0]);
    Serial.println(regs[1]);
    Serial.println(regs[2]);
    Serial.println(regs[2]);
//}
//  lcd.setCursor(6, 1);
//    lcd.print(regs[0]);
//lcd.print("hgftf");پ
 }
  delay(1000);
//lcd.clear();

}

SLAVE CODE
#include <SimpleModbusSlave.h>

/* This example code will receive the adc ch0 value from the arduino master.
   It will then use this value to adjust the brightness of the led on pin 9.
   The value received from the master will be stored in address 1 in its own
   address space namely holdingRegs[].

   In addition to this the slaves own adc ch0 value will be stored in
   address 0 in its own address space holdingRegs[] for the master to
   be read. The master will use this value to alter the brightness of its
   own led connected to pin 9.

   The modbus_update() method updates the holdingRegs register array and checks
   communication.

   Note:
   The Arduino serial ring buffer is 64 bytes or 32 registers.
   Most of the time you will connect the arduino to a master via serial
   using a MAX485 or similar.

   In a function 3 request the master will attempt to read from your
   slave and since 5 bytes is already used for ID, FUNCTION, NO OF BYTES
   and two BYTES CRC the master can only request 58 bytes or 29 registers.

   In a function 16 request the master will attempt to write to your
   slave and since a 9 bytes is already used for ID, FUNCTION, ADDRESS,
   NO OF REGISTERS, NO OF BYTES and two BYTES CRC the master can only write
   54 bytes or 27 registers.

   Using a USB to Serial converter the maximum bytes you can send is
   limited to its internal buffer which differs between manufactures.
*/

#define  LED 9

// Using the enum instruction allows for an easy method for adding and
// removing registers. Doing it this way saves you #defining the size
// of your slaves register array each time you want to add more registers
// and at a glimpse informs you of your slaves register layout.

//////////////// registers of your slave ///////////////////
enum
{
  // just add or remove registers and your good to go...
  // The first register starts at address 0
  ADC_VAL,
  PWM_VAL,
  HOLDING_REGS_SIZE // leave this one
  // total number of registers for function 3 and 16 share the same register array
  // i.e. the same address space
};

unsigned int holdingRegs[HOLDING_REGS_SIZE]; // function 3 and 16 register array
////////////////////////////////////////////////////////////

void setup()
{
  /* parameters(HardwareSerial* SerialPort,
                long baudrate,
        unsigned char byteFormat,
                unsigned char ID,
                unsigned char transmit enable pin,
                unsigned int holding registers size,
                unsigned int* holding register array)
  */

  /* Valid modbus byte formats are:
     SERIAL_8N2: 1 start bit, 8 data bits, 2 stop bits
     SERIAL_8E1: 1 start bit, 8 data bits, 1 Even parity bit, 1 stop bit
     SERIAL_8O1: 1 start bit, 8 data bits, 1 Odd parity bit, 1 stop bit

     You can obviously use SERIAL_8N1 but this does not adhere to the
     Modbus specifications. That said, I have tested the SERIAL_8N1 option
     on various commercial masters and slaves that were suppose to adhere
     to this specification and was always able to communicate... Go figure.

     These byte formats are already defined in the Arduino global name space.
  */

  modbus_configure(&Serial1, 9600, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs);

  // modbus_update_comms(baud, byteFormat, id) is not needed but allows for easy update of the
  // port variables and slave id dynamically in any function.
  modbus_update_comms(9600, SERIAL_8N2, 1);

  pinMode(LED, OUTPUT);
}

void loop()
{
  // modbus_update() is the only method used in loop(). It returns the total error
  // count since the slave started. You don't have to use it but it's useful
  // for fault finding by the modbus master.

  modbus_update();
//  holdingRegs[0] = 123; // update data to be read by the master to adjust the PWM
  holdingRegs[1] = 123; // update data to be read by the master to adjust the PWM
    holdingRegs[2] = 123;
//    holdingRegs[3] = 123;
//    holdingRegs[4] = 123;
  //  analogWrite(LED, holdingRegs[PWM_VAL]>>2); // constrain adc value from the arduino master to 255
  delay(1000);
  /* Note:
     The use of the enum instruction is not needed. You could set a maximum allowable
     size for holdinRegs[] by defining HOLDING_REGS_SIZE using a constant and then access
     holdingRegs[] by "Index" addressing.
     I.e.
     holdingRegs[0] = analogRead(A0);
     analogWrite(LED, holdingRegs[1]/4);
  */

}

I even didn't check the Modbus part of your code but the first think what I found:
You are using the D2 pin for LCD and at the same time as TXEnablePin...


text:
convert String to unsigned long long
i want to convert string for example
"68976543210" to unsigned long long(64 bit) in mega2560,
 do is possible?
String x="68976543210";
unsigned long long y=?;

avr-libc lacks strtoull() that I would normally use for such a conversion. You will have to do it manually.
Fortunately it's quite simple - just start with y=0 and, for each character in the string, multiply y by 10 then add the numeric value of the character in the string:
String x = "68976543210";
unsigned long long y = 0;

for (int i = 0; i < x.length(); i++) {
    char c = x.charAt(i);
   if (c < '0' || c > '9') break;
   y *= 10;
   y += (c - '0');
}

Note that the Arduino Print API has no method for printing a 64-bit integer.


text:
Simple memory chip for Arduino?
My basic question is: What is a good alternative to EEPROM chips for external memory on the Arduino Unor R3?
I know that there are EEPROM chips when one would like an external memory chip. It, in fact, seems like this is the standard choice. I am wondering if there are any other good ways to work with external memory. Are there, for example, memory chips that work a bis simpler? Like, a chip that doesn't require any specific libraries in the Arduino?
(I do not have extensive experience working with the Arduino.)

What is the problem with using a library? If you have some external memory, you have to communicate with this memory somehow. This already makes it "not simple". Note that you are not required to use a library. You could just write your own code that does the communication. But that would make it even less simple

@Gerben: No problem at all. I was just wondering.

There is no DRAM, SRAM nor flash interface in ATmega, so you can't extend your chip memory. You can only connect serial (SPI, I2C) or parallel memory (usind GPIO).
Neither SPI nor I2C require any specific libraries.
SPI is much simpler to program than I2C and much faster, but require more wires.
Instead of using rather slow EEPROM, you can try FRAM (non-volatile) or SRAM (volatile, but may be battery-sustained). They are usually available with the same interface as EEPROM, but don't suffer from limited number of erase cycles. FRAM can withstand ridiculous number of erasures, SRAM is virtually indestructible.

In what way is SPI easier to program than I2C?

No. There is no external memory interface on the ATmega328P, so all external memory requires some sort of library to use.

Personally I like the Amtel 24C256 chip/module. It is I2C enabled and the standard Wire library is all you need to talk to it. It is 256 bits or 32K 8 bit bytes in size. Data is sent and read in byte chunks. Addressing is at the bit level. It can run on 3.3V and 5V. Ebay has a bunch of suppliers for it. There's a number of good How-To's on line.


text:
what units do Mouse.move() use?
When I use Mouse.move() method (https://www.arduino.cc/en/Reference/MouseMove), what are units of xVal and yPos parameters?

They're raw HID counts and as such don't have a unit. It is up to the OS to translate them from logical amounts to physical values.


text:
How does Arduino decide when to go into flashing mode and normal mode?
Just this general question.As the titles says.
How does Arduino decide when to go into flashing mode and normal mode?
Is it by connecting certain pins to ground,so it's a hardware check or does it have to do with the code?
Other similar arduino like products such as the esp8266 work the same way as long as they use the same chip?

esp8266 chip is unrelated to anything arduino

It first runs the bootloader. If there is no data coming into the serial connection within a certain amount, i.e. it's not being programmed, it will exit the bootloader and start the actual sketch.
In the UNO you will notice a 3 second delay between providing power, and your sketch starting.


text:
ESP8266 Battery Monitor
Is there a way to monitor the battery that feeds an esp8266 in a portable project?
I have been meaning to implement that feature into my project so that i can be warned when the battery runs low on juice but i don't know if the esp has some kind of onboard sensor to do that.

All ESP8266 have ADC, just not all of them have them "broken out" - in the ESP8266 the ADC can be in one of two modes, one of which allows you to read VCC - so, no external hardware required ... that's the good news, the bad news ... how to set the ADC to read VCC depends on how you are programming the esp

There are two things you need to measure the battery of the system that is doing the measuring of the battery:

An analog-to-digital converter
Some form of fixed voltage reference to compare the battery voltage against.

Some ESP8266 modules have a single analog input available, and some don't. You need to check which module you have and which pins are available on it.
Then you need to use the ADC to measure the fixed known voltage. That could be from a small LDO voltage regulator that is below the voltage of the minimum voltage you will care about from your battery, or something like the forward voltage drop of a silicon diode (~0.7V) - something where you know what the voltage is.
From that reading you can then back-track what the supply voltage must be in order to give you the reading it has given you.  As the battery voltage drops the voltage range the ADC will be measuring will be reduced, and so the fixed voltage will rise within that range giving you higher readings from the ADC.
Here is a snippet of code I use with the 1.1V internal voltage reference of the ATMega328P to calculate the supply voltage:
long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1125300L / result; // Back-calculate AVcc in mV
  return result;
}

Of course, you need to change that to use the analog input of the ESP8266 instead (probably just using analogRead()). And of course change the ADC-scaled voltage.  The formula is basically:
Vref * ADCmax / ADCreading

So if you have the 1.1V reference as above, and the ADC can read 0-1023, then it's:
1.1 * 1023 / reading

Or, pre-calculate the first half of the sum:
1125.3 / reading

To keep it as integer mathematics work in millivolts instead of volts by multiplying the reference voltage by 1000:
1125300 / reading

And that, as you can see, is what is in the function above.


text:
Mass Storage with Arduino Uno and LUFA
guys ! I want to implement the mass storage example from the LUFA Library to my Arduino Uno, but I do not know where to start. Has anybody done this successfully and could give me a few pieces of advice ?

You start by taking the Uno and putting it aside, and picking up an AVR-based Arduino that has native USB device support such as a Leonardo or Esplora. You can then use the build scripts that come with LUFA to build the code for your device.


text:
Question about number of sensors for Arduino Mega
What is a good max number of sensors for an Arduino Mega? Since it has like -- 2? -- ground connections, is it better to keep the number of sensors to a minimum amount?

It depends on what you want the Arduino to do with them. There is no (not much) penalty for having many sensors connected. Where it begins to matter is when you need to read at rates which, collectively, tax the speed of the processor to meet the total demand. Your project specs will really determine how many sensors make sense. The other place that sensor count might matter is if your project is to be battery powered, and the sensors draw some amount of current even when they're not being used. In a battery powered project, you'll want to be able to power-down everything that isn't being used at a given time, to maximize the system's overall run-time on battery.
The Mega, and I'm assuming you mean Mega 2560, has 50-some odd I/O pins available, so you have a lot of potential connectivity, and I think it's safe to say, the designers intended for them to be used.


text:
What is the meaning of the preceding character on several library defines?
I have been reviewing the code for several libraries,mostly by SparkFun, and looking at the defines for for instance the chip select pins for their hardware.
In the defines, rather than being a simple number or string, they have the following syntax:
#define P_MOSI  B,3

with others being preceded by a D instead.
I am surmising this may be a data type definition, but I don't recognise the syntax and am wondering

What does the syntax mean?
What is the effect of nominating the data type of a define?
Is this Arduino specific syntax or general to C/C++?
If I want to modify a value, is it as simple as changing the value after the comma?

That completely depends on where it's actually being used.

I looked into one of these libraries, namely the SparkFun CAN-Bus
Arduino
Library.
The macro appears to be used inside other macros that require two
arguments, for example RESET(P_MOSI);. Given the following
definitions from the library:
#define RESET(x) _XRS(x)
#define _XRS(x,y) PORT(x) &= ~(1<<y)
#define PORT(x) _port2(x)
#define _port2(x) PORT ## x
#define P_MOSI B,3

the call RESET(P_MOSI); expands to
PORTB &= ~(1<<3);

PORTB is the name of an IO port of the MCU which controls the outputs
of the pins. It is actually a macro from
avr-libc that expands to something
like:
(*(volatile uint8_t *)(0x05 + 0x20))

where 0x05 is the IO port number of the register (the number depends
on the particular AVR chip) and 0x20 is an offset needed to get the
memory-mapped address from the IO port number. When the compiler does
constant folding, RESET(P_MOSI); resolves to
*(volatile uint8_t *)0x25 = 8;

which is then compiled into
cbi 0x05, 3

a single assembly instruction (Clear Bit in Io port) that executes in
two CPU cycles and sets to zero the bit 3 of IO port 0x05.
The same end result could be achieved in a much simpler way:
#define P_MOSI 11  // assuming digital 11 = PB3, as in the Uno
#define RESET(x) digitalWrite(x, LOW)

However, the function digitalWrite() is very slow, mostly because it
has to map an Arduino pin number to a port address and a bit number, and
it does it at run time. The SparkFun approach, though somewhat
convoluted, is way more efficient, because the mappings are performed
at compile time.

While we can't see how the macro is being used, it may be worth noting that, on Uno's built-in SPI interface, the MOSI signal is on port-B, bit 3.
Update:

the architecture is broken down into ports and pins.

The AVR processors use memory-mapped, byte-wide I/O ports, where each bit mapped to a physical pin (actually to a multi-function pin-driver/receiver). The Arduino programming environment defines symbols such as PORTB to be the addresses of those ports. It further defines single-pin I/O functions (digitalRead(), digitalWrite() ) that "know" the mapping of pin numbers to ports and bits as implemented in each processor. Most people rely on the single-pin functions but the ability read and write the ports directly is there if you need it. And note that the Arduino pin numbers do not match the physical pin numbers of the pins at the exterior of the chip, but it does match the numbers silk-screened on the PCB. While this relieves you from having to deal with that mapping, it makes those low level details somewhat less visible.

Here's some interesting information, that the architecture is broken down into ports and pins. Perhaps now I need to find the translation between pin/port numbering and the board's own printed numbering.

As in found here: https://www.arduino.cc/en/Hacking/PinMapping2560. This seems to be a step forward..!

#define P_MOSI  B,3

This is a C style macro definition. During the pre-processor phase of compilation where ever the text P_MOSI is encountered it will be replaced with the text B,3.
This is a purely textual replacement with no understanding of the semantic meaning of what is being replaced.  So the validity of the macro will depend on where it is being used.
I am not familiar with how this macro is being used in the library code you are looking at, but from what I have seen from a quick google this macro is used to define things on a per-chip architecture basis.  EG for an ATmega16 it is
#define P_MOSI  B,5

But for a AT90USB82 it is
#define P_MOSI  B,2

So if you are trying to adapt a library to your processor you will need to change the macro to suit your architecture.
In general such defines are used to adapt the same code across multiple architectures.  For instance here is a snippet of something I found when googling
#if (BUILD_FOR_MCP2515 == 1)
    #if defined(__AVR_ATmega16__) || defined(__AVR_ATmega32__) || defined(__AVR_ATmega644__)
        #define P_MOSI  B,5
        #define P_MISO  B,6
        #define P_SCK   B,7
        #define SUPPORT_FOR_MCP2515__
    #elif defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__)
        #define P_MOSI  B,2
        #define P_MISO  B,3
        #define P_SCK   B,1
        #define SUPPORT_FOR_MCP2515__

That is what I thought as well, in which case it must be arguments to a function, elements in a list/array, have another define for the B and D symbols. If that's the case then that's kind of complicated. It seems to be nonstandard if you've never seen it before.

@JCollins: Most things after #define should be considered non-standard.

@JCollins I have a bucket load of experience with C/C++ but virtually zero with Arduino.  In fact I only wrote my first Arduino program yesterday.

The is exactly what I am looking to do, connect a piece of SparkFun hardware to a MEGA 2560. I have made what I think are the necessary changes, but the unit still does not communicate, leading to the question.


text:
What would be the best way to sniff an established serial connection?
I am studying a system running a serial connection and looking not to intercept its packets, but merely to inspect the traffic as it passes.
Option 1
Hook the RX and TX wires to the RX of two serial channels on my Arduino. Read the messages sent in either direction separately. Don't know the baud rate so this might be experimental?
Option 2
Split the connection, absorb both sides of the break into a RX TX serial connection on the Arduino, and set up forwarding from each to the other while inspecting the content.
In either option I can see the need to inspect the connected wires and establish the highest observed baud rate to match to. In the second option until I inspect enough data to reliably get the baud rate, data will be lost unless it is buffered.
Has anyone got any experience with a situation like this?

Use a logic analyser so you can find the baud rate visually. They can also decode the raw data into values, and some even know about common protocols already.

option 1 is preferred ... option 2 makes an assumption that voltage levels are not important to the exchange of data .... you could have a system that sends bogus serial data and uses voltage levels to transmit the true data covertly

I would suggest spending more time studying it and updating the information you presented. There are thousands of serial communications formats and most have both a transmit and receive connection. Is it a sync or async format. Could it be I2C or SPI? Maybe it's VPWM, you will need to know before you can spi on the data going to and fro. Once you have this you can use a few Op Amps and resistors as a high impedance connection so you do not damage the data stream.

Keep in mind even if it is RS232-like asynchronous serial protocol you don't need to know the baud rate beforehand. You can write an algorithm to measure and detect the baud rate of traffic passing by. This is what "autobaud" means for higher level systems which support it. They have just written algorithms to figure out the baud rate by listening to traffic for a moment first.

FYI I highly recommend Saleae logic analyzers. Several hundred $$ but worth it. https://www.saleae.com/. For an oscilloscope, go Rigol.

There are also lots of logic analysers, that only cost like 10$. Surely they are not as capable as the top tier ones, but that most likely will be enough.


text:
Do interrupts block other interrupts?
If I have an interrupt attached to two pins and the handler of the first is still executing when the second interrupt fires, does it:
a) queue the second interrupt,
b) ignore the second interrupt (missing it altogether), or
c) pause processing of the first interrupt to execute the second?
I am writing code that logs the exact time the interrupt occurs. Quite lightweight, but have three pins and am logging the rise and fall of each, so there is the potential for collisions. If a) then the second interrupt timestamp will be late, b) there is no timestamp for the later interrupt or c) the timing of the first and second interrupts will be ambiguous.
b) is the worst case, the other two are manageable.

By default the compiler disables interrupts at the start of the ISR and re-enables them at the end. You can disable this, and enable interrupts inside other interrupts by adding the ISR_NOBLOCK attribute to your ISR. But you have to know what you are doing.

It sound like Timer Input Capture Mode might be useful for your specific problem.

Gerben expand on this. I've been working hard to get up to speed on interrupts, and have got as far as external interrupts on pins and internal interrupts. You might be suggesting something better for the task

Depending on your board it might not be possible to use Timer Input Capture Mode for your pins. With that mode you can let a hardware Timer capture the duration of a pulse (not its timestamp at the general timelime). But you would need one hardware Timer per pin. Most boards don't have that much timer left, especially, if you still want to use functions like delay(), millis() or micros(), which need Timer0 to be configured for them. Maybe a simple pin change interrupt would be the easiest. Though that depends on your timing requirements ( how accurate should the recorded timestamp be?)

@Gerben: On AVR, interrupts are disabled at the start of the ISR not by the compiler, but by the hardware. The ISR_NOBLOCK attribute is a way to ask the compiler to re-enable interrupts as early as possible within the ISR.

It depends on the architecture.
Assuming AVR (8-bit Arduino) then it will queue the second interrupt until the first is finished.
It works by setting a flag in a register at the moment the interrupt occurs. Then between instructions it checks that flag and executes the associated interrupt routine. If an interrupt is in progress at the time the flag still gets set, but it is unable to check the state of that flag until after the current interrupt is over and normal execution occurs, at which point after the next instruction is completed it checks the interrupt flag statuses and runs the second interrupt routine.

It depends on the specific MCU, not all are exactly the same.
Some have interrupt priority circuitry that you can use.  But in general, an ISR can be interrupted by another incoming IRQ, etc.  What you often do in an ISR is mask IRQ, handle the IRQ, and then unmask to let any pending IRQs be handled.
This is one reason why long-running ISRs should be avoided!


text:
Power motor with Uno
I am trying to power a small peristaltic pump using an UNO R3. I have it powered using usb, and I tried running the blink program to see if I could power it using digital write, and extended the delay to troubleshoot voltages using a multimeter. The motor doesn't do anything connected to the digital pins even when the digital write is set to high. If I connect the motor to the 5 V power pin the motor turns on so I know 5 V is enough voltage. I've looked at tutorials for DC motors and they explain how to set it up with motor reversing using components I don't have, and I don't need it to reverse. How can I get the motor to turn for a specific length of time?

Most likely the motor you are trying to drive requires much higher current than what the UNO can provide through its digital outputs.
Check out this summary to find out detailed specs for the I/O ports.
What you could do is to draw power from the 5V line provided by the Arduino. If that can drive your motor, then use the line to power an output stage, driven by the digital I/O. See this example.
In general, the idea is that the digital I/O provides the control logic, while the output stage provides the power required by the specific load.
The typical loads that can be driven directly by GPIOs are low power LEDs.
Anything that involves moving parts is generally out of reach, power-wise.

Thank you for your reply, I managed to get it working using your information coupled with a tutorial from youtube found here: https://www.youtube.com/watch?v=sOz41WQF7wE . Instead of a mosfet I used an NPN transistor, but ran too much current and blew up the motor, oops. Next time I'll use use your 5v suggestion since it is indeed able to be run well on that voltage. Thanks again!

Driving motors in a safe way is a problem on its own. Especially if you want to implement more sophisticated control, like variable speed and/or direction. During some transients the motor can start acting like a generator and pump current back into your driving stage, which might result in damage of either of both of them.


text:
Arduino original motor shield can not supply enough torque to the motor?
I am using original Arduino motor shield L298P with Arduino uno.
I disassembled an electric screw driver which came out with a 4.8 v battery pack and a 4.8v specified DC motor.
I connected battery pack to the Vin and Ground pins of the motor shield, and connected the DC motor to A channel of the shield.
The thing is when I run a test code with PWM 255, the torque of the motor is way too low compared to connecting the motor directly to the battery pack. I also changed the batteries to a common 1.2v rechargeable 4 batteries connected in parallel. The result is the same.
What might be going wrong?
I also paste the code I am using below. Thanks in advance.
const int motorPin = 3;
int Speed;
int flag;
void setup()
{
pinMode(motorPin, OUTPUT); //Set pin 3 as an OUTPUT
Serial.begin(9600); //Init serial communication
//Print a message:
Serial.println("Give a number from 50 to 255."); //Why minimun value 50?     Because with values below 50 the motor doesn't spin ;)
Serial.println(""); //Blank line
}

void loop()
{
//Check if incoming data is available:
if (Serial.available() > 0)
{
  // If it is, we'll use parseInt() to pull out only numbers:
  Speed = Serial.parseInt();
  flag=0;
}

//Valid range is from 50 to 255
if (Speed>=50 && Speed<=255){
    //Send PWM value with analogWrite to Arduino pin 3 and print a message to serial monitor
    analogWrite(motorPin, Speed);
    //Print message only once
    if (flag==0){
        //Print PWM value
        Serial.print("Motor spinning with ");
        Serial.print(Speed);
        Serial.println(" PWM");
        flag=1;
    }
}

delay(1000);
}

This is not at all surprising - screwdrivers made to run off of low voltages have to draw very high currents under load.  A L298 has both limited current handling, and uses bipolar transistors which when you count both elements active in a bridge add up to a substantial voltage drop inside the chip.  You can try adding a 5th cell but the current limit remains.  If you don't need reversing you can consider a single logic-level NFET with good performance.  If you do need reversing, you can "pick any two" of performance, simplicity, or low cost.

According to the motor shield page:

To avoid possible damage to the Arduino board on which the shield is mounted, we reccomend using an external power supply that provides a voltage between 7 and 12V. If your motor require more than 9V we recommend that you separate the power lines of the shield and the Arduino board on which the shield is mounted. This is possible by cutting the "Vin Connect" jumper placed on the back side of the shield. The absolute limit for the Vin at the screw terminals is 18V.

According to you:

I disassembled an electric screw driver which came out with a 4.8 v battery pack and a 4.8v specified DC motor.
I connected battery pack to the Vin and Ground pins of the motor shield, and connected the DC motor to A channel of the shield.

That's a lot less than 7V.

Also, from the motor shield page:

Max current   2A per channel or 4A max (with external power supply)

How much current does your screwdriver use?

From the Arduino playground:
Arduino: What Adapter?
by djmatic
Ever since the dawn of Arduino, one question has been asked over and over again: "what kind of DC adapter can I use to power my Arduino?"
The short answer is: 9 to 12V DC, 250mA or more, 2.1mm plug, centre pin positive.
The long answer is that an off-the shelf Arduino adapter:
must be a DC adapter (i.e. it has to put out DC, not AC);
should be between 9V and 12V DC (see note below);
must be rated for a minimum of 250mA current output, although you will likely want something more like 500mA or 1A output, as it gives you the current necessary to power a servo or twenty LEDs if you want to.
must have a 2.1mm power plug on the Arduino end, and
the plug must be "centre positive", that is, the middle pin of the plug has to be the + connection.
These important details are often contained right on the adapter.
Current rating: Since you'll probably be connecting other things to the Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have enough juice to make each component of the circuit function reliably.
One final note. The Arduino's on-board regulator can actually handle up to 20V or more, so you can actually use an adapter that puts out 20V DC. The reasons you don't want to do that are twofold: you'll lose most of that voltage in heat, which is terribly inefficient. Secondly, the nice 9V pin on the Arduino board will actually be putting out 20V or so, which could lead to potential disaster when you connect something expensive to what you thought was the 9V pin. Our advice is to stick with the 9V or 12V DC adapter.
Electronicalifragilistic: I use a power supply from an old HP laptop that I scrapped. The plug is center positive and puts out 12V. Fits perfectly into Arduino connector. Packs a Wallop - most laptops draw 2-2.5 amps. That ought to run your screwdriver.

Don't just copy text from somewhere else, especially when the recommendations it makes are unsuited to the question at hand.  The actual issues here have been explained already, and many times previously both here and at EESE.


text:
Arduino UNO, using 5V and 3.3V
I am newbie in Arduino (using UNO) and as I have 2 components that I wish to connected that one needs 5V and the other need the 3.3V, is it safe to connected them together next to each other?

In general, yes: you would just connect the 5v component to the Arduino's 5v output pin, and the 3.3v component to the Arduino's 3.3v output pin. They should share the same ground connection. Just make sure not to give the 3.3v component 5v power.

You may put a potentiometer to change and organize the voltage, if you need.

If a component needs 5V it must be connected to 5V. If it needs 3.3V it must be connected to 3.3V.  Connecting a 3.3V component to a 5V supply is a sure fire way of destroying it.
Furthermore, since the Arduino's main chip is a 5V device, if you want to connect it to a 3.3V device you must use some form of level translation so that the 5V signals from the Arduino don't damage the 3.3V device. Also it may (though not always) be necessary to convert the signals from the 3.3V device to a level that the Arduino can understand (5V).

"sure fire way" - pun intended?


text:
Tile NeoPixel NeoMatrix 8x8
As a programmer I am new and lack some knowledge in electronic and I will appreciate the help.
I wish to connect 3 Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix (https://www.adafruit.com/products/1487) can some one please provide me a scheme how to connect/tile 3 these NeoMatrix 8x8 to one Arduino Uno.
Thanks a lot

To add to both existing answers.  Memory ends up being your problem because each pixel needs 3 bytes for it's color value.  I would highly recommend that you read all of adafruits info for that product AND their uber guide, When you're finished you will understand (I did anyway).  One more thing adafruit site has conflicting info, they DO now have libraries for this type of LED (WS2811/ws2812) for the rasperberry pi, the info in Russell McMahon's answer is out of date, but it's because so is adafruit's page--elsewhere adfruit does have libraries for the pi

On the page that you cite they say
If, say, you need MORE blinky, you can chain these together.

For the second shield, connect the DIN connection to the first panel's DOUT.
Also connect a ground pin together
and power with 5V.
There you go!

You can chain as many as you'd like although after 4 or more panels you may run low on RAM if you're using an UNO. Watch your power usage too, you may need a 5V 10A power supply for so many of these!

Related:
They also say:

There is a single data line with a very timing-specific protocol. Since the protocol is very sensitive to timing, it requires a real-time microconroller such as an AVR, Arduino, PIC, mbed, etc. It cannot be used with a Linux-based microcomputer or interpreted microcontroller such as the netduino or Basic Stamp.
Our wonderfully-written Neopixel library for Arduino supports these pixels! As it requires hand-tuned assembly it is only for AVR cores but others may have ported this chip driver code so please google around.
An 8MHz or faster processor is required.

Hi, Thanks. Could you please provide me a scheme of how to connect them.

On the products page, they link to the Neopixel Uberguide, which should really contain what you need :-)
The good thing about the NeoPixels is that they can be chained, since each pixel is supplied with VCC, GND, Data in and Data out. Data out of LED1 will be data in for LED2, and afaik you can make infinitely long chains this way

I found the http://fastled.io/ libary to be a useful and well documented (https://github.com/FastLED/FastLED/wiki/Overview) alternative to Adafruit's NeoPixel library.
FastLED has some clever compression of palettes, and many other nice features that might save you valuable memory when using many neopixels.


text:
Adding Date and Time to existing sketch
I am currently trying to add a clock functionality to my current sketch for a peristaltic pump [run by NEMA 23].
The current sketch waits for a button on my breadboard to be pressed, it then runs the motor for a specified amount of steps and then stops and waits for the next press of the button. It also displays the amount of steps to the Serial Monitor. I have a working sketch for a clock using an RTC DS3231 module and have unsuccessfuly attempted to fit it into my motor sketch. The problem is, the clock seems to be taking precedent over the rest of my sketch, so pressing the button no longer works and the time is simply consistently output onto the Serial Monitor.
The ideal functionality would be the time and date displayed on LCD constantly (or at least blinking so rapidly that one could not tell the difference) with the number of button presses displayed under it, changing in value only when a button is pressed.
Attatched find my code, it is really quite simple, and thank you so much for the time and help.
#include <Bounce2.h>
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <AccelStepper.h>
#include <MultiStepper.h>
#include <Wire.h>       //I2C Library
#include <OneWire.h>
#define DS3231_I2C_ADDRESS 0x68

AccelStepper stepper(1, 9, 8); // initiate stepper motor

LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

int pos = 0; // variable to store position
int buttonPresses = 0;

const byte ButtonPin = 10;
const byte LedPin = 13; // for debugging and visualization

unsigned long ledOnTimer = 0;

const unsigned int ledPeriod = 3000;

Bounce button;

void setup() {
  Wire.begin();
  Serial.begin(9600);
  lcd.begin(16, 2);
  button.attach(ButtonPin);
  pinMode(LedPin, OUTPUT);
  stepper.setMaxSpeed(4000);
  stepper.setSpeed(2000);
  stepper.setCurrentPosition(0);
}

byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val / 16 * 10) + (val % 16) );
}

void loop() {
  motor();
  printDate();
}

void motor() { // functioning motor sketch by itself

  //if led is on
  if (digitalRead(LedPin)) {
    stepper.runToNewPosition(21000); //about 420 steps per 10 mL
    digitalWrite(LedPin, LOW);
    // }
  }

  //if led is off
  else {
    button.update();
    if (button.fell()) { // if the button "fell" from a value from HIGH to LOW (so now it is off)
      stepper.setCurrentPosition(0);
      digitalWrite(LedPin, HIGH);
      buttonPresses++; // count presses of button and print to monitor
      lcd.clear();
      Serial.print("Number of Button ");
      lcd.setCursor(0, 1);
      Serial.print("Presses = ");
      Serial.println(buttonPresses);
    }
  }
}

void printDate() { //functioning time sketch by itself

  // Reset the register pointer
  Wire.beginTransmission(DS3231_I2C_ADDRESS);

  byte zero = 0x00;
  Wire.write(zero);
  Wire.endTransmission();

  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);

  int second = bcdToDec(Wire.read());
  int minute = bcdToDec(Wire.read());
  int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  int monthDay = bcdToDec(Wire.read());
  int month = bcdToDec(Wire.read());
  int year = bcdToDec(Wire.read());

  //  print the date EG   3/1/11 23:59:59
  Serial.print(month);
  Serial.print("/");
  Serial.print(monthDay);
  Serial.print("/");
  Serial.print(year);
  Serial.print(" ");
  Serial.print(hour);
  Serial.print(":");
  Serial.print(minute);
  Serial.print(":");
  Serial.println(second);
}

Last note: Everything compiles, and I will change "Serial" to "lcd" after I finish debugging the sketch, so that is why everything is currently beign sent to the Serial Monitor.

Even if you want to display time with the seconds showing, you don't need to check the time on the RTC continiously. Once a second should be enough. You can use a timer interrupt that triggers an ISR(Interrupt Service Routine) every second to do that check for you. This will free a lot of time which your arduino can use to do other stuff.
Same goes for your button(s): you can use an External Interrupt (INT) or a Pin Change Interrupt (PCINT) for them. This way the arduino will only look at them when they are pushed (and/or released).
If you combine those two interrupts (for the clock and the button), your arduino will have a lot of spare time. This is especially handy if you later want to expand your project with more buttons and motors.

Thank you, I am not entirely sure how to do any of this but I will work on it for a few hours and let you know if I am able to figure it out.

Here is some info about timer interrupts: http://www.instructables.com/id/Arduino-Timer-Interrupts/ and about INT and PCINT http://www.geertlangereis.nl/Electronics/Pin_Change_Interrupts/PinChange_en.html

Appreciate it I will read these both!

I think you need to look at using interrupts.
The printDate function is quite processor intensive with all the Wire and Serial.print calls, it will be taking the majority of the time in each loop().
Whilst in printDate it won't be looking at the state of the button, so you have to press at just the right time.
If you place an interrupt on the button's pin I think you will get a more responsive system.  Another thing that you could look at it only reading the clock once a second, this could be done with a timer interrupt.

Attaching interrupt (PIN change or LEVEL change) to the push button would work fine. You can trigger a flag and the flag should access the controller to run motor() function.


text:
Can't make my stepper motor run clockwise and counterclockwise with AccelStepper Library
I'm relatively new to arduino thus need your help to figure out why my stepper motor doesn't rotate clockwise and counterclockwise. All I could do was to make it rotate only in one direction.
Here is my code:
#include <AccelStepper.h>

int pos=16000;
AccelStepper stepper(1,4,5);

void setup() {
stepper.moveTo(pos);
stepper.setMaxSpeed(6400);
stepper.setSpeed(6400);
}

void loop() {
if (stepper.distanceToGo() == 0)
{
  stepper.setCurrentPosition(0);
  pos = -pos;
  stepper.moveTo(pos);
  stepper.setSpeed(6400);
}
   stepper.runSpeed();
}

Will appreciate any help you can give me :)

Actually after trying different options, I could finally find a solution that seems to work for me:
if (stepper.distanceToGo() == 0 && stepper.currentPosition()==50000) {
    delay(1000);
    stepper.setCurrentPosition(0);
    stepper.moveTo(-50000);
    stepper.setSpeed(10000);
    stepper.runSpeedToPosition();
  }
  else if (stepper.distanceToGo() == 0 && stepper.currentPosition()==-50000) {
    delay(1000);
    stepper.setCurrentPosition(0);
    stepper.moveTo(50000);
    stepper.setSpeed(10000);
    stepper.runSpeedToPosition();
  }
  stepper.runSpeed();

Just out of interest, you are still using a speed which is an order of magnitude greater than 1000, which as jwpat points out is unreliable. What happened when you used speeds of <1000? Did it not work?

Yes, I'm still using high speeds, but I guess it works for me because my stepper motor is configured on a micro step. If I put a speed lower than 1000 it also works, but very slowly

The  “Performance” paragraph of the “Detailed Description” section of AccelStepper documentation says:

The fastest motor speed that can be reliably supported is about 4000 steps per second at a clock frequency of 16 MHz on Arduino such as Uno etc. ...

and the AccelStepper::setSpeed () documentation says:

... Speeds of more than 1000 steps per second are unreliable

Try changing your 6400-steps-per-second setting to a some plausible number, eg 500 or 1000.
Actually, it would make sense to start out with moderate destination settings and speeds, like a target position of 200 instead of 16000, and steps-per-second of 100, or whatever count it takes for say exactly two shaft revolutions.  Once you have that working right, then start doubling numbers until it no longer works, after which you can back off by a factor of say four (to allow for variations in load, etc).

Thxs, I'll try to lower a speed


text:
Arduino Wireless SD Shield
Is it possible to use the Wireless SD shield without the wireless function, or XBEE Module? I do not need it to be wireless it simply was cheaper than any other I could find, so I was wondering if it was possible to use it just like a normal, non-wireless SD Shield? Thanks!

In general, on a combined "Something plus SD card" shield like this the SD card is a completely separate section to the rest of it. The only real exception is on some audio shields (mp3) where the SD card is directly controlled by the audio CODEC chip.
So yes, you can pick and choose which portions of the shield you actually use in your code. Just by not using the bits you don't want to use.