text:
Two arduinos one power source
I was surprised that this question had no answer on Stack Exchange and I can't find much about it elsewhere so, in the hopes that it will be useful to people other than myself, I'd like to ask:
How can one power two arduinos using the same power source? Such that the first is connected by barrel jack to a 12v transformer.
I saw this youtube video which very briefly mentions doing this by make the connections:

Ardu1 --> Ardu2
5V --> 5V
GND --> GND

This surprised me as I was not aware the 5V could operate as a power input. I was expecting the use of the VIN pin somewhere along the line.
Am I correct in thinking that the second arduino would take power on it's VIN pin from 5V on arduino one?
If so, where should the second arduino ground to?

Where did you read that putting 5V on VIN is acceptable?

Nowhere, my only knowledge of VIN is that it can be used as a power source. Please explain your enthusiastic objection.

"The board can operate on an external supply from 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply less than five volts and the board may become unstable."

Thank you for that link Ignacio Vazquez-Abrams. It has helped me, discover the solution:
"Vin. The input voltage to the Uno board when it's using an external power source (as opposed to 5 volts from the USB connection or other regulated power source). You can supply voltage through this pin, or, if supplying voltage via the power jack, access it through this pin."
So I have connected arduino 1 VIN --> VIN arduino 2, and arduino 1 GND --> GND arduino 2. And I have power!
Reluctant as I am to destroy my boards, I have not tried the example from the video. Props to anyone who can explain it.

The explanation is that supply pins are neither inputs nor outputs, merely supply lines with a maximum load.

I have powered numerous arduino's via the 5V pin. I would however call this an advanced usage because there are some limitation/dangers.
First of all: Power your arduino via 5V and plugin a powered USB cable or a powered plug and it may (probably will) damage your USB or arduino or both.
Secondly; it is best to assume that all arduino's are different on behalf of the behaviour of the +5V pin. I know for a fact there is a difference with uno,yun,due.
thirdly: The way it is used on the video -you linked to- (power jack 5V arduino 1 to 5V arduino 2 and ground arduino 1 to ground arduino 2) makes that all power goes through the voltage converter on the Arduino 1.
These voltage converters can not handle much current. This is only sufficient in very low power drawing applications.
It s not a good idea to connect the 5V pin of arduino 1 to Vin of the arduino 2. This because the voltage converter on arduino 2 will not be able to provide 5V to The 5V cirquitry.
It is mutch smarter to connect the Vin from arduino 1 to Vin of Arduino2.
When I power arduino's from "standard batteries" I use a switching power supply that powers the arduino over a cut in halve USB cable. This way it is lots safer as I can add power over the jack and I can not plugin a second USB cable.

Thanks, I don't have a high load but I have gone with VIN to VIN. There seems to be no advantage in using 5V over VIN. And more current and protection with VIN to VIN.

You could put the 12v from the barrel jack on both Arduninos Vin pins by jumpering the Vin pins together instead of the Vin->+5 or +5->+5.  Then they'd have independent protection and regulation of 1A, 5V through their NCP1117ST50T3G chips.

Connecting the +5V pins together is acceptable providing you don't exceed the total load that the source of the +5V can provide. This would be either:

The maximum the USB interface can provide:
Bus 003 Device 013: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)
Device Descriptor:
...
  bDeviceClass            2 Communications
...
  idVendor           0x2341 Arduino SA
  idProduct          0x0043 Uno R3 (CDC ACM)
...
  Configuration Descriptor:
...
    MaxPower              100mA

That would seem to be 100 mA from doing lsusb -v on my Ubuntu system.
The maximum that the voltage regulator can provide (if you are using the power jack, or Vin). This would depend on the model of Arduino, plus what your input voltage is (the higher the input voltage, the hotter the voltage regulator will get).

When I am testing things like sending I2C from one Arduino to another, I will often connect the USB to one of them, and just connect together the +5V pins (and ground of course) so that the second Arduino gets powered.

Caveat : my page about power indicates that without using sleep modes and other techniques, a Uno may consume 50 mA on its own. Thus connecting two Unos is likely to be reaching the limit that the USB interface can provide. Connecting three or more is likely to be problematic.

Regarding the USB power issue, see How to get more than 100mA from a USB port. On that page it says:

USB-100mA
USB by default will deliver 100mA of current (it is 500mW power because we know it is 5v, right?) to a device. This is the most you can pull from a USB hub that does not have its own power supply, as they never offer more than 4 ports and keep a greedy 100mA for themselves.
...
Near the end of enumeration you setup device parameters. Very specifically the configuration descriptors. If you look on this website they will show you all of the different pieces that can be set. It shows that you can get right up to 500mA of power requested.

As the negotiation in this case appears to be requesting 100 mA (and not 500 mA) the port on the PC may well limit you to that.

Good answer (+1), but as per USB specification, maximum current a USB 1.1/2.0 port can provide is 500 mA.

See expanded answer.

nice extension :-)

Yeah, thanks. Loads of information. And your page on power and sleep modes is excellent reading. Bookmarked!

This surprised me as I was not aware the 5V could operate as a power input. I was expecting the use of the VIN pin somewhere along the line.

Power is just power. It doesn't have a "direction" like an IO pin. It just flows from a point of higher potential to a point of lower potential. If you put a load onto the 5V pin then the power will flow out of the 5V pin, through the load, to the lower GROUND potential. And that is all the other Arduino is - a load. The power flows out of the 5V, into the other Arduino, through it, and down to the lower GROUND potential.
It's just like a rechargeable battery. Put a light on the battery and the electricity flows out of the battery to light the lamp. Apply a higher voltage to the battery from another supply and the power flows out of the supply into the battery, recharging it (or making it explode if the voltage is too high).

Thank you, this is a very clear explaination. So polarity is not an issue when powering the arduino?

Polarity is a different thing altogether. Reversing the polarity would involve connecting 5v of one to gnd of the other and vice versa. That would result in the death of one arduino.


text:
Hall effect sensor direction detection using arduino
I'm using a hall effect sensor A1356 (linear application) to measure the amount of fluid in a container. The fluid is in constant use. My doubt is I'm placing the sensor and the magnet assembly in place, such that when it is exactly half filled, the magnet's center will align with the center of the sensor. In this condition I get 100% duty cycle output from the sensor.
Condition 1: If the fluid is filled then the magnet moves above the sensor and the duty cycle reduces say to 90%.
Condition 2: If the fluid is consumed then the magnet will move below the sensor and the duty cycle reduces to say 90%.
How do I differentiate between the rise and fall of the fluid? Or is there a better way of orienting the magnet and the sensor such that this problem could be avoided?
I'm interfacing it with an Arduino UNO

Two sensors? If the lower one activates then the level is low (and if it deactivates it is lower still). If the higher one activates then the level is high (and if it deactivates it is higher still). If both activate then the level is about right.

its is a one way of doing it but i am supposed to use only one sensor to reduce the cost

Do you have a bipolar or unipolar device? If it's bipolar, and you position both the sensor and magnet correctly, you can see if it's above or below.

According to the data sheet (see below) the no-field PWM output is mid-range; north poles reduce it & south increase.
So if you had an arrangement whereby the float had north down & south up, ie a vertical bar-magnet, this would presumably give a rise-before-0 or fall-before-0 at the float vanishes, or a fall-to-minimum an rise-to-maximum as the float centres? The bit in the middle could be interesting!
From the datasheet:
"The presence of a south polarity magnetic field,
perpendicular to the branded surface of the package face,
increases the output duty cycle from its quiescent value toward
the maximum duty cycle limit. The amount of the output duty
cycle increase is proportional to the magnitude of the magnetic
field applied. Conversely, the application of a north polarity
field decreases the output duty cycle from its quiescent value."

source: Stack Exchange

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

sort: votes


text:
Motor Shield not giving full power, LED DIMS
I have an Adafruit Motor Shield, the V1. I have been using this thing with my OPSEPP Uno and a stepper motor with no issues. (Powered by 12v DC wall wart [CASIO]).
My question, or issue, not sure yet, is this:
Why when I connect my motor directly to the 12v power supply it operates efficiently (for my purposes) and when I run it through my Arduino with the Adafruit Motor.h library does it not power the same.
Basically on direct connection it works fine, but I want to be able to regulate the connection and reverse it, change the speed, etc.
It is possible I am utilizing the library or the board wrong.
Can someone indicate why the power or, torque seems to drop when through the board. I have tried all KHZ all speeds etc, no way to get the same 12v power directly and modulate it?

According to the Adafruit page the V1 version of the shield is not as powerful as their V2 version.
Where is the 12V coming from to get to the shield? There isn't really 12V broken out on the Uno anywhere. If it comes from Vin then there is a 0.7V drop through the reverse polarity protection diode. Plus, the tracks on the Arduino board may not be thick enough to provide enough current.
It looks like the shield may take an external power source (it is hard to tell because they discontinued it). You could try using that.

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


text:
Is replacing USB serial WITH ESP8266+ESP link feasible?
ESP8266 (01-512k,) Arduino Uno (clone), Arduino IDE, Python 2.7.6 on Macbook pro running OSX 10.10.4 64-bit.
Hello!
I'm using a motion sensor with the following setup:
Arduino Uno+motion sensor >>>sensor values>>>USB Serial>>>Laptop running Python code>>>Notification>>>WiFi>>>Web
The sensor generates a value. The value is displayed on the serial monitor. The python program is triggered into action by a specific value appearing on the serial monitor and the program sends an email notification.
I would like to replace that setup with the following:
Arduino Uno+motion sensor>>>sensor values>>>ESP8266 as transparent WiFi to Serial bridge>>>Laptop running Python code>>>Notification>>>WiFi>>>Web
Essentially, I want to get rid of the USB cable and use the ESP8266 as a transparent WiFi to Serial bridge. Of course, a battery would power the Arduino and ESP8266.
I read this post  and the Jeelabs/ ESP Link Readme. It seems that the ESP8266, once flashed with ESP Link, could replace a serial cable. But, can ESP Link replace the USB Serial in my current setup? If so, are there tutorials explaining how this can be done?
I did some further reading and researched the matter but so far I only found one use case similar to what I want to do. In the said use case, a virtual serial connection through WiFi was being executed via a server within the ESP8266. Unfortunately, there were no detailed explanations on how this was achieved and I don't think this would be suitable for my specific use.
Please let me know if further information or clarification is needed.

Why not use an actual protocol, such as HTTP?

The jeelabs link is indeed what you are looking for. You no longer need a USB-to-serial for that one (other than to program the ESP the first time).

@IgnacioVazquez-Abrams Hello, Would you say that the HTTP protocol would be better than the Jeelabs ESP Link transparent WiFi to serial bridge? If so, for which reasons? Thanks!

@Gerben Hello, Thank you for your comment. I'll dig deeper into the Jeelabs documentation and forums to determine the best way to go about it and report back here with progress or a solution. If you have any tips please feel free to post them. Thanks!

What kind of motion sensor are you using? You might be able to use an ESP8266 directly with it.

@Pabluski Hello, For this project it's a standard PIR motion sensor. I thought about having everything on the ESP8266 but first I need to understand the ESP8266 a bit better. Thanks!


text:
Arduino UNO and SPI eeprom (AT93C46D)
I'm trying to write to and read from an AT93C46D eeprom using an Arduino UNO but for some reason the output I'm getting is not what I expect.
The eeprom has a data structure of 128 words of 8 bits each and I'm trying to write 10000010 to each word. When reading back the data however I get 11000001.
When I write 00000000 to all words I get 10000000 for all words when reading. I tested my code on 2 AT93C46D eeproms and both gave the same result.
It looks like the MSB is always 1 (when reading) for some reason.
I'm probably making a stupid mistake but I can't seem to find it, any help is greatly appreciated!
Datasheet: http://www.atmel.com/images/atmel-5193-seeprom-at93c46d-datasheet.pdf
#include<SPI.h>
#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define SS 10//ss

void setup()
{
  pinMode(SS,OUTPUT);
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  digitalWrite(SS,LOW);

  Serial.begin(9600);

  SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));

  fill();

  dump();
}

void loop()
{

}

void fill()
{
  Serial.println("Send EWEN opcode");
  digitalWrite(SS,HIGH);
  SPI.transfer(B10011); //EWEN
  SPI.transfer(B0000000);
  digitalWrite(SS,LOW);

  delay(100);

  for (int i=0; i < 128; i++) {
    digitalWrite(SS,HIGH);
    SPI.transfer(B101);
    SPI.transfer(i);
    SPI.transfer(B10000010);
    delay(10);
    digitalWrite(SS,LOW);
  }

  delay(100);

  Serial.println("Send EWDS opcode");
  digitalWrite(SS,HIGH);
  SPI.transfer(B1000); //EWDS
  SPI.transfer(B00000000);
  digitalWrite(SS,LOW);

  delay(10);
}

void dump(){
  Serial.println("Dumping AT93C46D");

  byte b;

  for (int i=0; i < 128; i++) {
    digitalWrite(SS,HIGH);
    SPI.transfer(B110); //read opcode
    SPI.transfer(i);
    b = SPI.transfer(B00000000); //clock data out
    digitalWrite(SS,LOW);
    Serial.println(b, BIN);
  }
}

That does not look like an SPI device (or at least 8-bit aligned). Might need to bit-bang that device.

B10011? Don't you mean B10011000?

After looking at the product spec again I think it might be possible to get this working. The protocol is MSB with a start bit S followed by two bit op-code, and parameters. SPI on AVR is 8-bit transfer but transfer can be byte aligned with the start bit.
READ is op-code(10) followed by 7-bit address, a dummy bit and the read value. That is in total 11+8-bits. Mapping that to 8-bit transfer would be:
spi.transfer(0b110);
spi.transfer(addr << 1);
data = spi.transfer(0);

That will give 5-bit zero, start-bit, op-code in the first transfer, and followed by 7-bit address and dummy bit (LSB) in second transfer. The third transfer is the read data.
EWEN would map to:
spi.transfer(0b1001);
spi.transfer(0b10000000);

EWEN has op-code(00), followed by 9-bits, 0b11XXXXXXX.
The WRITE operation becomes:
spi.transfer(0b10);
spi.transfer(0x80 | addr);
spi.transfer(data);

Cheers!

I updated my .ino file per your suggestion: https://gist.github.com/anonymous/5f29911c6f1c15d0660f
But now I get even stranger results, by writing 0 to all bits the output is '10000000' for the first half of the words and '11111111' for the second half.
What is your reasoning behind doing address & 0x7f?

There is much more to consider with the other commands. In any case, the READ command has to create the sequence S(1), OP(10), ADDR(7-bit). The LSB of OP is MSB of the 8-bit with address therefore addr & 0x7f (alternatively alway keep address less than 128). The was a way to explain where the LSB of OP was.

You need to verify all other sequences and then there is a special dummy bit in READ response that needs some consideration.

Thanks for your help!
I adjusted my code one final time and added some comments:
https://gist.github.com/anonymous/3e085bd2d639f137d1a3
It might be useful for other in the future.

You are welcome. I had a look. Here are some possible changes (and tests). line 88-91: Could rewrite this as "data1 = (data1 << 1) | (data2 != 0);". line 82-85: Could you test this: "SPI.transfer(0b110); SPI.transfer(address << 1);  data1 = SPI.transfer(0); "

That works!
The replacement for lines 82-85 is pretty awesome good thinking! No need for the data2 now. Thanks again!

Updated the answer above with this finding.


text:
How to speed up
I found that using more float variable in arduino uno(atmega328p) slows it down (very muck that i can get slow response)
so, how to speed up it processing ?
my data are euler's angle with 2 digits and 2 decimals like give below
XX.XX , where X is number Eg.(85.63,34.65,etc) (from MPU6050)
How to process it fast?

Add the code for the slow procedure (or add your whole program) into the question.  Details make differences.  To tell markdown that a section is code, highlight it and press ctrl-K

i just found by multiplying raw value by 100 (85.63 * 100 = 8563),it is still integer so it will be fast in arduino uno. And divide it by 100 to get processed value

A technique commonly used in digital signal processing is using fixed-point arithmetic instead of floating point.  In fixed-point arithmetic, one calculates using numbers multiplied by some power of two or ten, and in effect mentally positions a binary or decimal point several bits or digits up while calculating. Numerical analysis may be needed to determine if the arithmetic is accurate enough and whether numbers will stay in bounds, or overflow.
The question doesn't say what's being calculated; it's possible fixed-point arithmetic might work, or might not.  A short self-contained fixed-point calculation that starts with MPU6050 sensor readings is likely to be ok, but long-term calculations (eg, integration of accelerations to get velocities and positions) that let error accumulate without reset may go too far astray.  In such a case, numerical analysis can indicate what intermediate results need to be stored most accurately.
Typically, when slow code is posted someone can point out speedups, from a few percent up to dozens of times faster.  Changes may range from adding or removing parentheses or temporary variables, to refactoring, to substitution of a new algorithm.

yeah i am now modifying code .


text:
Why all unset pins of my Arduino Uno are outputting 2 volts?
I am new to Arduino and physical computing When I measure the wire coming from any UNSET Arduino uno pin, the result is approximately 2 volts even the "ANALOG IN" pins. Considering that the pins which been set to HIGH and LOW are giving 5 and 0 volts "which is cool".
Is that the nature of Arduino or is that a failure caused by short or anything else?

Unconnected pins float near a certain voltage. If the voltage bothers you somehow just attach a pull-down resistor to them.

@Avamander I am trying to measure a small voltage from some kind of sensors which is between 0.2 - 0.6 volts to the analog in pin A0. I get my hands shocked when I do that because of the 2 volts getting out of the A0. I am worried about the sensor, I think the 2 volts is not good for it.

If your getting your hands shocked when touching the Arduino pins, maybe you need to ground your power supply... You can get badly hurt or even dead in some conditions!

@fabrosell my power supply is my laptop's USB

I think this is a simple question for expert users.

After a microcontroller reset, AVR IO pins default to input.  In this state they have high impedance.  For example, according to the Atmel ATmega328 spec sheet doc8271 Table 29-15, analog input impedance typically can be taken as 100 MΩ for design purposes.  (Input pin impedance may in fact be orders of magnitude more, effectively an open circuit except for leakage currents of a few nanoamps.)  Each pin has a few pF (5-10?) of capacitance [1,2,3,4] which in general is small compared to stray capacitances of attached wiring.
When stray electromagnetic fields charge the pin and stray capacitances, a small voltage develops on the pin.  You could connect a 1 to 10 MΩ resistor between the pin and ground, to avoid the 2 V you are seeing.

Does that mean that it is natural fact to have the 2V and that the solution is to connect a resistor with the input wire to solve that problem?

It's natural for arbitrary voltages to appear when you have an antenna (the wiring) attached to a capacitor (the wiring and pin).  BTW, how did you measure the voltage?  Many cheap DVMs have fairly low input impedance (about 1 MΩ) so you might see a voltage upon first connecting, but it should soon drop to near zero unless you are using long leads or have high EM fields in the area.  Getting a shock suggests hundreds of volts, not 2 V.

@AhmedAl-sabsab with the sensor connected to the Arduino there should no longer be 2 volts on the input pin that it is connected to; if there is then there must be an error in the way you have connected everything. You might need to provide more information on what you're actually doing - by editing the question.

I have used an expensive multi-matter to measure the voltage. I also used  Serial.println(volt); to print the result to the PC screen and I get the same result. the shock stills a mastery. it is a tiny shock not a killing one of course.

What exactly shocks you? The pins?

It seems that you might need a nice conductive wristband or take off the wool socks and stop covering your floor with plastic bags :D Your description sounds like either static or something is very wrong with your power supply.

@Avamander I will try the resistor then I will try to shock my self again (bad habit :D)

I get shocked when I touch the connection of the wire coming from the sensor to the A0 analog in

Attach one end of a 10K resistor to ground, and the other end to  a wire.  Look very closely (for tiny sparks) as you move the probe end of the wire towards the input.  If no sparks, probably the shocks you've seen are from static electricity in your body.  You can also hold the probe end of the wire between thumb and ring finger, then touch the input with forefinger.  (Generally, don't let shocks go across your body.) Having no shock in this case (where the probe is grounding your hand) would be consistent with static-electricity-in-your-body theory.

The electric shocks being felt is due to leakage current from the laptop's switchmode power supply. All unearthed mains powered switchmode plug pack power supplies leak a few micro amps and voltages in excess of 80 volts AC as measured from the plug packs output socket to ground will be observed when measuring with multimeters having 10 meg ohm input impedance.
The solution is to have the GND pin of the arduino board connected to earth. Here in Australia all computer power supplies are grounded via the 3 pin power plug.

The pin is default to Tri-State or High-impedance(Hi-Z) which means they do not either sink or source current. Just as others say it's a matter about electromagnetic or some such. A voltmeter can measure its voltage because the current it takes is small enough(close to or smaller than the leakage current). The real value is undefined when you are not measuring it. Instead of reading analog pin values, You can try reading digital pins to take a better look at "floating".
A Hi-Z pin can absolutely power nothing from LED to other big stuffs. If all you want is just stable readings, well, this is where pull-up or pull-down resistors come in place. Typically these resistors can be from 10KΩ to 10MΩ, ensuring that when the pin is not connected they will provide the pins with stable values while when connected the influence of pulls can be safely ignored.

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


text:
Atmel SAM MCU (on Arduino Due) only boots after second power up
I am using an Arduino Due as a prototyping board for a microcontroller project. The due has the chip Atmel ATSAM3X8E, with an ARM Cortex-M3 core. I am programming the flash directly using Atmel Studio and SAM-BA over USB, I am not using the arduino tools or bootloader in any way, at least not to my knowledge. I am powering it over the USB port on the arduino.
I am able to program the flash and select flash for boot, but the problem is that the chip never works the first time I plug in the power. But if I cut the power and try again, it boots normally and the program starts. Then if I cut the power and wait a while, I have to power it up another two times before it works. It's like there is some volatile charge or RAM in there that needs to have been powered within the last minute for the chip to boot at power up like it should, but I don't know what. The result is the same if I plug the USB into my computer, or from a phone charger. Also the same whether I use the native or arduino programming USB port to power it.

How about if you press the reset button? after powering it up for the first time?

Then it starts correctly

Floating bootloader pin?

I don't know if there is a bootloader pin.. Can't find anything about that in the datasheet. Here is the schematic for the arduino: https://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf

Edit: Maybe the SHDN pin? I see it is related to some kind of sleep / power save mode, and it is not connected

I did this improvement and worked to me
https://forum.arduino.cc/index.php?topic=256771.30 (#35)


text:
Arduino Leonardo Pro Mini will not begin sketch when connected to BIOS not an OS
I have an Arduino Leonardo that I am using to emulate a Keyboard using the keyboard.press function with the Keyboard.h libraries. I have gotten the Keyboard.press function to work on my windows and mac- the keystroke I used was CTRL N to test- this worked well. So my ultimate goal was to emulate a keystroke ,F1, on a PC that is not running an OS- meaning I want the sketch to run in BIOS. for context, This keystroke (F1) tells the computer to use the a bootable USB to run a certain MathWorks OS.
The problem, when it is plugged in the Arduino shows that power is receieved by lighting the POWER LED but it does not begin the sketch. The RED LED that usually flashes ( TX or RX im not sure) when it is running a sketch is not happening (not illuminating).
How can I troubleshoot this and what could be happening? I have read that maybe too much serial info is going to the board so it confuses the board and does not begin the sketch.
I appreciate all the following help!!

When you have booted into Windows or OSX, how long does it take from the moment you plug the Leonardo into the computer to the keystroke happening? Are you sure that the computer isn't leaving BIOS or POST before the Arduino has had a chance to boot itself?

Because the computer doesn't have a full OS at POST time any USB keyboards attached to the system have to operate in a special "Boot Keyboard" mode.

Keyboards that implement the USB Boot Keyboard profile specified in the USB Device Class Definition for Human Interface Devices (HID) v1.11 and are explicitly configured to use the boot protocol will interrupt the CPU every time the keyboard is polled even if there is no change in state unless the USB controller overrides this behavior, and are limited to 6-key rollover (6KRO). This profile is intended to allow the BIOS to handle a USB keyboard in the absence of a USB-aware operating system. The recommended profile for keyboards that are not in boot mode in this specification limits keyboards to 6KRO and causes them to respond to an interrupt with a status report at least every half second even if there is no state change in the keyboard unless the USB controller overrides this behavior in order to implement typematic (the function that causes keys to repeat when they are held long enough). However, keyboards in non-boot mode are free to implement an alternative HID profile.
-- Wikipedia

Since it was not expected that anyone would be using the Leonardo to operate in the BIOS that functionality has never been implemented. The choice was to implement the entire system, which would have left less room for your sketch, or to just implement the parts that the majority of people would find useful (that is keyboard, mouse, joystick, etc) and leave out the extra stuff, leaving as much room for sketches as possible.
They chose the latter, since as I am sure you are well aware: "The needs of the many outweigh the needs of the one".
For your rather specific case it may be easiest to butcher an old USB keyboard and work out which pair of inputs to the matrix, when connected together, perform the function you require and design some small interface circuit to allow the Arduino to trigger that function.

Thanks for the Input, you were quite right Majenko. The keyboard.press does not work in BIOS. The problem has been solved by a patch ( I'm not sure if that's the correct terminology) I found on github. By a Nicohood, here is the project if anyone find this having the same issues as me.https://github.com/NicoHood/HID?files=1


text:
Regulator magic smoke
I have accidentally released the magic smoke from the regulator on a digispark board. I did this when I accidentally plugged a circuit into the 5V and the VIn instead of the 5V and Gnd, and then plugged the board into the USB port.
The attiny chip still works - I know because I plugged it in to the USB ,with no circuitry attached, and the uploaded program still runs happily.
My question is, is there any possibility that when the magic smoke was released from the regulator, the attiny was also damaged?
Secondly, is there any harm in leaving the dead regulator on the board? Or am I better off cutting it off?

Better replace the regulator on the board. Cutting or leaving is not the best idea.

Linear voltage regulators have an internal parasitic diode that shorts the output to the input. You have burned out this diode which has destroyed the regulator, but it is highly unlikely that any other components have been damaged. You can get away with cutting away the legs of the regulator, but complete removal will be difficult due to the large size of the tab connection and will likely result in damage to the other components.


text:
GPS Receiver SKG13BL + Arduino - Having trouble receiving data
Here is my setup:
I'm trying to read the GPS data from SKG13BL which is connected to an Arduino Uno.
The GPS seems to be working fine as I could see the green status light blinks after a while (I think it takes time to fix the position).
I connected TTL of SKG13BL to UNO Digital pins 2 & 3 and connected the ground as well.
Here is the image of the connection:

I'm using the TinyGPS test with GPS device sketch to read the data. but I always get something like this,

**** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   30862 0         116
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   30885 0         116
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   30929 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   30952 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   30985 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   31019 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   31041 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   31086 0         117
  **** **** *******  *******   **** *******    *******    **** ******* ****** ***** *   0        0.00   *   31109 0         117

I tried swapping the pins, using external power source instead of Arduino's  3.3, but there is no change in the result, any advice would greatly help.
Update 2/26
I changed the pin here to 10 & 11, and using this code
#include <SoftwareSerial.h>
#include <TinyGPS.h>

SoftwareSerial mySerial(10, 11); // RX, TX
TinyGPS gps; // create gps object

long lat,lon; // create variable for latitude and longitude object

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
    //gps.encode(mySerial.read());
    if(gps.encode(mySerial.read()))
      { // encode gps data
      gps.get_position(&lat,&lon); // get latitude and longitude
      // display position
      Serial.print("Position: ");
      Serial.print("lat: ");Serial.print(lat);Serial.print(" ");// print latitude
      Serial.print("lon: ");Serial.println(lon); // print longitude
      }

  }

}

But this only displays the below, lon and lat not coming up in the feed even after waiting for an hour.

$GPRMC,043721.000,A,1301.6666,N,07740.9169,E,0.13,343.86,260216,,,D*61
  $GPGGA,043722.000,1301.6666,N,07740.9169,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*72 $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37
  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71
  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46
  $GPGSV,4,3,13,27,18,238,12,25,15,087,16,26,13,180,,08,11,268,*7A
  $GPGSV,4,4,13,11,09,311,20*43
  $GPRMC,043722.000,A,1301.6666,N,07740.9169,E,0.26,343.86,260216,,,D*64
  $GPGGA,043723.000,1301.6665,N,07740.9169,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*70 $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37
  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71
  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46
  $GPGSV,4,3,13,27,18,238,12,25,15,087,16,26,13,180,,08,11,268,*7A
  $GPGSV,4,4,13,11,09,311,20*43
  $GPRMC,043723.000,A,1301.6665,N,07740.9169,E,0.33,343.86,260216,,,D*62
  $GPGGA,043724.000,1301.6664,N,07740.9170,E,2,7,1.36,902.9,M,-88.1,M,0000,0000*7E $GPGSA,A,3,10,31,18,11,193,14,22,,,,,,1.62,1.36,0.88*37
  $GPGSV,4,1,13,41,73,157,43,31,72,187,37,10,47,048,33,14,41,003,28*71
  $GPGSV,4,2,13,18,32,088,16,193,30,107,29,22,27,330,21,21,26,154,*46
  $GPGSV,4,3,13,27,18,238,,25,15,087,16,26,13,180,,08,11,268,*79
  $GPGSV,4,4,13,11,09,311,20*43

Updated code on 3/1
This one works perfectly and provides the latitude and longitude.
Thank you @slash-dev and @altinturk
#include <SoftwareSerial.h>
#include <TinyGPS.h>

SoftwareSerial mySerial(10, 11); // RX, TX
TinyGPS gps; // create gps object

long lat,lon; // create variable for latitude and longitude object

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {

char c = mySerial.read();
Serial.write( c );
if (gps.encode( c ))
      { // encode gps data
      gps.get_position(&lat,&lon); // get latitude and longitude
      // display position
      Serial.print("Position: ");
      Serial.print("lat: ");Serial.print(lat);Serial.print(" ");// print latitude
      Serial.print("lon: ");Serial.println(lon); // print longitude
      }

  }

}

Here is the output

$GPGSA,A,3,14,20,21,18,29,15,10,,,,,,2.59,1.13,2.33*0E
  $GPGSV,4,1,13,29,63,172,35,40,59,241,34,15,45,039,43,18,44,324,51*7A
  $GPGSV,4,2,13,21,42,350,46,10,27,284,46,24,27,116,19,14,25,209,17*76
  $GPGSV,4,3,13,20,24,037,46,193,23,064,39,25,10,180,16,26,08,268,*44
  $GPGSV,4,4,13,16,01,294,*42
  $GPRMC,003218.000,A,1301.6703,N,07740.9225,E,0.02,0.00,010316,,,D*6D
Position: lat: 1******8 lon: 7*****42

Seems you are able to receive data properly (according to your the update.) I was using TinyGPS++, an advanced version of TinyGps (http://arduiniana.org/libraries/tinygpsplus/), maybe those can help you:
Try
Serial.print("LAT=");  Serial.println(gps.location.lat(), 6);
Serial.print("LONG="); Serial.println(gps.location.lng(), 6);

GPS cannot get any data indoors. Put your gps close to a window or better -directly outside. First of everything you will get a date&time data on the output, then number of satellites, then the Lat/lon data. But GPS has to receive data indoors.
On some chips there is a LED starts blinking once it gets a fix from any satellite. Keep an eye on it.
I realized this small issue when my phone (used for "calibration") couldn't get a fix by its embedded GPS without any cell/network assistance. You should try if you get any signals where you put your device.

Hi Thank you for your response, Yeah I could see the Status LED starts blinking in green and the I kept the antenna outside of the window looking up to the sky. I believe I'm doing something wrong in the way I read the data.. or connecting the wires.

Check the answer :) I added some piece of code. I used tinyGPS++ but I guess these two are quite relevant.

Sorry about the late reply, Thanks a lot for your response, i will try with the tinygps++,

You are consuming the received characters with the debug print:
Serial.write(mySerial.read());
//gps.encode(mySerial.read());
if(gps.encode(mySerial.read()))

Instead, do this:
char c = mySerial.read();
Serial.write( c );
if (gps.encode( c ))

Also, SoftwareSerial is a real CPU-killer.  Try NeoSWSerial instead.  It's much more efficient and reliable.  Sometimes other interrupts, like Serial.print, can cause SoftwareSerial to be unreliable.  Echoing the received characters may be enough to cause characters to be lost.  NeoSWSerial is not nearly as susceptible.
And while you're at it, take a look at another library I wrote, NeoGPS.  It's the fastest and smallest library out there, especially when you configure it to only parse the fields and messages that you use.  For example, if you only need lat/lon, disable all the other fields (time, alt, speed, sats, etc.) and all the other messages (just RMC, no GGA, no GSA, no GSV).  Saves lots of RAM and CPU time!

Thank you , you nailed it down, i was loosing the information in the debug print, after correcting that able to get the lat and lan, posted the updated code. i will try with the NeoSWSerial as well,

@RamS: LOL, that green check is supposed to be for the answer that worked for you, so I'm not sure why you checked altinturk's answer.   The up and down arrows can be used by anyone like a vote.  The check is reserved for the Original Poster.  Cheers!


text:
How to write array of functions in arduino library?
I've nine functions each of type void as follow:
void zero();
void one();
void two();
void three();
void four();
void five();
void six();
void seven();
void eight();
void nine();

I've put all these functions into an array pointer as follow (without any error):
typedef void (*num_func) ();
num_func functions[] = { zero, one, two, three, four, five, six, seven, eight, nine};

Now I'm writing an arduino library and wanting to achieve the same, but after hours of thinking I'm not able to achieve. Please help me how can I accomplish this in a library?
Thanks in advance.

@Mikael
Sorry Mikael, I'm not able to comment at your answer (because stackexchange demands me to have 50 points before I can comment). Here is the error I'm getting from your implementation. storage class specified for 'functions'

What is your setup? I do not get that error. Obviously there must be some implementation of the functions and there must be a sketch that uses the library.

Yup, I've the implementation of the functions in .cpp file (for all of these zero() etc. functions).
And also, I'm getting this error when I compile a sketch using that library.

Which line does to the compiler indicate? You have added some extra character or added extern also in the implementation.

It is pointing at:      extern num_func functions[];
And I've NOT added extern in the implementation.

What compiler/IDE version are you using? You have not answered the question about the setup. You must provide more information.

I'm using Arduino IDE latest uptodate.
And I can provide more information of course. What do you mean by "What is your setup?"

Let us continue this discussion in chat.

Ah, one thing that might be of worth noting is I've declared the functions zero() etc. as members of the class.

I've tried the implementation of the function as you've in your edited answer, but as a member of the class I'm talking about. And my implementation in the loop() is as follow:     myClassNamet::functions1;
Now I'm getting additional error "invalid use of non-static data member 'myClassName::functions'

I have migrated your answer to be comments under your question. You can always edit the question itself and add additional notes in response to answers.

You must define the member function as static. But then it cannot access member data as there is no this reference. Please mark this question as answered or at least update your original question with with is not yet answered.

This was a bit fiddly to get right. I got inspiration from How do I create and use an array of pointer-to-member-function?
Based on my post about Function pointers / function callbacks / function variables I modified it to work with class functions:
class foo {

  public:

   void doAction0 ()
    {
      Serial.println (0);
    }

    void doAction1 ()
    {
      Serial.println (1);
    }

    void doAction2 ()
    {
      Serial.println (2);
    }

    void doAction3 ()
    {
      Serial.println (3);
    }

    void doAction4 ()
    {
      Serial.println (4);
    }

   // typedef for class function
   typedef void (foo::*GeneralFunction) ();

   // array of function pointers
    GeneralFunction doActionsArray [5] =
    {
      &foo::doAction0,
      &foo::doAction1,
      &foo::doAction2,
      &foo::doAction3,
      &foo::doAction4,
    };

};  // end of class foo

void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  Serial.println (F("Starting"));

  // test instance of foo
  foo bar;

  for (int i = 0; i < 5; i++)
    {
    // get member function pointer from array
    foo::GeneralFunction f = bar.foo::doActionsArray [i];
    // call the function
    (bar.*f) ();
    }  // end of for loop

}  // end of setup

void loop () { }

This compiles OK and prints:
Starting
0
1
2
3
4

Amended answer
I was wondering why you needed to specify bar in this line above:
    foo::GeneralFunction f = bar.foo::doActionsArray [i];

The reason is that the code above had the array as non-static, and thus a copy belonged to each instance of the class. This doesn't make a huge amount of sense, so the modified code below makes the array static and const. That is, the array should be the same for every instance of foo and also never change.
Modified code below:
class foo {

  public:

   void doAction0 ()
    {
      Serial.println (0);
    }

    void doAction1 ()
    {
      Serial.println (1);
    }

    void doAction2 ()
    {
      Serial.println (2);
    }

    void doAction3 ()
    {
      Serial.println (3);
    }

    void doAction4 ()
    {
      Serial.println (4);
    }

   // typedef for class function
   typedef void (foo::*GeneralFunction) ();

   static const GeneralFunction doActionsArray [5];

};  // end of class foo

 // array of function pointers
const foo::GeneralFunction foo::doActionsArray [5] =
  {
    &foo::doAction0,
    &foo::doAction1,
    &foo::doAction2,
    &foo::doAction3,
    &foo::doAction4,
  };

void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  Serial.println (F("Starting"));

  // test instance of foo
  foo bar;

  for (int i = 0; i < 5; i++)
    {
    // get member function pointer from array
    foo::GeneralFunction f = foo::doActionsArray [i];
    // call the function
    (bar.*f) ();
    }

}  // end of setup

void loop () { }

This will also save RAM, as the array of function pointers only exists once, not once per instance of the class.

See amended answer. The second method is a bit simpler and uses less RAM.

First you need a header file - let's say lib.h:
#ifndef LIB_H
#define LIB_H

typedef void (*num_func) ();
extern num_func functions[];

#endif

And then the implementation, lib.cpp:
#include "lib.h"

void zero();
void one();
void two();
void three();
void four();
void five();
void six();
void seven();
void eight();
void nine();

num_func functions[] = { zero, one, two, three, four, five, six, seven, eight, nine};

The functions could be declared as static (if you want to hide them) and they do need implementation. They are only forward declarations above. Below is a snippet of a sketch using the library (assuming that it is within the sketch folder).
#include "lib.h"

void setup()
{
  ...
}
void loop()
{
  ...
  // Call to the one() function
  functions[1]();
  ...
}

Cheers!


text:
Arduino Pro Mini
I have the following problem
I have a pro mini clone, with 328/5V. It was successfully working in my board. I pulled it out of the board, and wanted to update my software. I connected it to my FTDI, arduino was normal by this time. Power on LED was on. I stared uploading, my sketch compiled and started writing. While it was writing, my 3.5 year old daughter who approached me from behind and whom I did not see pulled the Arduino out of FTDI - "what is that nice red light?" Of course writing failed.
Now, when I connect the arduino to FTDI, it is dead. No LEDs light up, no sync... what to do? Any chance to revive it?

Check the FTDI as well. Voltmeter could be helpful.

Just flashed another Arduino board to test - worked without problems...

Ok, then if looks like FTDI is alive and the Pro Mini is dead.

Just decided to examine the Arduino for physical damage, and that was it! Looks like she ripped Arduino off the cable so hard, that the solder holding the programming pin row was not holding! I resoldered all connector pins, and it worked now!

Tough thing. You are lucky. Cheers! Please mark the question as answered (i.e. provide your solution as an answer and accept it).

Check for physical damage! Solder connection of the programming pins to the board was damaged in my case. Resoldering helped!


text:
Neopixel led strip stops responding after change in brightness
I have an arduino UNO hooked up to a neopixel LED strip with 148 lights.  Most of the time it works fine, but when I upload a program that changes the brightness frequently, particularly when I increase brightness, only the first 8 LEDs continue responding.  The rest get stuck.
Here's an example of the kind of code that sets this issue off.  To fix it, I usually have to restart the lights and the arduino and sometimes upload a blank program to the arduino.
I'm pretty new to arduino programming so and help would be really appreciated.  Thank you.
#include "FastLED.h"

FASTLED_USING_NAMESPACE

// FAST LED definitions
#define DATA_PIN    3
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS    148

CRGB leds[NUM_LEDS];
#define DATA_PIN 3 // Output Pin to Data Line on Strip

int fadeAmount = 5;
int brightness = 0;

void setup()
{
   FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
}

void loop()
{
   for(int i = 0; i < NUM_LEDS; i++ )
   {
   leds[i].setRGB(0,255,0);
   leds[i].fadeLightBy(brightness);
  }
  FastLED.show();
  brightness = brightness + fadeAmount;
  // reverse the direction of the fading at the ends of the fade:
  if(brightness == 0 || brightness == 255)
  {
    fadeAmount = -fadeAmount ;
  }
  delay(20);
}

After doing more research and getting feedback on the Adafruit forum here, it appears that the problem was a cracked solder joint.  I managed to get access to the strip and wiggled it a little and the problem has gone away.  The recommendation is to reflow the joint by adding a little solder over the data connection between where the LEDs stop being responsive.

If it's only the solder, you can indeed resolder/reflow it.
At one of my strips, the solder-joint ripped out some of the strip, then it will be best to cut out the pixel completely. You can easily re-attach them (without the single pixel).

You might indeed also check the heat generation, if it becomes hot enough to reflow the solder, it won't last long.

I replaced the pixel and the set up appears to be working without issue now.

It is almost certainly a power issue. The Adafruit page about one of those types of Neopixels says:

Don't forget, with 256 LEDs, you could use over 15A of current if you turn on all the LEDs on to white (which we really do not recommend because we don't think the flex PCB can handle that much current). Try to keep the current draw at under 5A ...

Increasing the brightness increases the current drawn. Do you have a heavy-duty power supply? Are the connecting leads sufficient for (say) 8 amps of current?

New information based on comments made
Based on comments by Lorenz I now think it is more likely to be that they are overheating.

I have the strip embedded in a picture frame with epoxy resin over it.

That makes it difficult for the ICs to cool down, and LEDs generate heat. If you search for "neopixels heat" you find quite a few matches. Some suggestions made are to use a heat sink or a fan. If this isn't practical for you, then running at a lower PWM rate (ie. not as bright) and not as saturated colour, could help keep the heat down.
You don't want to "cook" one of the early pixels, because each one has to pass the data on to the next one in sequence, so if you lose an early one, you lose everything after it, particularly if you can't get at it to replace one.

Postscript regarding heat
I have been testing a NeoPixel with a temperature sensor. Displaying full white (255/255/255) it has reached about 44°C. So clearly it warms up. However this is in the open air with just some sticky-tape holding the sensor onto the LED. According to the spec the chip can operate at up to 80°C, so this is within range.
However if the whole thing was sealed in epoxy, then the heat being generated would have much less chance of escaping into the ambient air, and thus would be likely to get a lot hotter.

I'm pretty sure I'm good on the power supply side.  I have a 5V 10A supply hooked up (https://www.adafruit.com/products/658).

What do you mean by are the connecting leads sufficient for (say) 8 amps of current?

I'm using basic jumper wires (https://www.adafruit.com/products/1957) connected through a 2.1mm DC barrel jack and a mini breadboard.

I see. From that page Each wire is 28 AWG (7 strands @ 36 AWG) and from  Wire Gauge and Current Limits Including Skin Depth and Strength 28 AWG wire has a maximum of 1.4 amps for chassis wiring. Thus I suspect your wiring cannot carry the load. Try measuring the voltage on the Neopixel end (ie. at the end of the wire). I am guessing that, when the brightness is up, you won't be getting 5V there.

Nick - I've rewired the neopixel wires to go directly to the 5v power supply without any jumper cables in between.  I'm still getting the problem.  I have the strip embedded in a picture frame with epoxy resin over it.  I cannot actually get to the other end of the strip to measure the voltage there.  Is it possible that the epoxy enclosure is causing the LED to overheat.  Usually the strip works fine for a few minutes (if I haven't plugged it in in a while) and then craps out.  Any thoughts on how I might be able to fix this without tearing up the frame?

With a lot of current going through them overheating sounds like a possibility. Do you have a way of measuring the heat of them (eg. a contact thermometer)? You could try setting the code to operate them at a low power level for a while, to see if it is heat, or time, that is causing this. Also, can't you at least measure the power input voltage to the frame?

The input voltage is 5V.  I've measured it and it's pretty constant.  Time definitely seems to be a factor.  When I run the lights at lower power, they last much longer and when I don't run them for a while and then run them, they last longer too.  After they crap out, only the first 8 respond to the pulsing pattern and the rest just stay lit at the color they were the moment it crapped out.  I'm trying to figure out what I can do to remedy this situation.  The LEDs are completely encased in wood and epoxy so there's very little air circulation around the strip.

My understanding of NeoPixels is that the early ones have to take the incoming data, strip out one RGB sequence, and pass the others on. Thus the earlier ones have more to do than the later ones, and if an early one fails, the later ones will do nothing. This would tend to explain what you are seeing.

Can you think of anything I can do to fix the situation?

If you can measure the temperature you could confirm it is indeed getting hot. And to fix it, if it is all encased in epoxy, all I can suggest doing is running at low brightness so it doesn't heat up too much.

Nick - one more question for you.  When I have this issue, the LEDs continue to be fully lit.  It's just the data that doesn't seem to go past the first 8 LEDs.  The remain 140 LEDs stay lit and bright they just stop responding to the pattern.  Would this suggest something other than a power issue?

I presume the LEDs "remember" the last colour latched into them. With power applied they would continue to show that. If data doesn't go past the first 8, it would seem likely that the 8th one has overheated and stopped passing the data on.

See amended post regarding measuring the temperature of the pixel when operating.


text:
How to update multiple outputs simultaneously
I need to update simultaneously all the outputs of a specific port.
I am familiar with using micro-processors assembly language. After initializing a port (Data Direction Register), I can write to that port and all outputs will update simultaneously.
In the Arduino commands  : I am aware of how to configure pins, such as pinMode(pin, mode), to make a pin an output or input.
I know of the digitalWrite(pin, value) , but this only updates one pin per command.
For timing reasons, I need to update several (same port) outputs without any time delay.
Normally (using assembly language) , I would keep a register with the data I desire on the output port, and write that register's data to the port.
Is there a command I can use in Arduino to accomplish the same thing?
If not a single command, what other choices do I have?
I use Arduino  micro,  UNO,  but I think the question might be valid for most Arduino

Yes, the ports of an Uno are addressed in C/C++ as PORTB, PORTC, and PORTD respectively, each 8 bits wide. You can read them or assign to them. Other processors' ports have similar names. Of course the pins' port assignments and functions differ from one to the other, which is one reason for providing the single-pin pinMode() and digitalRead(), digitalWrite() functions. But where you need to deal directly with the hardware (and probably don't care about chip-to-chip portability), the registers are exposed with the above symbols.
Also note that most other CPU registers are exposed the same way - the ports' data-direction registers as DDRA, DDRB, DDRC. You may not care about setting them up simultaneously, but if you wanted to make all of your hardware accesses similarly (and save the flash space for the portable pin functions), you could.
Update:

Is there a specific command I can use ? Such as Write PortD ?

Yes, you can use the PORTx names like any other C/C++ variable:
PORTD = 0xFF;
PORTD ^= 0x02;
if( (PORTD & 0x40) != 0 ){, for just a couple of examples - just like real C! :-)
PS: Pighixxx makes absolutely top-notch pinout diagrams for boards & processors. Here is his diagram for the 28-pin DIP-packaged AtMega328p for instance. They're extremely useful when you're working with a chip at the port or board level.

Is there a specific command I can use ?   Such as Write PortD  ?

If you need to do more than 8 (especially LOTS more), and timing is very critical, you can use a Serial In, Parallel Out (SIPO) chip, such as the 74HC595 - it also saves a lot of pins on the Arduino.
To use it, you need 3 pins connected to the Arduino. You send one bit to the chip from the Arduino for each output, then when you have them all set, you toggle the Latch pin - all output pins change at the same time. The chip has 8 outputs.
Another advantage of a chip like this is that you can daisy-chain them - with the same 3 pins, you can control as many pins as you like (subject to power availability, of course!).
Read https://www.arduino.cc/en/Tutorial/ShiftOut for more information on how to use them. They are dirt cheap (about US$1.26 each if you buy 10 from AliExpress, shipped to NZ, which is where I am).

Even though I selected another answer as more directly answering my question, your answer is also very helpful.


text:
Serial monitor listing unreadable characters

My Serial Monitor is displaying unreadable characters.  If anybody can give me some insight on why this would be happening please let me know.
Thank You.

It greatly helps to post the code as text (copy from IDE, paste here) - that way people can copy/paste it into their own IDE for testing. What you have done forces people to read from your image, and retype. Please format the code using the code formatting markdown (four leading spaces). For help see Markdown help. You should be able to do this by selecting the code and pressing Ctrl+K to have your browser do this for you.

I changed from 9600 to Serial.begin(115200) and matched the serial monitor to 115200 and it worked. Went back to 9600 and back to same error. Interesting to know wht

Change Serial.write to Serial.print (or Serial.println).
write writes in binary, which gives you unprintable characters.

I am facing same issue https://arduino.stackexchange.com/questions/38289/at-commands-is-sending-response-in-square-box-on-serial-monitor can you help me what I am doing wrong

I changed Serial.print as well but no success

Make sure the selected baud (like 115200, 57600) in Serial Monitor matched the one specified in code like Serial.begin(115200)

This is sound general advice, however the image in the question clearly shows that the baud rates match.

I had the same problem, baud rate was the same in the code as it was in the serial monitor. I tried changing the baud rate in the code to 19200 and the same in the serial terminal and that fixed the problem. Hope this helps, not sure why it wasn't working with the 9600 baud value. Also found that clicking on the wrong baud rate in the terminal and back on the right one fixed the issue with it displaying gibberish.


text:
Speed Control L298 motors
Proceeding is the relevant part of the code for the problem I'm asking assistance with.  I'm attempting to vary the speed of the robots motors with PWM. The left motor speed can be varied numerical. The right motor fails to move. Any ideas is appreciated. The motor speed code is at the end of the sketch.
Any assistance is greatly appreciated.
//Below are the symbolic constants. Instead of having to type in a non-sensical pin number each time we want to do something we can write an easy to understand name which represents the pin, the compiler will then replace the names with the numbers
 #define LeftMotorForward 8
 #define LeftMotorBackward 9
 #define LeftMotorSpeed 10
 #define RightMotorForward 6
 #define RightMotorBackward 7
 #define RightMotorSpeed 5
 #define USTrigger 3
 #define USEcho 2
 #define MaxDistance 100
 #define LED 13

//Here we have created two 'objects', one for the servo and one for the ultrasonic sensor
 Servo servo;
 NewPing sonar(USTrigger, USEcho, MaxDistance);

//Below we are creating unsigned integer variables which we will use later on in the code. They are unsigned as they will only have postive values
 unsigned int duration;
 unsigned int distance;
 unsigned int FrontDistance;
 unsigned int LeftDistance;
 unsigned int RightDistance;
 unsigned int Time;
 unsigned int CollisionCounter;

 void setup()                                            //This block happens once on startup
 {
  Serial.begin(9600);                              //I have included the serial initialize but commented it out, if you want to debug and print information to the serial monitor just uncomment

  //Here we are setting the pin modes. As we will sending out signals from the pins we set them as outputs
  pinMode(LeftMotorForward, OUTPUT);
  pinMode(LeftMotorBackward, OUTPUT);
  pinMode(LeftMotorSpeed, OUTPUT);
  pinMode(RightMotorForward, OUTPUT);
  pinMode(RightMotorBackward, OUTPUT);
  pinMode(RightMotorSpeed, OUTPUT);
  pinMode(LED, OUTPUT);
  servo.attach(11);                                    //The servo is attached to pin 4
 }

 void loop()                                           //This block repeats itself while the Arduino is turned on
 {
  servo.write(90);                                    //Rotate the servo to face the front
  scan();                                             //Go to the scan function
  FrontDistance = distance;                           //Set the variable FrontDistance to the value of the distance returned from the scan function
  Serial.println("Front distance = ");
  Serial.print(distance);
  if(FrontDistance > 40 || FrontDistance == 0)        //If there is nothing infront of the robot within 40cm or the distance value is 0 (which for the newping libary means no ping was returned) then...
  {
   moveForward();                                     //Go to the moveForward function
  }
  else                                                //Else (if there is something infront of the robot within 40cm) then...
  {
    CollisionCounter = CollisionCounter + 1;
    moveStop();                                       //Go to the moveStop function
    navigate();
  }
 }

 void moveForward()                                    //This function tells the robot to go forward
 {

  Serial.println("");
  Serial.println("Moving forward");
  //Turn on left motor
  digitalWrite (LeftMotorBackward, LOW);
  digitalWrite(LeftMotorForward, HIGH);
  //set speed
  analogWrite(LeftMotorSpeed, 100);

 // turn on right motor
  digitalWrite(RightMotorBackward, LOW);
  digitalWrite(RightMotorForward, HIGH);
// set speed
   analogWrite (RightMotorSpeed, 75);

Also asked here

You are not sending a speed command to the motor, you are sending it an analog voltage with the analogWrite. If that voltage is too low, the motor will stall. A higher value should make it spin faster. If you want the speed to be more tightly controlled, you will need encoders on the motors to sense how fast they are spinning, or use stepper motors.

First try commenting out the
 Servo servo;

line, and all other bits using the servo.  If it works then there's your problem - use the Mega possibly as this allows more PWM outputs.
If it doesn't work with the Servo bits removed, then report back and include the Arduino model you're using.
Good luck!

int value;
for(value = 0 ; value <= 75; value+=5)//if value is <=50 left motor does not spin. >75 both motors turn
Serial.println("");
Serial.println("Moving forward");
analogWrite(LeftMotorSpeed, value);//int value has no effect on speed
analogWrite (RightMotorSpeed, value);// same as LeftMotor)

Thanks Andy. I'm getting a Mega board and using pin 11 on the Uno, to avoid the servo conflict.

I commented all references to servo, the same results. Comment out the servo code doesn't seem to make a difference. What's going on is when the speed is numerically controlled the motor speed varies. At 50 the right motors slows down and the left motor HALTS, Not sure what's going on.
//This function tells the robot to go forward
int value;
for(value = 0 ; value <= 75; value+=5)
    //if value is <=50 left motor does not spin. >75 both motors turn
    Serial.println("");
    Serial.println("Moving forward");
    analogWrite(LeftMotorSpeed, value);//int value has no effect on speed
    analogWrite(RightMotorSpeed, value);// same as LeftMotor)

    digitalWrite(LeftMotorBackward, LOW);
    digitalWrite(LeftMotorForward, HIGH);
    digitalWrite(RightMotorBackward, LOW);
    digitalWrite(RightMotorForward, HIGH);

Now you've got both motors running, but they don't run at the same speed?  A common problem - possibly not enough current getting through from the battery. See Jim's answer.

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


text:
Programing uploading to Arduino due
I am new to Arduino and bit blur on how it works. lack of info on the net about it. please help me with these questions!

Does Arduino due allow you to upload a program on programming port and then run it through Native port?
Can I work with SerialUSB instance in Programming port?

lack of info on the net about it Then you can't be looking very hard.

Does Arduino due allow you to upload a program on programming port and then run it through Native port?

You don't run a program through anything. You run it on the Due. Where you send text to is entirely up to you.

Can I work with SerialUSB instance in Programming port?

I have no idea what you are asking there. Both the Programming port and Native port are capable of being used as virtual USB COM ports. They use CDC/ACM. One is directly connected to the SAM3X chip's USB peripheral, and the other is connected to the SAM3X's UART interface via another microcontroller as a USB to UART converter.


text:
ESP8266 Firmware Upgrade
Can I upgrade my ESP8266 firmware by connecting the pins in Arduino Uno, or do I still need a USB UART to Serial?

Looking at the schematic of arduino UNO here you can see that Pin 0 and Pin 1 are connected to the same line of RX TX of the ATMEGA8U2. So in theory (and assuming the ATMEGA8U2 behaves like any usb to uart IC) if you remove or disable the ATMEGA328P, your arduino should behave like any cheap usb to serial. The way you can "disable" ATMEGA328P is by setting it in constant reset mode as explained here
By manually reseting and setting the esp into flashing mode, you should be able to upload the new firmware to it from arduino IDE for example by selecting the ESP device.
Two notes on this
1 - The TX line of the ATMEGA8U2 is the marked RX on arduino Uno board and RX line of the ATMEGA8U2 is the marked to TX on arduino Uno board. That means your ESP RX should connect to pin 0 on arduino and TX of ESP should connect to pin 1.
2 - You might need voltage level conversion on pin 0 as ESP is a 3.3V device although in schematic there is 1K resistor in that line


text:
What Arduino board with WiFi should I choose
I want to implement an Arduino module with some sensors and send the info through WiFi to a server. I'm looking for the best board or component combination to make this. What is the best board or solution you would use in my case? Maybe Arduino Yun or Intel Edison Kit for Arduino...¿?
I've developed a sensor module with Redbear Blend board which use Bluetooth to communicate with an Android app to send sensor data, but now looking for WiFi connection.
Sorry if it's a stupid question, I'm new in this Arduino world. Thanks in advance!

I'd recommend ESP8266 (model 07) based board.

Can be programmed the same way as other Arduinos
Cheap
Enough storage for code
Fairly low power
Large community (more code examples and better library support)

Ok, thanks, I'm checking it right now and it seems just what i was looking 4 ;)


text:
Sensor/servo shield for Arduino Mega
Is there Arduino shields with blocks of 4 pins that you can plug your servos into and use the fourth pin as signal pin to the Arduino Mega board?

You could (probably) easily make this yourself (using an Arduino prototype board and some pin-headers) or buy an arduino "servo controller shield".
Also, Arduino.Stack Exchange isn't the place for shopping recommendations, you could ask suppliers/manufacturers if they have such a thing available.
It's also a little unclear, do you want the 3 servo's to receive the same signal? You could simply attach them to the same header and "short", solder or jumper the pins together.

Do you mean something like a sensor shield? They have three pins (Vcc, GND, signal), not four (because servos have three pins), but they are designed for connecting a large number of servos
These can be found easily and cheaply all over the internet.


text:
Micro + restricted user Win XP = avrdude: butterfly_recv(): programmer is not responding
I have a Micro (original) and I am (trying to) using it under windows XP.
I was successful in installing its drivers (by swithching to ad Admin account) and uploading sketches to it, no problem. Even when I switched to my limited account, I was able to upload new sketches without error.
But...
Everytime I reboot my computer, as soon as I connect the Micro to the usb port, I get a "New hardware found" popup window from Windows. If I ignore the window I do not see the board in Arduino's IDE. If I choose to install the drivers (by loggin in that window as an admin and then fetching them from the Arduino folder) I end up seeing the board, selecting the COM port and then when compiling, getting the dreadful
avrdude: butterfly_recv(): programmer is not responding

If I press the reset button I get the "Found new hardware window" again and the cycle repeats.
To make it work again I have to log off, log in in an admin user account, and install the friggin drivers from there. After that, if I log off and enter into my limited account, I can see board, port and I can finally upload my sketches (or at least that was the case the last two times).
Is it supposed to work this way?
Can I make it work like a Nano: install drivers only once and then just use the board?
PS
I have to mention that I happen to have 5 compatible Nanos with a ch340G chipset that work like a charm (and cost one tenth of the Micro). I installed the drivers ONCE and forgot about that.
I also happen to have a keyboard and a mouse, and they do not require me to install their drivers every time I plug the USB connector off.
Why is the Micro misbehaving this way?


text:
Send multiple sensor values over serial
I want to send a JSON string over serial from arduiono device to my computer. The JSON string contains a sensor value array. To fill this array I use String.concat("value") function. But If I have more than 100 values I get the JSON string with an empty array and an error message:
{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[],"landscape": PUF}
VMDPE_1|3147_VMDPE

Is there any other way to send more than 100 values in one message? The arduino device is running with a battery and the communication is wireless. So I want to save energy and reduce the send interval.
EDIT:
After reading the answers I updated my sketch:
Serial.print("{\"deviceID\":\"ZB_ROUTER_1\",");
    Serial.print("\"sensorID\":\"MMA8451\",");
    Serial.print("\"sensorType\":\"accelerator\",");

    Serial.print("\"aX\":[");
    for (int i = 0; i < samples; i++)
    {
        if(i != 0)
        {
            Serial.print(",");
        }

        Serial.print(xArray[i]);
    }
    Serial.print("],");

    Serial.print("\"aY\":[");
    for (int i = 0; i < samples; i++)
    {
        if(i != 0)
        {
            Serial.print(",");
        }

        Serial.print(yArray[i]);
    }
    Serial.print("],");

    Serial.print("\"aZ\":[");
    for (int i = 0; i < samples; i++)
    {
        if(i != 0)
        {
            Serial.print(",");
        }

        Serial.print(zArray[i]);
    }
    Serial.print("],");

    Serial.print("\"landscape\":\"");
    Serial.print(orientation);
    Serial.println("\"}");

In the xArray, yArray and zArray, there are 50 double values stored. One double value needs 4B. So that shouldn't be too much. But there are problems when I receive the JSON string on my computer:
{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[-1.17,-1.31,-1.26,-1.25,-1.16,-1.09,-1.40,-0.91,-0.94,-0.97,-1.39,-1.06,-0.91,-0.75,-0.78,-0.83,-0.72,-0.62,-0.74,-0.53,-0.82,-0.86,-0.84,-0.79,-0.79,-0.76,-0.83,-0.82,-0.97,-1.07,-0.92,-0.87,-0.97,-1.20,-1.51,-1.53,-1.82,-0.99,-1.04,-0.41,-0.54,-0.27,-0.24,-0.08,-0.02,-0.63,-0.{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[0.16,-0.04,-0.18,-0.03,0.01,-0.17,-0.10,-0.30,-0.31,-0.21,-0.16,-0.16,-0.15,-0.19,-0.17,-0.17,-0.17,-0.18,-0.16,-0.17,-0.17,-0.20,-0.18,-0.16,-0.17,-0.16,-0.15,-0.13,-0.20,-0.19,0.37,-0.88,-0.20,-0.05,-0.12,-0.21,-0.20,-0.17,-0.17,-0.17,-0.17,-0.17,-0.19,-0.17,-0.19,-0.16,-0.18,-0.17,-0.18,-0.17],"aY":[9.80,8.63,8.37,9.05,9.19,8.83,9.01,9.69,8.42,7.94,7.72,7.83,8.43,8.82,9.24,9.21,8.79,8.60,8.39,8.44,8.61,8.77,8.87,8.76,8.66,8.59,8.54,8.73,8.879,8.73,8.66,8.60,8.61,8.68,8.71,8.76,8.71,8.66,8.60,8.63,8.69,8.71],"aZ":[-4.81,-4..28,-4.02,-4.02,-4.29,-4.49,-4.67,-4.63,-4.46,-4.32,-4.28,-4.38,-4.42,-4.52,-4.58,-4-4.52,-4.52,-4.42,-4.39,-4.34,-4.40,-4.47,-4.51,-4.47,-4.44,-4.38],"landscape":" PDB{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[-0.18,-0.17,-0.19,-0.20,-0.18,-0.17,-0.18,-0.19,-0.19,-0.20,-0.17,-0.18,-0.17,-0.18,-0.16,-0.18,-0.18,-0.18,-0.17,-0.16,-0.19,-0.18,-0.17,-0.17,-0.16,-0.18,-0.17,-0.18,-0.18,-0.18,-0.16,-0.19,-0.17,-0.16,-0.17,-0.18,-0.17,-0.17,-0.17,-0.16,-0.17,-0.19,-0.18,-0.18,-0.17,-0.18,-0.17,-0.18,-0.17,-0.18],"aY":[8.67,8.68,8.69,8.68,8.68,8.68,8.66,8.68,8.69,8.69,8.69,8.67,8.69,8.70,8.68,8.67,8.68,8.69,8.69,8.68,8.67,8.69,8.69,8.70,8.68,8.66,8.67,8.67,66,8.76,8.80,8.98,8.99,8.76,8.46,8.37,8.55,8.71,8.80,8.85,8.74,8.59,8.58,8.64,8.70,8.44,-4.43,-4.43,-4.44,-4.42,-4.43,-4.43,-4.43,-4.42,-4.44,-4.43,-4.44,-4.43,-4.41,-44.13,-4.20,-4.44,-4.58,-4.68,-4.60,-4.41,-4.31,-4.29,-4.40,-4.50,-4.52,-4.48,-4.41,-{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[-0.18,-0.19,-0.22,-0.15,-0.15,-0.19,-0.23,-0.13,-0.16,-0.21,-0.20,-0.17,-0.15,-0.10,-0.16,-0.18,-0.24,-0.17,-0.12,-0.20,-0.28,-0.20,-0.13,-0.19,-0.21,-0.17,-0.18,-0.20,-0.19,-0.17,-0.17,-0.17,-0.17,-0.15,-0.18,-0.16,-0.18,-0.19,-0.18,-0.16,-0.17,-0.18,-0.19,-0.17,-0.19,-0.18,-0.17,-0.16,-0.17,-0.17],"aY":[8.67,8.55,8.61,8.73,8.82,8.73,8.66,8.54,8.54,8.60,8.67,8.60,8.77,8.88,8.79,8.57,8.60,8.51,8.79,8.72,8.83,8.72,8.66,8.68,8.79,8.76,8.67,8.58,75,8.78,8.63,8.63,8.70,8.79,8.77,8.72,8.71,8.67,8.67,8.66,8.70,8.70,8.70,8.69,8.66,87,-4.47,-4.45,-4.32,-4.36,-4.31,-4.41,-4.30,-4.37,-4.46,-4.42,-4.20,-4.39,-4.49,-4.4.40,-4.35,-4.36,-4.39,-4.41,-4.43,-4.40,-4.41,-4.39,-4.40,-4.40,-4.41,-4.42,-4.44,-4{"deviceID":"ZB_ROUTER_1","sensorID":"MMA8451","sensorType":"accelerator","aX":[-0.19,-0.18,-0.18,-0.17,-0.17,-0.18,-0.18,-0.17,-0.19,-0.18,-0.18,-0.17,-0.17,-0.17,-0.18,-0.18,-0.18,-0.18,-0.20,-0.18,-0.16,-0.17,-0.17,-0.18,-0.18,-0.17,-0.18,-0.19,-0.17,-0.19,-0.19,-0.19,-0.17,-0.18,-0.16,-0.18,-0.18,-0.18,-0.19,-0.20,-0.18,-0.17,-0.17,-0.17,-0.18,-0.22,-0.18,-0.17,-0.17,-0.17],"aY":[8.69,8.68,8.69,8.68,8.69,8.68,8.69,8.70,8.69,8.69,8.70,8.68,8.69,8.69,8.70,8.70,8.69,8.67,8.66,8.62,8.73,8.80,8.79,8.75,8.68,8.57,8.60,8.66,8,8.67,8.66,8.69,8.62,8.67,8.76,8.75,8.71,8.71,8.70,8.66,8.67,8.66],"aZ":[-4.43,-4.4-4.41,-4.40,-4.41,-4.42,-4.43,-4.44,-4.47,-4.36,-4.30,-4.30,-4.39,-4.45,-4.51,-4.52,,-4.49,-4.42,-4.35,-4.32,-4.37,-4.38,-4.41,-4.42,-4.46,-4.43],"landscape":" PDB"}

Sometimes there is "aZ" missing, sometimes I get wired array values like 8.83.2 (values with two "."). Do I have to many Serial.print operations? The sending interval is 500ms.

How long is the String you intend to send, and how does it compare to the RAM size of the arduino device?

@DaveX I don't know the exact length. The string looks like the posted one. But I want to fill as many sensor values as possible in the "aX" "array". What is the common way to transmit such values?

I have had a very similar problem and the Arduino core team has accepted a change from me to facilitate this functionality.
It is a complex story so you may have to reread a couple of times.
1) Serial.print returns before the data is send over serial.
The first thing to realize is that when you do serial.print() the data is not actually send over serial.
When your code looks like
serial.print("I'm dead");
resetArduino(); //This method does not exists in the arduino core

The message "I'm dead" will not be send over serial. That is because Serial print does not wait until the data has been delivered.
2) There is a software buffer used for serial.
The second thing to realize is that when you do serial.print() the data is not actually send but is put into a software buffer. A interrupted routine sends the data from the buffer over the "transport layer" (like in the osi model) here the serial connection.
This buffer uses the same memory that your string is using. In other words you are storing the string 2 times. This is why I agree with majenko when he states

Don't use String. Don't use concat(). Just print each bit as a separate Serial.print() function call.

3) If the software buffer is full serial.print will wait
If you do serial.print and the software buffer is full the function will not return until all data is in the buffer.
In other words: If a sketch tries to send more data than is transmittable over the serial connection the behaviour of the sketch will change over time.
4) Serial is slow
115200 baut may seem lightning fast but it is slow compared to what your arduino can do.
In other words: if you send lots of data you will need to calculate wether the serial connection can handle that amount of data.
So how can you improve on the situation.

As majenko implied: Only use the buffer of serial.
Reduce the amount of data you send. Jason is not a good way to send lots of similar data over a serial line because you have to add the variable name each time. I have split my variable names from the data to do reduce the amount of data to send.
If you send bursts of data bigger than the software buffer; increase the buffer. This is the change Arduino core team accepted from me.you can set the define SERIAL_TX_BUFFER_SIZE for changing the send buffer size and SERIAL_RX_BUFFER_SIZE for changing the receive buffer size. The default is 64 which means 64 characters.
Only send changed data.
Preprocess your data so you can send less data

Thanks for sharing improvement suggestions. My target is to analyze the frequencies of the signals (FFT). I wanted to do that on my computer. I choose the JSON format, because I have a wireless sensor network (WSN). So I get sensor values from more than one sensor device. Thats why I need at least one sensor ID. The software buffer uses the RAM right?

Yes the sensor buffer uses RAM. just like String and char[].

Is there any other way to send more than 100 values in one message?

Yes. Don't use String. Don't use concat(). Just print each bit as a separate Serial.print() function call.

Maybe avoid doing the dynamic string manipulations?
Serial.print("{\"deviceID\":\"ZB_ROUTER_1\",\"sensorID\":\"MMA8451\",\"sensorType\":\"accelerator\",\"aX\":[");
for(i=0; i <10000; i++){
   if (! i==0) Serial.print(',');
   Serial.print(i);
}
Serial.print("],\"landscape\": PUF} VMDPE_1|3147_VMDPE");


text:
SN76489 - Ready pin not working?
I'm testing the SN76489AN chip with Arduino and I'm able to play the 3 tones I want etc BUT I don't understand why the READY pin is not working? The datasheet says the pin goes high when the chip is ready and low when it's busy with processing a command. But the READY pin is always low! I've got 2 brand new pieces of the chip and they both act this way. I've even tried to pull-up this pin but it didn't help. I see everyone is just using delayMicroseconds in their examples, so I guess it is a common problem but it's just strange... Is it a bug in the chip or what? Does anyone know?
Thanks!

Please post a link to the datasheet for the chip. How do you know the pin is always low? Do you measure it (and if so, how?), or is it a side-effect of the code? If the latter, please post your code using the code formatting markdown (four leading spaces). For help see Markdown help. You should be able to do this by selecting the code and pressing Ctrl+K to have your browser do this for you.

READY is open-collector. It will require a pullup-resistor. Test circuit in datasheet shows a 2kohm resistor.

Oh, so the pull-up idea was good, but I just used too big resistor. I haven't noticed the 2K resistor in the test circuit! Thanks @Mikael! (sorry I can't give you +1 here yet). Unfortunately this method is not much fuster than the version with delay. PS: @Nick, I have measured it when the chip was idle (when it should by high) and I am actively waiting for the pin to become high in a while loop.

@MikaelPatel, if you will copy your comment as an answer then I will be able to mark it as answer and close the question.

The READY signal is open-collector. It will therefore require a pullup-resistor. Test circuit in datasheet shows a 2 kohm resistor. You could try with that. Alternatively use the internal pullup resistor on the input pin but this may be too large (weak).
Cheers!

I had this problem, but the mistake was that I had missed the clock pin on my breadboard by one row, so there was no clock signal.


text:
Arduino: How to get the board type in code
I want to write a sketch that can be compiled on different Arduino boards.
I want to display on the PC which board is currently connected.
This means that the user connects the PC via USB cable to the Arduino/Teensy board in which runs my sketch and my sketch tells the PC via Serial which board is connected. On the PC runs my C# application which receives this data and displays it.
Therefore I need the board that has been selected when the sketch has been compiled:

I found the code on https://github.com/backupbrain/ArduinoBoardManager
but it does not give correct results (apart from the fact that several boards are missing).
Here a snippet from the code:
static const uint8_t BOARD_MICRO= 0x04;

....
#elif defined(__AVR_Atmega32U4__) // Yun 16Mhz, Micro, Leonardo, Esplora
  static const uint8_t BOARD = 0x04;
  static const uint8_t NUM_BITS = 8;
  static const uint16_t CPU = __AVR_Atmega32U4__;
  static const unsigned long SRAM_SIZE = 2500;
  static const unsigned long EEPROM_SIZE = 1000;
  static const unsigned long FLASH_SIZE = 32000;
#elif defined(.....

So this code gives the same result (BOARD = 0x04 = Micro) for Yun 16MHz, Micro, Leonardo y Esplora.
Is there any way to get in my C code exactly the string that the user has selecetd in the menu of the Arduino compiler?

If you're using the arduino IDE to build the firmware, there's no provision to pass a project-level #define to the compiler, aside from F_CPU ARDUINO and AVR_whatever. You may need to grauate to using a makefile to build, instead of arduinio IDE. Check the arduino.SE site, Nick and Ignatio have some good examples.

I cannot find anything interesting on Arduino.SE. (Is that swedish?)

@Elmue arduino.StackExchange.com is Arduino SE.

Ahhhh. OK. But arduino.se exists!

By “I want to display on the PC which board is currently connected” do you mean to display it when a compiled and uploaded sketch runs, or display it while a sketch is being compiled, or while the IDE is just sitting there with a particular board attached?  (In the latter two cases, board selection shows up in lowest line of the 1.6.3 IDE, but if you have an older or different IDE maybe not.) (If first case applies, do you want it to appear in the serial monitor?)

I updated my question to make it clearer. What I want is without IDE and without serial monitor. Just my sketch tells the PC via Serial: "Who am I".

Thanks to the help of Charlie Hanson and jantje I found the universal solution!
Because it is a pity that every Arduino programmer has to go through the same pain to figure out how to get the board name, I will offer my code to the public so everybody can just copy and paste it.
Here it is:
#if defined(TEENSYDUINO)

    //  --------------- Teensy -----------------

    #if defined(__AVR_ATmega32U4__)
        #define BOARD "Teensy 2.0"
    #elif defined(__AVR_AT90USB1286__)
        #define BOARD "Teensy++ 2.0"
    #elif defined(__MK20DX128__)
        #define BOARD "Teensy 3.0"
    #elif defined(__MK20DX256__)
        #define BOARD "Teensy 3.2" // and Teensy 3.1 (obsolete)
    #elif defined(__MKL26Z64__)
        #define BOARD "Teensy LC"
    #elif defined(__MK64FX512__)
        #define BOARD "Teensy 3.5"
    #elif defined(__MK66FX1M0__)
        #define BOARD "Teensy 3.6"
    #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY40)
        #define BOARD "Teensy 4.0"
    #elif defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41)
        #define BOARD "Teensy 4.1"
    #else
       #error "Unknown board"
    #endif

#else // --------------- Arduino ------------------

    #if   defined(ARDUINO_AVR_ADK)
        #define BOARD "Mega Adk"
    #elif defined(ARDUINO_AVR_BT)    // Bluetooth
        #define BOARD "Bt"
    #elif defined(ARDUINO_AVR_DUEMILANOVE)
        #define BOARD "Duemilanove"
    #elif defined(ARDUINO_AVR_ESPLORA)
        #define BOARD "Esplora"
    #elif defined(ARDUINO_AVR_ETHERNET)
        #define BOARD "Ethernet"
    #elif defined(ARDUINO_AVR_FIO)
        #define BOARD "Fio"
    #elif defined(ARDUINO_AVR_GEMMA)
        #define BOARD "Gemma"
    #elif defined(ARDUINO_AVR_LEONARDO)
        #define BOARD "Leonardo"
    #elif defined(ARDUINO_AVR_LILYPAD)
        #define BOARD "Lilypad"
    #elif defined(ARDUINO_AVR_LILYPAD_USB)
        #define BOARD "Lilypad Usb"
    #elif defined(ARDUINO_AVR_MEGA)
        #define BOARD "Mega"
    #elif defined(ARDUINO_AVR_MEGA2560)
        #define BOARD "Mega 2560"
    #elif defined(ARDUINO_AVR_MICRO)
        #define BOARD "Micro"
    #elif defined(ARDUINO_AVR_MINI)
        #define BOARD "Mini"
    #elif defined(ARDUINO_AVR_NANO)
        #define BOARD "Nano"
    #elif defined(ARDUINO_AVR_NG)
        #define BOARD "NG"
    #elif defined(ARDUINO_AVR_PRO)
        #define BOARD "Pro"
    #elif defined(ARDUINO_AVR_ROBOT_CONTROL)
        #define BOARD "Robot Ctrl"
    #elif defined(ARDUINO_AVR_ROBOT_MOTOR)
        #define BOARD "Robot Motor"
    #elif defined(ARDUINO_AVR_UNO)
        #define BOARD "Uno"
    #elif defined(ARDUINO_AVR_YUN)
        #define BOARD "Yun"

    // These boards must be installed separately:
    #elif defined(ARDUINO_SAM_DUE)
        #define BOARD "Due"
    #elif defined(ARDUINO_SAMD_ZERO)
        #define BOARD "Zero"
    #elif defined(ARDUINO_ARC32_TOOLS)
        #define BOARD "101"
    #else
       #error "Unknown board"
    #endif

#endif

You can even put this code into a new header file and #include it into your project.
P.D.
If you want to know additionaly to the board also the CPU model, search for the file avr_cpunames.h

another thing. instead of using "return "?";" when you don't know use #pragma warning board name is unknown

1.) I have replaced the "?" with an #error. 2.) I don't think that the strings are really a problem. You did understand that only ONE string will be compiled at the end? See my update that explains this above. The longest string is 11 bytes. If you need to optimize your code so much that you care about 11 bytes, I recommend to define an enum and return that instead of a string. Then your function will return one byte instead of 11.

3.) And what concerns the maintainability: It is sad that I have to write such a function. This should be already part of the header files that are installed with the compiler and should be maintained by the developers and updated with every new version.

2)I made a mistake when writing the remark on the size. I made a remark on that 5 hours ago. Sorry for that. 3)The maintainability is a problem. I have written very similar code in the past. I'm sure many others have as well. It is the maintainability why I prefer the "better IDE solution". I'm pretty sure all "better IDE's" will have similar solution as the one I mentioned in my answer. See it as a complement: You are outgrowing the Arduino IDE.

If you wrote a wrong comment, the best would be to delete it.

I like this solution.
Here's a suggested addition for the ESP8266.
#elif defined(ESP8266)
    #define BOARD "ESP8266"

note this is a windows mod something similar must exist on linux.
The first is quick and easy. Simply modify the platform.txt files you are using as described nelow. The draw back of this is that you will need to change platform.txt files with each release.
add -DBOARD=\"${build.board}\" to the recipe. This will allow for
   const char boardName[]=BOARD;

Which gives you the string "ARDUINO_AVR_LEONARDO" (for the leonardo) in boardName.
The second way is to switch to a better IDE (like already proposed by others). As the creator of the arduino eclipse plugin I would advice to use the arduino eclipse plugin. In the arduino eclipse plugin you do this as follows:
Right click on the project->properties->arduino->tab "compile options" put
-DBOARD=\"${A.BUILD.BOARD}\"

in the append to C and C++ field.
This will make the code above to compile
Adendum
I wasn't aware you wanted the "nice name". I'm not sure this can be fixed in the platform.txt in arduino IDE. In the arduino eclipse plugin change the fixe above in
-DBOARD=\"${A.NAME}\"

to get the nice name (for the leonardo "Arduino Leonardo") in the define Board.

Would the downvoter or anyone else please be so kind as to specify why this is answer needs downvoting?

1.) Yes, StackExchange should force everybody who votes down to write an explanation. (It was not my downvote) 2.) There is no need to use Eclipse to solve this problem. 3.) See my answer here.

Elmue, 1) thanks for agreeing :-). 2) I agree. The first part of the answer is how you can fix this modifying the platform txt so it works in the Arduino IDE. Your answer goes in more detail on how to fix this.No need to have eclipse or any better IDE for that. The better ide solution is mentioned because a Arduino ide needs to parse the boards.txt so it probably has this info somewhere and has the possibility to work without need for modifying the platform.txt. As I happen to know the arduino eclipse plugin very well I give an example on how to do this with this tool. 3)See my edit

Does Eclise also work with Teensy? What other advantages has Exclipse?

Yes teensy is supported by the arduino eclipse plugin but you'll have to mod the platform.txt (should be fixed in teensyduino 1.28)

The advantages: It is hard to say as there are so many. I personally like the click to see the code (when you ctrl click on a method you jump to the implementation/declaration of that function/variable; even if it is arduino core code). The call tree (Where is this used?) is a really powerfull view. Auto completion, the scope, multiple projects(=sketches) in one place, integrated version control ...

The original answer is out of date as new boards have been added.  The basic test is correct, but it's not clear where the list of boards come from.
If you locate the boards.txt file and look through it (eg. ~\Library\Arduino\hardware\arduino\avr\boards.txt on a Mac), each board will have an entry along the lines of <BOARD>.build.board=<NAME>, so for example, the MKR1000 would have a line:
mkr1000.build.board=SAMD_MKR1000
The corresponding #define can be generated by prefixing the <NAME> with ARDUINO_ so in this example, the following code will error for an MKR1000 board...
#if defined(ARDUINO_SAMD_MKR1000)
  #error

I asked a related question a while ago.
An internal *.h file exists which is created by the IDE, and holds in it the type of board that has been selected. The list of possible options is given in the linked question, but only for AVR boards. I believe the non-AVR list is much shorter.
It is simply a matter of adding some conditional statements to send the PC the correct information. A simple example:
//...within your code, perhaps during setup()...
#ifdef ARDUINO_AVR_UNO
    serial.println("UNO");
#endif
#ifdef ARDUINO_AVR_LEONARDO
    serial.println("LEONARDO");
#endif
// etc...

If you need to refer to the board type more than once in the sketch, use the following format:
//...BEFORE setup(), or otherwise in the global namespace...
#ifdef ARDUINO_AVR_UNO
    #define __BOARD_TYPE "UNO"
#endif
#ifdef ARDUINO_AVR_LEONARDO
    #define __BOARD_TYPE "LEONARDO"
#endif
// etc...

// within your code, wherever necessary:
serial.println(__BOARD_TYPE);

The latter is much tidier, even if you only need __BOARD_TYPE once, as it removes the cumbersome #ifdef chunk from your functions.
You will, of course, have to write one for each board that you expect your end-user could have, and you will possibly need to update this list as new models appear.

Thanks for your answer. It helped me lot. (See my answer here) But there is an error in your code. Instead of AVR_UNO it must be ARDUINO_AVR_UNO.

You might want to remove the semicolons at the end of your #defines; they are not C statements and do not need separators; in fact the separators will be inserted where the macros is used, link inside the parens of the println() function.  (If the semicolons are removed, this comment won't make sense to later readers).

For Adafruit boards, specifically a Feather M4, the following worked for me.
#ifdef _VARIANT_FEATHER_M4_
serial.println("Feather M4");
#endif

The exact names in the menu come from boards.txt file in your Arduino IDE (Arduino\hardware\arduino\avr\boards.txt). I think you would have to parse the file by yourself and find the detected board there.

Parse the file ?? And how do I know which one is selecetd in the menu?