text:
Arduino struggling to power a large LED strip
I'm building a word clock and its a grid of 20x20 letters, each with its own LED (I know, its absurd for just a clock). I've recently got the LED's on a strip. Its the WS2812B type, just like the neopixels. There are 3 rolls of 5m strips and a single 1m strip. When I tried to power the 1m strip, everything worked perfectly and all looked quite lovely. But when I tried the 5m strip (just one of them), this happened: https://www.dropbox.com/s/5w1lok6wa7dfvzd/IMG_0046.MOV.mov?dl=0
If you didn't see the video I recorded of it, for a second or two after powering the arduino (uno) on, it works as expected but not long after it all stops the colors and fades to red, sometimes it just instantly jumps to it, like the second time in the video. I don't know what happened but all I can guess is that the arduino is not able to power the strip properly. Any ideas on what I should do to be able to power a total of 16m of these strips?

Each LED needs 60mA. Do the math.

So that would be 24 amps right?

And now you know why they don't use 2812Bs for it.

So how in the world would I go about carrying that out?!

Use discrete RGB LEDs, and restrict them to 4mA per color. It will still be a lot of current, but far less than full 2812Bs.

I've already got the 2812Bs so it would not be ideal to change them, what can I do to make it work with what I have?

Don't run them with values higher than 50 per channel. That should keep the total current below 5A. Which will still require you to power them externally.

Alright then, so heres my thinking. The grid is 20x20, so if I have a power source every for every 2 rows (each one being 20 LED's so a total of 40 LED's for every power source). What do you think of that?

That will work, but it will still be 10 2.5A supplies.

Yeah, seems like the best option though, unless you have any other ideas I think I will have to go with that.

I'd still run them lower than full brightness. Most people can't tell the difference between 230 and 255 unless they're right next to each other, and even 100 is still decently bright.

Thats a good point actually. If I did that, is it easy to work out how much power it would need if the brightness were lowered?

The LEDs use PWM, so it's approximately linearly proportional to the value used.

Thats good to know, well thanks for your help, hopefully it will work!

@MatthewInglis according to the internet (http://web2.murraystate.edu/andy.batts/ps/PowerRatings.htm) a 250watt computer power supply would be able to supply 25A on 5V.

@MatthewInglis Just be warned that 1) with a duty cycle of 50%, instead of 24A you will have a 12A AVERAGE current; while this is the right value to pick for thermal considerations, if your power supply is not rated for 24A peak it won't work properly (because the instantaneous current will be always 24A). 2) using an ATX power supply can seem good but you COULD have some problems due to the fact that they expect some load on every rail. Usually the feedback rail is the 5V, so it should be sufficiently stable, but... Well, a dedicated 5V 25A power supply is better

WS2812 use around 1mA when they are off. So that's already 400mA with no LED lighted. USB can supply around 500mA. So you only have 100mA available.
Each led package has three colored leds inside; Red, Green and Blue. Every color will use around 20mA when fully turned on.
So you can only turn on 5 colors at full brightness at 500mA.
Using a 2.5A supply you could go up to 105 colors, or 35 leds full white.
This would be more than enough for a word-clock, as most leds will be off.

Thats not enough for our word clock, as I said in the description our clock is 20x20, which is 400 LED's

The point is that you aren't lighting all leds at the same time. The word clock is quite useless if all leds are on all.

You're trying to power a consumer which draws more current than the arduino could provide.
To fix this, you need an transistor and a ~5V battery (e.g. 4.8V NiMh, or a stronger batteries plus suitable resistors, to not burn out the leds)
Look at this (awesome paint) shematic to understand the principle.
The arduino will switch the transistor through S2 which then closes the circuit.
Through S1, the arduino can set the LEDs values.
Note that for savety, you should also set a diode between S1 and the LEDs, so the battery cannot burn out your arduino, if the LED strip is cheap made.
The reason why the behavior at your setup differs might be because of a capacitor on the arduino which works similar to a batterie (With extreme little capacity).
The capacitor might provide enough power to run the LEDs for a very short periode. After discharging, the capacitor needs some time to recharge and thus it may vary in effect.


text:
NRF24L0 wireless modules
I have two arduinos (one uno and another nano) with NRF24L0 modules attached to both and they are communicating between each other. All good.
However, I have a load of different ones and have switched them with the working receivers to test them but they just refuse to work despite the pinouts being correct.
Does the pinout vary between manufacturers or something else perhaps? What really perplexes me is that some of the modules I've tried are brand new (just taken out of the antistatic)
I have followed https://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/
Any help would be really appriciated. Thanks

The library probably works fine, but I'd still recommend that you'd either download the updated version through the IDE or from https://tmrh20.github.io/RF24/.

Second thing is that some modules are fake/counterfeits they do not work according to the specs in terms of registers, power usage, range, required decoupling and possibly in more aspects. See http://hackaday.com/2015/02/23/nordic-nrf24l01-real-vs-fake/ for more information.

I was having the same kind of problems (even with new modules) when supplying them by mistake with 5v instead of 3,3V. It even happened that the system was working fine for days after the communication problems due to wrong power supply started to appear.
Also many people have reported similar problems(sometimes communicating, sometimes not) with this module due to poor built-in decoupling especially when using relatively long cables between arduino and module. Just to make sure, put a decoupling capacitor near the module's power and ground pins.
(this is more of a comment but I cannot comment due to reputation.)

source: Stack Exchange

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

sort: votes


text:
Controlling dynamixel AX12 by Arduino
Actually, i would like to control   12 motors of AX-12 using Arduino .. I could control just 2 motors. However when i send a command to the 12 motors they don't move and one or 2 of them move randomly!
could you please help me to find solution of that ???
note :
I am using an external power with 12 Volts and 5 amp maximum

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


text:
How to use SIM908-C BY UNV shield
I have a shield with a SIM for GSM/GPRS communications and GPS module.
As visible in top-left corner its name is "SIM908-C EVB v1.0 designed by UNV".

I found some basic information on Arduino forum but they are discordant about baud rate so I tried different configuration: https://forum.arduino.cc/index.php?topic=302982.0
I tried to use several libraries (such as sim900 or tinyGPS) for GPRS communication or simply for getting GPS position, but without results. Shield not respond to serial commands at any baud rate.
Connections that I used:
shield <--> aruino mega
GPRS TXD <--> D2
GPRS RXD <--> D3
GPS TXD <--> D4
GPS RXD <--> D5
GND <--> GND
5V <--> VCC_MCU

Obviously I set D2..D5 in library according to TX/RX pins on shield.
I also tried with a simply code to send AT commands and... no results again.
Here is the code:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2,3);

void setup() {
    Serial.begin(115200);
    Serial.println("Begin");
    mySerial.begin(115200);
}

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

Shield seems to be well powered and connected to SGM net. Infact:

power led: is on
ring led: is on
net status: blinks one time in three seconds

Has someone used this shield? What is a good library to use?
Every help is very appreciated.

Have you tried other baud rates with this sketch? 9600, 19200, 57600, etc? Is your serial monitor set to "Both NL & CR" at the bottom? Explain the connections between the Arduino and the module.

Thank you for interest.
Shield not respond to serial commands at any baud rate.
Serial monitor is set to "Both NL & CR".

Dont connect the GPS pins for now. Try using the other hardware serial ports of the Mega like Serial1 instead of SoftwareSerial. You say the module is powered well. How exactly are you powering the module? Try using 4V/2A supply. Also connect the VccMcu pin to the same 4V source and level-shift TX signals from the Arduino to 4V.

OK, I'll try connecting TX1 <-> GPRS_RXD and RX1 <-> GPRS_TXD.
I'm using a 12V/1.5A power supply connected to the shield. Arduino Mega is connected via USB to computer.
I'm not sure what do you mean with "level-shift TX signals from the Arduino to 4V"

Surely you arent connecting the 12V supply directly to the shield? There must be some regulator in the middle? By level-shift, I mean using a simple voltage divider to reduce 5V signals from the Arduino TX line to 4V that can be used by the module. Does the module have any sort of datasheet about the voltages it supports?

From datasheet I find that power supply can be 5-18V and Vcc_mcu must be connect to level of serial port: I think that is correct to connect to 5V of Arduino.
I'm trying now (baud rate 9600) and with AT command I receive a response made by ten bytes:
65 (A)
84 (T)
13 (CR)
10 (LF)
13 (CR)
10 (LF)
79 (O)
75 (K)
13 (CR)
10 (LF)
It seems to work.
How to use GPS, now?

What did you change that made it work now? I havent used GPS with these modules before but I imagine another serial port is all you need. Download the sim908 AT command set.

I tried a lot of configurations: I don't know exactly what is different now.
I think that the main difference is the use of TX/RX native serial ports of Arduino Mega.

I thought as much. I had the same problem with a similar module and a Mega. Didnt work till I used Serial3.

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


text:
Will I be able to control stuff from anywhere in the world if I use a wifi shield like ESP8266?
Currently, I am using a Bluetooth shield, HC-05, which is working perfectly but there are two problems:

Only one person can connect to Bluetooth  at a time.
I have to be in a specific place to be able to control the lights.

I want to be able to control everything from anywhere in the world. I've thought about using an Ethernet Shield, but I'd prefer using a Wifi Shield if it can do the task.

Yes, but realistically only with the help of a well-engineered and maintained intermediate server on the publically visible Internet - drilling holes in your firewall to expose an esp8266 to incomming connection is a bit dicey even if you work around your ISP's likely attempts to prevent it, so you are better off having both the ESP8266 and the controllers be clients which make outgoing connections to a real server which passes messages between them.

answer on your comment on Majenko's answer:
(cannot comment due to reputation)

build a simple web server on your device and make sure it is accessible from a local network node (e.g. a PC).To do this open from a web browser the page ip:port where ip is the ip assigned to arduino (usually from your router's DHCP service) and port is the port which your web server listens to. This is configured in your arduino code. For an arduino Wifi shield you can find a tutorial for this step here
Now you have to set up port forwarding. This means that when somebody from the internet sends a request on your router, the router will forward this request on your arduino and not on another node on your local network. The nodes on your local network are individually recognized by their IP address. Port forwarding is configured per port, so you must set up port forwarding from a specific in-port to a specific ip,local-port combination. For example if your arduino has been assigned ip 192.168.2.10 and your web server listens on port 80, you can forward all requests from port 8080 to 192.168.2.10:80. This means that every request comes from the internet on port 8080 on your router (internet side) will be forwarded on your local node on ip 192.168.2.10 and port 80. Note that for simplicity in-port and out-port can be the same and they usually are. Port forwarding is configured in your router's menu and the exact procedure is different for every modem. Your best bet is to search google for your modem's model + port forwarding. If you succesfully configure this, then you will be able to load web server's page from a node outside your local network by visiting ip:port where ip is your router's internet ip and port is the aforementioned in-port. A simple page to see your internet ip is this.

These are basically the main steps to have access from internet. Further improvements could be:

solving dynamic IP issue (in order to access your arduino, you have to know your router's internet ip which can change by your ISP anytime. Buying a static IP or setting up a dynamic DNS solves this issue)
turning your web server to non web server (more advanced topic).

The WiFi shield connects your Arduino to your local network. What you then do with that network is entirely up to you.
Yes, it is possible.
Is it easy, though? Well, if you have to ask the question then for you it won't be easy. You have to know how networks work for a start. Routing, port forwarding, client-server models, etc.

Can you put me in the right direction?

If you haven't already, take a look at Blynk.cc's website. Blynk provides a (drag-and-drop configurable!) smartphone/tablet app and a number of skeleton programs for many platforms and interfaces including, of course, the Arduinos.
In brief, your Arduino program can report data to their server, and the smartphone app can read and display that, as well as send control signals back to your board. They make it simple to accomplish basic things and quite easy to expand it to do more. The ESP8266 is a good choice for a web interface, especially if you're using an Arduino Uno or other Atmega328p-based platform, because it takes about the least amount of the MCU's limited resources of any of the compatible network interfaces.
Because your Arduino program will be configured as a network client you will avoid the hassles and potential security issues of configuring your local network to allow access to internal server from outside. The Arduino sketch opens an outboud connection to their server, just as a web-browser would, so you won't need to "poke holes" in your router's firewall to let in your client and anyone else that wants to mess with your stuff.
(Note: I have no connection with them, but I think they have a strong platform for Internet of Things hobbyists and I use their stuff.)
Update:
Blynk supports Arduino WiFi, WiFi 101, CC3000, and ESP8266 w/original (AT) firmware. This device (Atmega328p with ESP8266) is logging temperatures from 3 DS18b20 thermo sensors to Blynk as I type this:

I have actually heard of Blynk. But I don't think they support wifi shield yet.

It is definitely possible to control anywhere from the World where internet is available.
As @forivaras noted, there are a few accidental complexities involved in the network setup. It is nothing specific to Arduino, these come from the fact how Internet works nowadays.
For start, I suggest using an ESP8266 module (instead of any other solution), which is connecting to a readily available 3rd party server (such as dweet.io and visualize with freeboard.io, or Adafruit IO, or IFTTT).
In fact, you don't need the Arduino at all. The ESP8266 is a way more powerful than an Arduino, and yuu can program it as if it would be an Arduino plus Wifi.
So the hardware comes for less than $10, and you can find ready made howtos on the web such as:
https://learn.adafruit.com/home-automation-in-the-cloud-with-the-esp8266-and-adafruit-io/introduction
This ensures a smooth start! Have fun :)


text:
Max double value or NAN as a sentinel value?
I am in need of a sentinel value to use to assign to a double variable initially.
0 or -1 won't work because these values are valid values in my computation and I need a value that will stand out.
Possible choices are:

Maximum double value
Minimum double value
NAN (I would also need a method to check is_nan as well)

How can I accomplish this in the Arduino language?

AVR GCC doesn't technically support double at all.

This is a matter of personal preference. I like NAN because it is almost
always obvious it cannot be a valid value.
You can test for the value being NAN with
isnan().

Right but do they exist in arduino language? The constant NAN and isnan() function (in standard c++ it's a std:: library function)

The link I provided is to the doc of the avr-libc. You can use NAN and isnan() with no prefix on any AVR-based Arduino. No need to explicitly include <math.h>, as the Arduino IDE does that for you (via <Arduino.h>). I do not know about the ARM-based Arduinos (e.g., the Due).


text:
Is a 9v battery appropriate for a piezo and 1 LED?
I'm making a basic "door open" detector that, when a door is opened, it turns on an LED and then sounds an alarm via a piezo.
This is controlled via a 5v Adafruit Trinket.
Is a 9v battery the correct thing to power this with, if the goal is to change batteries as infrequently as possible?

Here's the code, incase that's relevant.
#include <elapsedMillis.h>
elapsedMillis timeElapsed;

const int switchPin = 2;
const int ledPin = 1;
const int piezoPin = 0;
const uint32_t openLength = 5 * 1000L; // X seconds
int notes[] = {862,294,730};

void setup() {
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(piezoPin, OUTPUT);
  digitalWrite(switchPin, HIGH);
}

void loop() {
  if(digitalRead(switchPin) == LOW){
    digitalWrite(ledPin, LOW);
    timeElapsed = 0;
  } else {
    digitalWrite(ledPin, HIGH);

    if (timeElapsed > openLength){
      for (int n = 0; n < 200 ; n++){
        beep(notes[random(0,2)]);

        if(digitalRead(switchPin) == LOW){ break; }
      }
    }
  }
}

void beep(int delayAmount)
{
  for (uint16_t t = 0; t < 30*1000/2; t += delayAmount)
  {
    digitalWrite(piezoPin,HIGH);
    delayMicroseconds(delayAmount);
    digitalWrite(piezoPin,LOW);
    delayMicroseconds(delayAmount);
  }
}

UPDATE: I had a 9V plugged in to this for about 3 days before it used all the power in 9V. Is that an issue w/ voltage on the battery (i.e. I should be using AA's instead of a 9V)? Or does that point largely to some other inefficiency w/ the code or hardware?

Not the problem, but your notes[random(0,2)] will only be 0 or 1 (2 is never reached). But you have 3 values in your array.

Also, a quick/dirty fix could be to put the switch between the battery and the microcontroller (if it can handle the current/voltage). Then your microcontroller will only power up when the switch is connected ;). This way you won't drain anything when the switch is off!

@Paul Bah! Of course! It delays the reaction time a few seconds, since the micro has to boot, but not a big deal in this case. Genius!

If you use an Arduino withouth bootloader (or modify it) you can get an extremely fast startup time. Microcontrollers won't need to set up an OS (Or well, the bootloader waits for code to be uploaded).

@Paul Actually I just realized that what you mentioned won't work for my use case. It's a magnetic contact switch and I need it to boot when the magnets disconnect...which I believe can only be detected via software. I could be wrong, though: https://www.adafruit.com/products/375

hmm, yea that makes sense. Maybe pull the reset pin low through it? It's on the icsp header. I'm not sure on the power usage, but it's basically made for that (:

@Paul As far as I can tell, the Trinket doesn't have that pin (https://learn.adafruit.com/introducing-trinket/pinouts) in the same way the Uno does.

The pin labeled "rst" is suspicious (: check it's voltage when it's on. Should be "high" and the device will reset when pulled to GND.

@Paul Yeah, I was under the impression that that pin just basically triggered the same thing as pressing the reset button, which would just cause it to reboot over and over. That being said, I wired it up and while it did "reset", it didn't reduce voltage.

Reset would be caused by connecting it to ground/GND. And if you keep it like that, it won't start until the pin is released.

A couple things to note:

Get rid of the PWR LED on the Trinket so it's not always drawing current.
Sleep the MCU whenever possible, only waking on interrupts.
Converting 9V to 5V with an LDO (in this case, the MIC5225) implies a 55% efficiency, max, which isn't great. But at least the LDO has a low ground current.

Also, ask yourself if you really need a micro for this task.
If you want a ballpark for runtime, find the capacity of your battery, estimate your current draw, and see what your upper bound on runtime is.

Added an update w/ more info...wondering if I have a battery issue or a hardware/software issue.

@Shpigford With regards to your update, it's both. 9V is not an ideal battery (and a few AAs have a lot more capacity), and you could be sleeping almost all the time. Again, ask yourself if you really need a micro to accomplish this task.

You can power the Trinket (ATTiny85) from as little as 2.7 volt. So you could power it by connecting 2 (or 3) AA-batteries directly to the 5V pin.
Using a 9V battery means you would "throw away" 4 of the 9 Volts to get 5Volt. So you'd waste almost half of the capacity of the battery.
Also a 9V battery only has around 500mAh, where as an AA battery has 2500mAh.

Added an update w/ more info...wondering if I have a battery issue or a hardware/software issue.

Like i said, AA have 5 times the capacity. So if you now get 3 days with a 9v battery, AA would give you only 15 days.

authors: ธนากร อุ่นเรือน


text:
Can d2xx connect to an arduino mega 250?
I am trying to replace a device which used a FTDI chip (http://www.ftdichip.com/Drivers/D2XX.htm) to get USB to serial. I need some more code on the chip, so I want to use an arduino mega 2560 instead. However, there is quite a lot of software which talks to the FTDI-based solution, some of which is not maintained by myself.
Can I write a program for arduino mega which makes it look to the PC software like I am still a FTDI chip? I am somewhat concerned, because the FTDI requires special drivers, so any software will try to use this driver to connect to the arduino, which does not have a chip that is native to the d2xx driver.
Best,
Alex
PS: If I am not mistaken, arduino used those FTDI chips in the past, but switched to ATmega8u2 for arduino UNO, and to ATmega16U2 for arduino mega 2560.


text:
DS1307 RTC not working with CC3000 WiFi shield (I2C bus hangs)
I am trying to use a DS1307 (from Sparkfun, BOB-12708) with an Arduino Leonardo. I have connected the SDA, SCL, GND, and 5V pins from the RTC to the Arduino. However, with a CC3000 WiFi shield on the Arduino, the I2C bus hangs. Specifically, Wire.endtransmission() hangs, called by rtc.isrunning(). I have confirmed that it works properly on the same Arduino without the WiFi shield. I am using the ds1307 RTClib example for testing it.

Which CC3000 breakout exactly? This may be related to the fact that the CC3000 employs interrupts; they could be interrupting the I2C transaction. Post the code that combines the CC3000 and the RTC.

It's the CC3000 shield.

Adafruit and Sparkfun both produce CC3000 shields, among others. Which one is yours?

I have the one from Adafruit: https://www.adafruit.com/product/1491

It could be that the CC3000 interrupts are affecting the Wire library's behaviour since the latter is interrupt-driven itself.
Try disabling the CC3000 IRQ before calling rtc.isrunning() or any other RTC functions. First #include "ccspi.h" in your sketch. Then place WlanInterruptDisable() before any RTClib function call, and then WlanInterruptEnable() after the RTC function returns.
Even if this works, it may affect the functionality of the CC3000, since it increases the chances of missed interrupts. You can search for DS1307 libraries that employ SoftwareI2C instead such as this one. They should be better able to recover from the CC3000 interrupts.

As I've said in my OP, it doesn't work even with just the RTC example. Would CC3000 interrupts be messing with things even if the library isn't included?

No, it wouldnt. Somehow, I thought you meant that you used the examples together with the CC3000 code. How are you powering the CC3000? Directly from the Arduino?

The CC3000 is a shield, so yes it is directly powered from the Arduino which is powered by USB for testing.

Powering the CC3000 via USB can cause unreliable behaviour since USB can only supply so much current. Try connecting the shield to the Arduino with jumper cables and powering the shield separately with a 1A source, while connecting all the GNDs together.

I'm pretty sure a USB to wall adapter can supply a lot more current, correct? Might that work? I could probably also rig something up if it doesn't.

Yeah, a USB-wall adapter should be alright, but read the specs on the body, to be sure.

That seems to be part of the solution, but something is still not working and I can't debug it since it has to be connected to the wall. I've been using the builtin LED to debug it, but there's only so much I can do. I tried netcat + a simple CC3000 socket, but it hung on establishing the CC3000 socket on my computer power (expected) and I can't debug it well without Serial. I might look into using two arduinos to assist with debugging later (one with a CC3000 connected to the wall, the other connected to my computer, both connected to each other via digital pins).

It doesnt have to be connected to the wall. You could use 4 1.5V batteries in series to power the CC3000.

For some reason I thought you couldn't have both VIN and USB connected, looking at the documentation it would appear I am wrong. That will be useful. Thank you!

@PlasmaPower Sure. But I wasnt talking about powering the Arduino, only the CC3000. I used batteries for a while, through lots of tests, before they got drained.

I'm using the CC3000 shield, not the breakout however. Powering them separately would be either impossible or at the least very tricky.

Not necessarily. The actual connections from shield to Uno are only 7. Look here: https://learn.adafruit.com/adafruit-cc3000-wifi/connections. You can use male-female jumpers, if you have them. Also how are you connecting the RTC to the Arduino, with the shield on top?

I'm stuck with a Leonardo for now, which also requires the ICSP pins, so I'm not sure if that makes a difference. As for connecting the RTC, the RTC is a breakout of course, and it's connected through SCL and SDA (but currently I'm using SoftI2C).

Let us continue this discussion in chat.


text:
Intel Edison Program Deleted After Power Off
I just bought a new Intel Edison and flashed the newest Yocto 3.0 image. I uploaded an Arduino program from the Arduino ide which just constantly prints out numbers to serial.
After uploading the code, it works. After I unplug it and plug it back in and wait 2 minutes for it to power on, I open the serial connection and the Edison does nothing like I never uploaded anything.
After some research I found it is a problem with the firmware version 2.5 so I tried 2.1. I tried 2.1 and it still doesn't work. Am I doing anything wrong?
I am using the mini-breakout.

I'm having a bunch of problems like this.  I went back to 2.1, and that works, but your sketch can't have any code that uses Serial.  Serial1 is fine, but not Serial, or else the board hangs and your sketch won't autorun when you aren't connected via USB during reset.


text:
Simple Calculator
I'm trying to make a basic calculator with the Serial monitor but it doesn't seem to work.
int a;
int b;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available()) {
    Serial.println("First Number: ");
    a = Serial.read();
    Serial.println("Second Number: ");
    b = Serial.read();
    Serial.println(a + b);
  }
}

Serial.read() reads in only the first byte of the data from the serial.This is not what we want, We everything that the user has entered to be treated as an Integer and then read it into the variables. You should use Serial.parseInt() for the job.
See the modified program below:
int a;
int b;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  Serial.println("Enter the First number");
  while(!Serial.available()); // wait till the user has entered something
  a = Serial.parseInt(); // treat what the user has entered as an Integer and read the whole number
  Serial.println("Enter the second number");
  while(!Serial.available());
  b = Serial.parseInt();
  Serial.println(a+b); // Print the sum
}


text:
Error in using buttons to input numbers!
This is a mini project of mine, which is to be implemented in another.
Here, I'm trying to make arduino output numbers in the serial window based on the diff. buttons pressed(there are four of them in my case).
What I want:

the initial array is 0000.
if I press button one, then button three, the array should be 1010
if I press button one two times, and button 4 three  times, the
resultant array should be 2003......and so on.you might have got what
I'm trying to do here.   the problem is , all I'm getting is 0000,
ALL THE TIME.

My code is below, and I'm a newbie, so any corrections(+advice?) given would be greatly appreciated.
(Also I don't know where to print the output :P I did it in loop() so it keeps on printing it :P)
CODE:

//the buttons:

const int b1=8;
const int b2=9;
const int b3=10;
const int b4=11;
//variables to store previous button press and currend button press , used to eliminate switch bouncing
boolean pb1=LOW;
boolean cb1=LOW;

boolean pb2=LOW;
boolean cb2=LOW;

boolean pb3=LOW;
boolean cb3=LOW;

boolean pb4=LOW;
boolean cb4=LOW;

//variables to store numbers:

int w=0;
int x=0;
int y=0;
int z=0;

int var_array [4]={w,x,y,z};

void setup() {
  // put your setup code here, to run once:
  pinMode(b1,INPUT);
  pinMode(b2,INPUT);
  pinMode(b3,INPUT);
  pinMode(b4,INPUT);

 Serial.begin(9600);

}

boolean debounce1(boolean last)
{
   boolean current=digitalRead(b1);
  if(last != current)
  {
      delay(5);
    }
      current=digitalRead(b1);
      return current;
  }

boolean debounce2(boolean last)
{
   boolean current=digitalRead(b2);
  if(last != current)
  {
      delay(5);
    }
      current=digitalRead(b2);
      return current;
  }

  boolean debounce3(boolean last)
{
   boolean current=digitalRead(b3);
  if(last != current)
  {
      delay(5);
    }
      current=digitalRead(b3);
      return current;
  }

  boolean debounce4(boolean last)
{
   boolean current=digitalRead(b4);
  if(last != current)
  {
      delay(5);
    }
      current=digitalRead(b4);
      return current;
  }

void loop() {
  // put your main code here, to run repeatedly:
  cb1=debounce1(pb1);
  cb2=debounce2(pb2);
  cb3=debounce3(pb3);
  cb4=debounce4(pb4);

     if (pb1==LOW&&cb1==HIGH)
   {
      w++;
    }
    pb1=cb1;

    if (pb2==LOW&&cb2==HIGH)
   {
      x++;
    }
    pb2=cb2;

    if (pb3==LOW&&cb3==HIGH)
   {
      y++;
    }
    pb3=cb3;

    if (pb4==LOW&&cb4==HIGH)
   {
      z++;
    }
    pb4=cb4;

for(int i=0;i<4;i++)
Serial.print(var_array[i]);

Serial.println();

delay(500);

}

At first glance it looks like your problem is you have a fraction of a millisecond where the buttons are being read. The rest of the time you are stuck in a delay.

In your C program all the variables including the array occupy their own space in memory.  In the line "int var_array [4]={w,x,y,z};" all you did was create 4 more variables (elements of the array var_array) in memory and initialized them to the values found in variables (w, x, y & z) in a different part of memory.  So when you incremented the variables in memory pointed to by the names w, x, y and z... you did nothing to the variables in memory pointed to by the elements of the var_array.
For example, in this program:
main()
{
 int w=0;
 int x=1;
 int y=2;
 int z=3;

 int var_array [4]={w,x,y,z};

 printf("w %d x %d y %d z %d\n",w,x,y,z);
 printf("var_array %d %d %d %d\n", var_array[0],var_array[1],var_array[2],var_array[3]);

 w += 1;
 x += 2;
 y += 4;
 z += 5;

 printf("w %d x %d y %d z %d\n",w,x,y,z);
 printf("var_array %d %d %d %d\n", var_array[0],var_array[1],var_array[2],var_array[3]);
}

The output is this:
w 0 x 1 y 2 z 3
var_array 0 1 2 3
w 1 x 3 y 6 z 8
var_array 0 1 2 3

Notice how the array values do not change.
If you really want to do this, you need to make the array var_array an array of pointers and point each element to each variable (w, x, y & z).
For example:
main()
{
 int w=0;
 int x=1;
 int y=2;
 int z=3;

 int * var_array [4]={&w,&x,&y,&z};

 printf("w %d x %d y %d z %d\n",w,x,y,z);
 printf("var_array %d %d %d %d\n", *var_array[0],*var_array[1],*var_array[2],*var_array[3]);

 w += 1;
 x += 2;
 y += 4;
 z += 5;

 printf("w %d x %d y %d z %d\n",w,x,y,z);
 printf("var_array %d %d %d %d\n", *var_array[0],*var_array[1],*var_array[2],*var_array[3]);
}

Now produces this output:
w 0 x 1 y 2 z 3
var_array 0 1 2 3
w 1 x 3 y 6 z 8
var_array 1 3 6 8


text:
FHT doesn't work with the example code
I'm trying to use the FHT librairy from (http://wiki.openmusiclabs.com/wiki/ArduinoFHT). I used the example code provided on the link, which is the following :
#include <FHT.h> // include the library

#define LIN_OUT8  1
#define FFT_N     64

void setup()
{
  /*Turn off timer0 for lower jitter -
    delay() and millis() killed*/
  TIMSK0 = 0;
  /*set the adc to free running mode*/
  ADCSRA = 0xe5;
  /*use adc0*/
  ADMUX = 0x40;
  /*turn off the digital input for adc0*/
  DIDR0 = 0x01;

  Serial.begin(115200);

}

void loop()
{
  while(1)
  { // reduces jitter
    cli();  // UDRE interrupt slows this way down on arduino1.0
    for (int i = 0 ; i < FHT_N ; i++)
    { // save 256 samples
      while(!(ADCSRA & 0x10)); // wait for adc to be ready
      ADCSRA = 0xf5; // restart adc
      byte m = ADCL; // fetch adc data
      byte j = ADCH;
      int k = (j << 8) | m; // form into an int
      k -= 0x0200; // form into a signed int
      k <<= 6; // form into a 16b signed int
      fht_input[i] = k; // put real data into even bins
    }
    fht_window(); // window the data for better frequency response
    fht_reorder(); // reorder the data before doing the fft
    fht_run(); // process the data in the fft
    fht_mag_lin8(); // take the output of the fft
    sei();
    Serial.write(255);
    fht_lin_ou8[0];
    Serial.write(fht_lin_out8, FHT_N/2);
  }
}

But I get the following error:
fht_lin_ou8' was not declared in this scope
I canot resolve this probleme, ans help would be appreciate

There's three versions of the library on that site. I can't find that code you post in any of them.

Even the "program example" link is something different.

May be you should try to replace :

fht_lin_ou8[0];

with :
fht_lin_out8[0];


text:
Compilation fails with non-explicit error message
I have written the following code for a project comprising an ultrasonic
distance sensor, a buzzer and a few buttons. When the distance is less
than 60 cm, the buzzer rings and stops only when the appropriate
passcode is pressed.
When I try to compile it, I get:

exit status 1
  Error compiling for board Arduino/Genuino Uno.

This does not give the reason for the compilation failure.
My code is below, any help would be appreciated.
#include<NewPing.h>

int r;
boolean ctr;

#define TRIGGER_PIN  10  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     9  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

//the buttons:

const int SPEAKER=8;

const int b1=4;
const int b2=5;
const int b3=6;
const int b4=7;
//variables to store previous button press and currend button press , used to eliminate switch bouncing
boolean pb1=LOW;
boolean cb1=LOW;

boolean pb2=LOW;
boolean cb2=LOW;

boolean pb3=LOW;
boolean cb3=LOW;

boolean pb4=LOW;
boolean cb4=LOW;

//variables to store numbers:

int w=0;
int x=0;
int y=0;
int z=0;

void setup() {
  // put your setup code here, to run once:
  pinMode(b1,INPUT);
  pinMode(b2,INPUT);
  pinMode(b3,INPUT);
  pinMode(b4,INPUT);

 Serial.begin(9600);

}

boolean debounce1(boolean last1)
{
   boolean current1=digitalRead(b1);
  if(last1 != current1)
  {
       delay(5);
    }
      current1=digitalRead(b1);
      return current1;
  }

boolean debounce2(boolean last2)
{
   boolean current2=digitalRead(b2);
  if(last2 != current2)
  {
      delay(5);
    }
      current2=digitalRead(b2);
      return current2;
  }

  boolean debounce3(boolean last3)
{
    boolean current3=digitalRead(b3);
  if(last3 != current3)
  {
      delay(5);
    }
      current3=digitalRead(b3);
      return current3;
  }

  boolean debounce4(boolean last4)
{
   boolean current4=digitalRead(b4);
  if(last4 != current4)
  {
      delay(5);
    }
      current4=digitalRead(b4);
      return current4;
  }

boolean distance(int o)
{
  boolean control;
  if (o<60)
    control=true;
    return control;
  }

void loop() {
  // put your main code here, to run repeatedly:
  cb1=debounce1(pb1);
  cb2=debounce2(pb2);
  cb3=debounce3(pb3);
  cb4=debounce4(pb4);

     if (pb1==LOW&&cb1==HIGH)
   {
      w++;
    }
    pb1=cb1;

    if (pb2==LOW&&cb2==HIGH)
   {
      x++;
    }
    pb2=cb2;

    if (pb3==LOW&&cb3==HIGH)
   {
      y++;
    }
    pb3=cb3;

    if (pb4==LOW&&cb4==HIGH)
   {
      z++;
    }
    pb4=cb4;

    delay(50);
    unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds   (uS).

    Serial.print(uS / US_ROUNDTRIP_CM);
    Serial.print(" ");
     int r=uS / US_ROUNDTRIP_CM;

     ctr=distance(r);

  if(ctr==true)
    tone(SPEAKER,1000);

Serial.print(w);
Serial.print(x);
Serial.print(y);
Serial.print(z);

Serial.println();

delay(100);
if(w==1&&x==3&&y==3&&z==1)
  noTone(SPEAKER);

}

There is a reason. There is always a reason. You may just have to scroll back in the output panel to see it.
Tone.cpp:536: multiple definition of `__vector_7'
NewPing/NewPing.cpp:284: first defined here
collect2: error: ld returned 1 exit status

In this case it is that you are using NewPing.h and tone().  Both of them use the same timer.
You can't use both tone() and the NewPing.h library together without first making one of them use a different timer or no timer at all.  The easiest is the NewPing.h library. As it says in the header file:
#define TIMER_ENABLED true      // Set to "false" to disable the timer ISR (if getting "__vector_7" compile errors set this to false). Default=true

So edit that header file and set true to false for that line and it should start working.


text:
How can I connect mysql with Arduino using GSMshield
How can I include mysql.h library in IDE of Arduino to connect Arduino to mysql database by using GSM shield?

You add the line: #include <mysql.h> ? Your question isn't clear. I'm going to close this question. Feel free to edit it with new information. Thanks for your understanding and cooperation!

You can't. Arduino is too small to run libmysqlclient directly. There are few other solutions:

You can expose your database using REST API and call that.
Change hardware platform to Raspberry Pi - it runs full Linux system
Run your app on PC and call Arduino using some RPC library

You can turn on GPRS data connection on your GSM shield and perform HTTP GET or POST request to the web page script (for example PHP script), which in turn will access the MySQL database (write or read DB records). It is easier than implementing REST API.


text:
Arduino Clone - A request for the USB device descriptor failed
I was working with my arduino clone and that was working well till last night.
I was trying to add l298p motor shield and after a few times of testing without any achievement, my PC suddenly did not recognize the arduino.
The device status in device manager is :
Windows has stopped this device because it has reported problems. (Code 43)
A request for the USB device descriptor failed.

What should I do now??
My OS is windows 8.1

Is it a real genuine Arduino Uno or a cheap Chinese clone?

it is a cheap chinese one

Then most likely the USB interface chip has died. Buy a real Arduino next time.

how can i repair it??

By replacing the USB interface chip with one that works. Until the next time it dies. Cheap Chinese clones are false economy. You can probably still use it using an external USB to TTL UART adapter through pins 0/1.

I can  program the AVR 328p via ICSP but i can not program it via USB which is on the board. so the avr is working. there is an IC named ch340t ... is it the IC used for programming

I guessed there probably would be... that kind of chip is the absolute cheapest USB interface chip available. Cough in its direction and it dies. Look at it and it dies. Enter the same room as it and it dies. They are about as useful as a chocolate teapot.

I've got the same problem with a genuine Arduino Uno WiFi Developer Edition, probably because of a damaged USB cable. So you can fry the original too ...

You have a cheap Chinese clone with a CH340T USB interface chip.
These are notoriously bad chips. It will have died.
You can fix it (temporarily) by replacing the CH340T with another - though it's anyone's guess how long that'll last.
You can also continue using your board as it is now by either programming the chip directly through ICSP or keep using the bootloader but via an external USB to TTL Serial adapter connected to pins 0/1 + RESET (via a capacitor to DTR) as if it were a "breadboard" Arduino.
That's the price you pay for buying cheap Chinese clones. They may seem like a good idea at the time, but unless you are willing to treat them very much as a throw-away item they are not always the value they appear.
Next time buy a genuine Arduino or an Arduino compatible from a reputable manufacturer.

Solution for semi-bricked Pro Micro/mini-Leonardo clones:
The OP's question is ambiguous to as the exact Arduino device in question. My answer applies to the "Pro Micro" or "mini-Leonardo" since these Clones usually use the default Leonardo boot loader, not the modified Sparkfun version.
Note the the Pro Micro doesn't use an external serial to USB chip at all. So the "CH340T USB" argument doesn't apply here. The USB is directly wired to the ATMEGA chip in this case as it has built-in USB 2.0 support.
I've made two projects with these: I gutted an old keypad replaced with a Pro Micro Clone and turned it into a extended keyboard so I could get F13 to F24 keys plus some others, then a custom game foot controller (to 'Q' and 'E' lean in FPS shooters).
Problem, I went to update my Foot controller sketch and after over a year later I forgot my Arduino IDE settings. This time I must have used the wrong setting like "Sparkfun Pro Micro" 3.3.v 8Mhz when your clone is probably like mine a 5v 16Mhz model.
When I uploaded the sketch it failed and apparently corrupted the program Flash header or something.
The original code was still running (on pedal press my LED lit up) but the device now showed up as "..missing USB device descriptor.." type message in the Windows device manager.
Fear not, it's probably recoverable like it was for me.
First of all realize you DON'T set in the Arduino IDE the board to "Spark Fun Pro Micro", simply set it to the default "Arduino Leonardo".
That's the right board setting for these clones. The Sparkfun bootloader IS different, as it says on their site. If you uploaded their bootloader then it might work but that's an experiment for another time.
Now you will need to add a reset button to the right hand side of your board (with the micro USB plug pointing up). The pins are next to each other and are clearly labeled.
I found a mini-switch just right to fit into the header pins from my parts box. In a pinch you can probably solder two small insulated stripped wires as a makeshift switch, but it might make the following step harder which is timing related.
If you plug your Clone Micro back in, notice if you press the switch the Clone Micro will show back up as a Arduino Leonardo on a COM port for about 8 seconds, then fall back to the bad USB ID thing again.
Now in your Arduino IDE create a NEW sketch. Which will create a minimal program that you'll need to restore your Clone back to working order.
Hit the reset switch again and quickly in your IDE preset the "port" to the COM port that shows up. Don't worry it will remember it after the device falls back again.
Now comes the hard part. Unlike a real Sparkfun Micro you can't double tap the reset button for extra time, you only get the 8 seconds period.
In the IDE click the "Upload" button, wait about a second, then hit your reset button.
If all goes well, you will see the typical flashing programming LED success lights and you will have restored your Clone Micro! This might take a few tries depending on your timing.
The thing is to press your reset button slightly after you click the Upload button (or CTRL-U) else you will miss the time frame of the special bootloader reset phase.
Basically this is the directions given here, with a little more details:
https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide#troubleshooting-and-faq

The OP got some opinionated and pretty toxic responses for an open-source hardware device. Some common sense notes on the morality and ethics of buying Chinese clone devices:
First of all, at least this is not nearly as bad a situation of the Chinese fake chips, arguably the real scourge of the Electronics parts world.
Without spending too much time on the legal ramifications and not being a lawyer, it looks like most of the Sparkfun stuff is CC licensed. Although doubtful the license if for their original or modified software/firmware.
From the Arduino site:
"Arduino is an open-source hardware and software company". So the clones are apparently not illegal to buy in the USA (if this is the country of contention).
The reason a lot of people buy the clones is you can buy around three or more of them for the same price of just one Sparkfun Micro.
I've been an electronic hobbyist since the late 70's and part of the equation for me is getting a few extras because there is always that chance I'll fry something despite double if not triple checking my wiring.
I can make a project plus have some spares for the next time.
I wouldn't use it in anything mission critical, but so far the Clone has been working fine for me as a hobbyist.
These things being said, I'm a big fan of Sparkfun. They are a relatively small USA company that makes fun innovative products with helpful Youtube "how too" videos, etc. I'm all for supporting them.

Whilst your answer is interesting, I'm not sure where the Pro Micro is mentioned in the OP's question. They state that they are trying to add a shield so that implies an Uno/Mega, or something similar and they even state that their Arduino has a CH340T.

True, my mistake. It still does come up on top search results for "Arduino" + "request for the USB device descriptor failed", so I made some edits and will leave it here in hopes it helps someone with Pro Micro or Leonardo clone devices.

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


text:
Low current in a motor used in a line following robot
I'm trying to make a line following robot for my students, the problem is that I have not done any calculations (I don't know how).
The motor can't move the robot unless I connect it directly to the 9 V power supply, but when i connect the other compenents(arduino) in parralel to the same 9v powersuply the motor doesn't get enough current when put on the floor so it just freeze's.
Where do you think should i start ?
The transistor I used is: NPN C1815
the motor is a brushed dc motor

9V power supply as in PP3 battery?

yes a 6F22 general purpose 9v battery

Does the motor have any form of gearbox?

@Majenko i added a photo of the motor to the post

Make your life easer next time.  Use 2 continuous servo motors instead of 1 regular motor and 1 regular servo.  The continuous servos are as easy to interface (directly to an Arduino) as a servo.  Then drive & steer your robot like a tank (left and right throttles).

You should not use a 9v battery for a motor project - it lacks the power to deliver voltage under load.  Additional, were it actually to deliver 9v it would destroy a typical hobby servo, which is intended for 4.5v - maybe 6v.  You are also missing the base resistor on your drive transistor.

Noticed that there is no base resistor between transistor and Arduino output pin, you may have blown the transistor and/or output pin, if not try a 1K.

@ChrisStratton do you mean that because the battery is 9v thats why it lacks power ? more volts less power !! i don't understand what you meant.
for the transistor base i used a 1k resistor i forgot it just on the schematic, for the servo i'll use a voltage divider

i used a 1k resistance i forget just in the schematic

Most 9V batteries have 6 AAAA batteries inside. Those are relatively small batteries, and can therefor not supply a lot of current. They will also deplete very fast. A 9V battery has 1/5th the capacity of an AA. My suggestion would be to use 4 AA batteries. You have special holders for 4 AA batteries.

@Gerben 4x AA will give 6volts? That's already on the limit for the Arduino Uno input voltage. I've used a 9.6V 2300mAh rechargable pack (https://www.conrad.nl/nl/nimh-accupack-96-v-2300-mah-conrad-energy-stick-tamiya-stekker-206671.html) which is great since it can supply 1C (2300mA) for one hour. Or run 300mA the whole day (8 hour) and it's rechargable. And the voltage is 9.6V so it can power the motors directly and the Arduino through regulated input. So I think such a 9.6V 2300mAh pack is very well suited for use in school. Though you really shouldn't short it out!

@Paul. 9V > 6V! Though 6V is probably on the low side for the regulator to work properly. You could use rechargeable AAs, which would give around 4.8V. PS nowhere in the question it's said that the motor is actually a 9V motor!

No! A 9v pack with meaningful current capacity will destroy that servo unless the circuit is changed to place a moderately high power regulator in front of it.  Hobby servos as made to run on 4 NiCd or Alkaline cells, or in some cases 5 NiCd (even 5 brand new alkalines could be risking damage).  Also the sensor pullups should really go the Arduino's regulated voltage, not the raw batter voltage.

ok i solved this using gears, and two separate power sources (9v transistor radio battery)
i also used a 1.5 amp transistor for driving the motor
thanks everyone

You seem to have ignored most of what was said.  Do not use 9v "transistor" batteries for motors - not one of them, not two of them.  Do not power a hobby servo from 9v.

What is a 1.5 amp transistor?

@ChrisStratton i did use a voltage divider for the servo, and i used one 9v low current battery for the motor and a 9v for the arduino, thats what i have in hand, i also changed the transistor to another one with a max Ic current of 1.5 ampere! i didn't ignore anything of what was said i hope, (i'm in a remote area, if i buy the proposed battery it will take about a month to arrive, by then students will be at holydays..

Voltage dividers are not appropriate for power unless feedback controlled. Feedback controlled voltage dividers are called linear regulators.  You should not use lithium batteries for such a project, nor 9v, just get ordinary AA's.

ok @ChrisStratton thank you very much for the information about voltage divider, i've never heard of Feedback controlled voltage dividers, i'll do a search about it and i will buy AA's because i can find them easily. thanks again

I should have added that, when using the 9V battery, only the motor can be driven directly from it. The servo should have a regulated source (5V is okay). I'm not sure if the Arduino can provide enough current for the servo, but it will do I guess.

Due to only a tiny amount of gearing (what is it - 2:1? 3:1? something like that) your motor is operating near the stall point unless it is able to pick up enough speed (at which point it would smash into the nearest wall and pulverise itself).
Consequently it is drawing far more current from the battery than you'd like.  And that is, without the Arduino connected, about all the puny little PP3 battery can provide.  Add the Arduino etc into the mix and you are over-stepping your current budget by enough to mean the motor cannot start turning (the 1A stall current).
So what to do? Well, two options:

Use a bigger battery.
Increase the gearing of the motor.
(my personal recommendation) Do both.

Increasing the gearing of the motor will decrease maximum output speed, increase the torque, and most importantly, decrease the start-up current. The whole load on the motor will be reduced making it much easier to start.
By increasing the power of the battery (use a 2S or 3S Li-Ion depending on what your motor's voltage limits are) you have a much bigger current budget to play with.

ok, thank you sir, i will give your recommandations a try


text:
Include Git tag (or SVN revision) in Arduino sketch?
Is there any way to get the current Git tag/commit identifier into an Arduino sketch binary?
For normal desktop program development, you can pull some tricks with the Makefile (as pointed out in this StackExchange answer). However, there is no Makefile for an Arduino sketch. Right?
I could make a batch file that I run before every compile, but there is the very real possibility I will forget to run it, and incorrect version information is worse than no version information.
At the moment, I am using the preprocessor macros __DATE__ and __TIME__ to try and identify what version is running on the board. This works, but tracking backwards from a compile date/time to a source control commit is more guesswork than anything.

You could ditch the Arduino IDE and go for a Makefile-based development.

tracking backwards from a compile date/time to a source control commit is more guesswork than anything - why? Commits have the date in them.

@EdgarBonet I think that is what I am looking for! I will give that a try. If you post that as an answer, I can accept it.

Inspired by Cellie's answer, I investigated further and found a similar
method that can be implemented using the regular interface of the
Arduino IDE.
It appears that GitHub user Wackerbarth, while facing the very same
problem, opened an issue on the Arduino bug tracker:

It would be very useful to be able to add a recipe to the platform
  specification that is executed at the start of the build process.
  (pre-build)
In particular, my use case is to generate version strings which will
  be incorporated in the Rom image based on information extracted from a
  SCM repository.

He went on to submit a pull request for adding “hooks” to the
build process, which made it to release 1.6.2. See the documentation on
these Pre and post build hooks.
Here is how you can use this feature for including git commit
information into your program (tested on Arduino 1.8.5 / Ubuntu 16.04):

Save the following file under the name make-git-version, somewhere
in your PATH, and make it executable:

#!/bin/bash

# Go to the source directory.
[ -n "$1" ] && cd "$1" || exit 1

# Build a version string with git.
version=$(git describe --tags --always --dirty 2> /dev/null)

# If this is not a git repository, fallback to the compilation date.
[ -n "$version" ] || version=$(date -I)

# Save this in git-version.h.
echo "#define GIT_VERSION \"$version\"" > $2/sketch/git-version.h

Locate the file named platform.txt in the Arduino installation
directory (currently in arduino-1.8.5/hardware/arduino/avr for the
AVR boards). In the same directory, create a file named
platform.local.txt with the following content:

recipe.hooks.sketch.prebuild.1.pattern=make-git-version "{build.source.path}" "{build.path}"

In your sketch, include "git-version.h" and use it like so:

#include "git-version.h"

void setup() {
  Serial.begin(9600);
  Serial.println("This is version " GIT_VERSION);
}

Create an empty file in your sketch directory named git-version.h.

Note that the git-version.h in the current directory is only needed
for the first compilation. The real git-version.h will be in the
temporary build directory.

I struggled with Arduino (ESP32) versioning also.
To make it somewhat more practical and less error prone I made some scripts to assist this process.
Using these scripts is as easy as adding them to your sketch folder and adding
#include "gitTagVersion.h"
...
Serial.println( sketchVersion );

to your Arduino sketch.
That is all that is needed.
The output in the example above will be something like v1.0.0-3-gab3fb04.
That breaks down to tag v1.0.0, we had 3 commits since that tag, at commit ab3fb04.
HOW TO INSTALL AND USE?
There are 2 scripts involved, the first script is a replacement for the Arduino  Verify button.
Save it as verify.sh:
echo "const char * sketchVersion = \"$(git describe --tags --always --dirty)\";" > gitTagVersion.h
~/arduino-1.8.5/arduino --verify test.ino
rm gitTagVersion.h

And the second script replaces the Upload button.
Save it as upload.sh:
echo "const char * sketchVersion = \"$(git describe --tags --always --dirty)\";" > gitTagVersion.h
~/arduino-1.8.5/arduino --upload test.ino --pref custom_DebugLevel=esp32_none
rm gitTagVersion.h

Some things to note about these scripts:

The scripts REPLACE the buttons.
You won’t be able to use the buttons anymore, as these buttons don’t
generate the necessary version info from git.
Using them will result in this error:

fatal error: gitTagVersion.h:    No such file or directory

The scripts are hardcoded to use Arduino 1.8.5 and have to be updated
if you update your Arduino IDE.
These script only work in Linux with a vanilla Arduino install.
If you use Windows, or are on a Mac the scripts will not work.
To change the debug output (using the LOGx_ESP macros) on ESP32
builds, change the custom_DebugLevel in the Upload script to
esp32_xxxx, where xxxx is none, info, error, debug or verbose.

I posted this also on my blog and esp32.com

I would drop the -n in echo -n '";': it is customary in Unixland that text files (specially source code) end with a line feed. Also, you could replace the first three lines of each of those scripts by echo "const char * sketchVersion = \"$(git describe --tags --always --dirty)\";" > gitTagVersion.h

If you're using Platformio, add this in platformio.ini file
build_flags =
    !echo '-D GIT_VERSION=\\"'$(git rev-parse HEAD)'\\"'

And use it like this:
Serial.printf("Firmware version: %s\n", GIT_VERSION);

Check out relevant docs:
http://docs.platformio.org/en/latest/projectconf/section_env_build.html#dynamic-build-flags

I met the same problem and based on the previous answers I wrote this script for Arduino IDE. I'm using it successfully on different OSs for many months to now. In the repository, you can find the instructions to install it.

I'm not sure what the commit ID would prove. I use git for source control for my Arduino sketches, but a particular upload might be halfway between the previous commit and the next one. That is, the code on the board might not match any particular commit.
The date/time would at least identify approximately where in the commit stream the code is.
A possibility would be to run a cron job that periodically (say, every minute) updates a .h file with the current commit ID from the branch, and include that in the sketch.

It is true that you can be compiling with a dirty working copy, but at least you know for sure what commit you started with for that firmware. With just a date, you can't know for sure which branch was compiled, especially if multiple branches were updated at about the same time. And finally, using date/time leads to problems with time zones, lending even more ambiguity to exactly what was compiled.

If you say so. A "dirty working copy" could be anything. I'm not sure what the original commit ID proves. using date/time leads to problems with time zones - how many time zones are you in? I'm in one, personally.

I still work with friends from college, and we now live in different states. The time zone thing has bit me in the past, I'm not trying to be a jerk or anything. Knowing the original commit ID lets me know what branch the sketch came from, at least. I do agree that a dirty working copy can indicate anything, but generally it is close to the base commit.

People have made makefiles to compiler their Arduino stuff. I can't think of any really simple way of doing it, short of my suggestion of a cron job to update a .h file regularly.

Inspired by Edgar's Bash script, I wrote a Windows Batch script do almost the same in adition to copying HEX file from the temp build directory to the project directory and insert commit hash, date, branch name and tag to it's name. I wrote a short article on how to use GIT to manage firmware versions.
:: How to use:
:: Add this file to you Arduino project directory and add the following line to platform.txt from Arduino core files
:: recipe.hooks.sketch.prebuild.1.pattern = {build.source.path}\fw_ver.bat GIT {build.path} {build.source.path}
:: recipe.hooks.objcopy.postobjcopy.2.pattern = {build.source.path}\fw_ver.bat SAVE {build.path} {build.source.path}

@echo off

:: arg1 -> "GIT" print version, commit number, brnach name and commit date , "SAVE" copy the .hex file from temp build directory to project directory
set arg1=%1
:: arg2 -> path to temp build directory
set arg2=%2
:: arg3 -> path to project source files
set arg3=%3

cd %arg3%

FOR /F "tokens=* USEBACKQ" %%F IN (`git describe --match^=NeVeRmAtCh --always --abbrev^=7`) DO (
SET commit=%%F
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git show -s --format^=%%cd --date^=format:%%y_%%m_%%d %commit%`) DO (
SET date=%%F
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --abbrev-ref HEAD`) DO (
SET branch=%%F
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git describe --abbrev^=0`) DO (
SET ver=%%F
)
::Export to version.h
ECHO #define FW_VER "%ver%" > version.h
ECHO #define COMMIT_NUMBER "%commit%" >> version.h
ECHO #define COMMIT_DATE "%date%" >> version.h
ECHO #define COMMIT_BRANCH "%branch%" >> version.h

IF "%arg1%"=="GIT" (
@echo on
@echo version:%ver% Commit:%commit% Branch:%branch% Date:%date%
@echo off
)
IF "%arg1%"=="SAVE" (
@echo on
@echo Save fw_%ver%_%branch%_%date%_%commit%.hex to %arg3%
COPY "%arg2%\fw.ino.hex" "fw_%ver%_%branch%_%date%_%commit%.hex"
)

If you want to do Makefile-like tricks, one possibility is to use a
Makefile-based workflow instead of the Arduino IDE. There are a few
generic Arduino Makefiles floating around the Web. One quite popular is
Sudar Muthu's Arduino
Makefile. With it, you just
write a small per-project Makefile that sets a few variables and then
includes the generic Makefile. There is one limitation with this
approach though: the Arduino IDE normally modifies your .ino file before
submitting it to the compiler, in two ways:

It #includes <Arduino.h>
It writes prototypes near the beginning of the program for every
function you define.

Sudar Muthu's Makefile does include Arduino.h (it does not touch your
code, using instead the -include gcc option), but it does not write
the function prototypes for you. It is thus not 100% compatible with the
Arduino IDE.
Another possibility would be to completely write yourself a Makefile
that calls Arduino
Builder. This should be
100% compatible with the IDE.


text:
I want to begin with arduino programming
I want to start programming with the Arduino Uno, but I don't know where to start or what a good start is. I can program a bit in c#, but I red that you have to program in c++.
Any idea's where to start?
Thanks!

welcome to Arduino Stack Exchange. You should do some basic research before you ask a question. This question is a duplicate and a question that can be resolved with a quick Google on: "Arduino get started".

Also, you might pick up a book and/or starter kit, they'll get you started very fast!

Yes, you are right @Paul, but i wanted to know the opinion of other programmers.

Good point, it would be better to ask in chat then (I believe you can't use chat yet though) or look at the duplicate questions: http://arduino.stackexchange.com/questions/18206/how-to-get-started. You also should've stated that you were looking for opinions ;) Just take a little time to check out http://stackoverflow.com/help/how-to-ask

Sure, thanks for your tip! I will have a look at it.

The other suggestions are great.
If you want to make a more "academic" approach, I can recommend two courses on Coursera:

The Arduino Platform and C Programming
Interfacing with the Arduino

I've followed and completed these 2 courses, and I think they were great fun. They give a light-weight introducton to the Arduino, with only a little time consumption needed.

You can purchase some great starter kits too:
They're easy to search for, here's a few that popped up right away:
http://www.arduino.cc/en/Main/ArduinoStarterKit
http://www.amazon.com/Kuman-Project-Complete-Starter-breadboard/dp/B016D5KUHS/
And here's one that I own, and I've recommended to other people:
http://www.microcenter.com/product/458578/Arduino_Compatible_Maker_Kit_with_LCD_Display
If you have a microcenter or radio shack or Fry's in your area, they all stock a variety of different starter kits.

I would like to add that you should go with one of the kits that has a book/guide with projects along with it. With a heap of components, it can be very difficult to get started. If there are some fun projects included, it will really motivate better.

Welcome to the world of Arduino. You can start by going directly to the Arduino Site -> Learning & tutorials. Also the internet full of 100's, if not 1000's of information and tutorials.

Do you have an example of a good tutorial, one that you think is good

Google Arduino Blink Tutorial -> https://www.google.com/search?q=Arduino+Blink+Tutorial&ie=utf-8&oe=utf-8

@Safwan If i answered your question, please mark the answer as ANSWERED. Thanks


text:
Esp 8266 doesn't reply to AT commands
I am working on esp8266 module with arduino uno board.  This is my program.
#include <SoftwareSerial.h>

#define DEBUG true

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                             // This means that you need to connect the TX line from the esp to the Arduino's pin 2
                             // and the RX line from the esp to the Arduino's pin 3
void setup()
{
  Serial.begin(9600);
  esp8266.begin(9600); // your esp's baud rate might be different
   Serial.print("START");
  pinMode(11,OUTPUT);
  digitalWrite(11,LOW);

  pinMode(12,OUTPUT);
  digitalWrite(12,LOW);

  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);

  sendData("AT+RST\r\n",2000,DEBUG); // reset module
  sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
  sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80
}

void loop()
{
  if(esp8266.available()) // check if the esp is sending a message
  {

    if(esp8266.find("+IPD,"))
    {
     delay(1000); // wait for the serial buffer to fill up (read all the serial data)
     // get the connection id so that we can then disconnect
     int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns
                                           // the ASCII decimal value and 0 (the first decimal number) starts at 48

     esp8266.find("pin="); // advance cursor to "pin="

     int pinNumber = (esp8266.read()-48)*10; // get first number i.e. if the pin 13 then the 1st number is 1, then multiply to get 10
     pinNumber += (esp8266.read()-48); // get second number, i.e. if the pin number is 13 then the 2nd number is 3, then add to the first number

     digitalWrite(pinNumber, !digitalRead(pinNumber)); // toggle pin

     // make close command
     String closeCommand = "AT+CIPCLOSE=";
     closeCommand+=connectionId; // append connection id
     closeCommand+="\r\n";

     sendData(closeCommand,1000,DEBUG); // close connection
    }
  }
}

/*
* Name: sendData
* Description: Function used to send data to ESP8266.
* Params: command - the data/command to send; timeout - the time to wait for a response; debug - print to Serial window?(true = yes, false = no)
* Returns: The response from the esp8266 (if there is a reponse)
*/
String sendData(String command, const int timeout, boolean debug)
{
    String response = "";

    Serial.println(esp8266.print(command)); // send the read character to the esp8266

    long int time = millis();
    while( (time+timeout) > millis())
    {

      while(esp8266.available())
      {
        Serial.print("Coming");

        // The esp has data so display its output to the serial window
        char c = esp8266.read(); // read the next character.
        response+=c;
      }
    }

    if(debug)
    {
      Serial.print(response);
    }

    return response;
}

the problem is  i am not getting any output from esp module but arduino is transmitting the data.  power supply for esp is given by 3.3v regulator (LD3.3)feeding 12v from arduino power supply adapter  to regulator input .
TX esp to rx arduino
arduino tx to esp rx by voltage divider (R1=1k and R2=1.8k)
esp gnd  to arduino gnd
chpd and esp vin are 3.3v from regulator
Can anyone tell me where the problem is ?

I see you have plenty of debug traces sent to Serial, could you copy what you get on the serial console and paste it in your question? That could help checking out your issue.

I don't get any data from the esp device ,If esp data available from the device i am printing the response from serial terminal.. But No data coming

This is not actually what I asked: there are lots of Serial.print() in your code, it would be interesting to show exactly what gets printed to the serial console right from the start of the program.

Also, I am surprised by the baud rate used to talk with the ESP. In newer versions, the default rate should be 115200, not 9600.

Try powering the ESP from an external 3.3V power supply if possible - some people say the Arduino 3.3V regulator may not provide enough power for it (it is quite power hungry at startup).
Another option worth trying is to put a 100uF capacitor between ESP VCC and GND. Put some small delay at the beginning of your setup() function if you do that just in case.
Also, there are several pins you need to pull UP: CH_PD, RESET, GPIO0. If you have GPIO15 broken out (depends on the board), pull it to ground. I have also noticed the ESP won't boot properly if GPIO2 is LOW - either leave it floating or pull it up.
Here is a picture you can use as a guide
Of course, you should make sure the ESP is flashed with the AT commands firmware (they usually are) and your baud rate is correct. If you don't know - try 9600, 57600, 115200.
If you have a USB to TTL converter, it might be better (easier) to test your setup using it, without Arduino. Any serial terminal program (including Arduino IDE Serial Monitor) will be fine. Just make sure you send both CR and LF for new lines. If you send "AT" and receive "OK" your wiring is correct, if you don't - it is not.


text:
Nano clone not working over USB, no data, no power, but can power via Vin (CH340 chip? schottky diode?)
My quite new Nano clone (ATmega328P + CH340G) suddenly stopped working. Plugging it in with USB did not light up the LED(s) nor did it get detected by my machine. I looked it up, and found some how-to's (such as this one: Repair Arduino Nano (no power on USB)), which suggested at least some diagnostics.
So I plugged the Nano in to a 5V breadboard power source using the Vin and GND pins, and the power LED lights up, but connecting via USB cable to my machine does not detect it.
So then I used some of the methods mentioned in the link, and used just a normal jumper cable (without soldering) to check if that could magically make it detectable by my machine. No luck. I tried bypassing the voltage regulator by "jumping" over it, and the power LED gets brighter, and "pin 13" LED flashes for just an instant. The same occurs if I "jump" the voltage regulator all the way to either end of what I am guessing is the "Schottky diode".
In all cases, still nothing in terms of being detected by my computer. The cable is fine because I tested with another nano clone, and it gets detected right away.
So, how do I properly diagnose what is going on here? Specifically how do I fix my poor board? How do I find which component is in need of replacing?

Update:
I found some online guides on how to have another Arduino board talk to this one over SoftwareSerial and found that I could get some data flowing through. However, the text was garbled, such that, for example if I was expecting it to say:

"Please enter some input"

It might read instead:

"Ulease XYZter some [][]put"

Often with the same characters being garbled in the same way. I tested the Schottky diode the way it was suggested in the video (with some guessing as to the multimeter setting I had to use was, since I have a different model than the one in the video), and it seems the diode is fine. So at this point I am guessing it is the ch340g chip that is toasty, either that, or the ATmega chip itself, which I don't know, but that sounds less likely.
So, could it be that it is the CH340G chip, since I get no power over USB, and the TX/RX over serial is being interfered with? Is there anything else I can do to figure out if it is the CH340G that's damaged before I go about trying to replace it?

First you (and we) need a schematic of the board. Without that you're just stabbing in the dark.

If you can't get one, then you will have to trace the flow of power around the circuit using a DMM.

Splash out as spend another $2 on a new clone. The same happened to one of my clones and it is still programmable via ICSP. (NOTE before I get any comments no official "Distributor" in Australia stocks genuine Nano.)

Some clones do not ship with a bootloader. They are basically unusable from the perspective of USB-based programming, until a bootloader is flashed. The only way to do flash a bootloader is to do spi programming, either with a ready-made programmer or with another arduino properly setup. The basic SPI programmer is 5-8 bucks on ebay.

Of course you can use another working one as an ISP to flash the bootloader and fuses.  Checking the voltage on both sides of the diode is a good idea.  Also make sure there are no hairline cracks in the soldering of the surface mount mini-USB connector.  The irony is these are often sold for less than the per-piece price of the ATmega!

@Majenko, I found this: https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf but it would be a ch340g instead of a FT232RL, I believe.

@IgorStoppa I was able to use this board no problem, uploaded several sketches etc, just as I could the other nano clone, and my UNO clone. There should already by a sketch in there from the last time I uploaded one, unless even that got somehow fried off.. is your SPI programming suggestion applicable to this situation?

@ChrisStratton Do you have a link that details how to do that? I'm pretty new to all this stuff. I do notice the mini USB connector is just slightly different at the back than the other clone, but I'm not sure how to tell if this is what is causing the problem, or has anything to do with it.

The Arduino site has a tutorial using a Uno as an ICSP programmer. All you need in addition is a few jumpers and a capacitor. PS my fried Nano clone still powers from USB - using a plugpack, but won't from a PC - presumably because the ch340g is fried.

You could try pushing down on the back of the connector and seeing if that helps.  It's worth the $7 or so to get a 10x jouler's loop for inspecting solder joints.  You can also just try fluxing and resoldering it, but it can be hard to get an iron in there on some of the connector styles.  Resolder the mounting tabs first, in case those are loose.  With some mini-USB's you can carefully break off the back of the shield to get more room to access the pins with an iron.

I don't believe the CH340 is involved in the power situation except possibly for the secondary 3.3v supply which you don't mention using.  USB is 5V power, the board runs at 5V.  If your USB 5V input is not working, and the diode is fine, I would suspect either cracked soldering of the connector, a damaged connector, or a bad cable.  I would only be inclined to suspect the CH340 if the host complains about a USB device drawing excessive current and shuts down the port.  You could carefully measure the voltage on both sides of that diode with respect to ground while the USB is connected.

10x jeweler's loupe ...

Either you have a cable problem or that board is just not working well.
What you call the CH340 chip - when they go bad you get power but NO communications, in my experience.  You can test voltages at the various points like 5V, 3.3V, etc., to see if it getting power.  If it is and you're still not communicating, then if it were me it would go on the shelf for the kids to see.
It no longer can trusted.
Rather than troubleshooting the board it would be worth getting another to compare with.
And if you have more than one cable on hand, try them and see if there are any differences.
But my prediction is that a new board will work and this one will continue to not work.


text:
Using Arduino UNO to retrieve ATMega328P-PU chip signature
Good day.
I have successfully built and tested an Arduino-on-breadboard about 2 days ago.
The device is rather straight forward, I have added a voltage divider and an LED to indicate power.
The schematics are as follows:

And this is a picture of the actual board:

I am using an ATMega328P-PU as a Microcontroller chip.
I uploaded quite a few sketches on the board and all seemed to work well. I was trying to upload a sketch yesterday but I got:
 "avrdude: Yikes! invalid device signature".
I rebooted the computer, rebuilt the entire board again, and tried once again to load a sketch using Arduino as ISP. The message changed again to:
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.
Wrong microcontroller found.  Did you select the right board from the Tools > Board menu?
I did a search online and I have found many forums suggesting that I change the avrdude.conf file parameters to different signatures "Although these are mainly targeted at people using ATMega328-PU, not ATMega328P-PU" but this also did not help.
I tried burning the bootloader again but I still get the same error message.
I tried to find a way to "retrieve" the chip signature, but I didn't.
I know that there is a chance that I have bricked the chip somehow, but how do I know for sure? and is there anyway that one can use and Arduino as a tool to retrieve the chip signature or verify if the chip itself is dead?
Thank You

In the arduino setting enable verbose output. After that the device signature should be visible, along with a whole lot of other information, when you try to upload.

There are two easy ways than that Method 1 - Using Atmel Studio Click-here Method 2 - Without Atmel Studio Click-here I Did using method 2 successfully .For method 2 if your are using Atmel Studio 7.0you need AVRISP MKII firmware 1.18 Download-Here If above webpages not available you can get those in PDF format below from my google driv

There is a nice explanation here about Atmel chip signatures.
It sounds like you already know this, so for others looking for help:
It says that there are different signatures in the Atmel chips you mention.  That you can over ride the Avrdude program using an "-F" switch.  Or you can change the Avrdude configurations to use the "other" Atmel chip (however, the consequences if any were unknown by the author).
This may be an obvious step, but double check to make sure the IDE's target board settings are correct.
You may also want to check the communications between the programmer and the target.  You might look into dropping the speed.  But the better way is to scope the lines to see if data is being sent to the target and if the target is talking back.  From that you can infer if the problems is a bad connection or if the chip has been damaged.
If you want to dig further using software tools you could look into driving Avrdude for your self.  There is a easy to read tutorial here and what appears to be an everything you wanted to know and more document here.
In the 1st tutorial (from ladyada.net) we see a test which they purposely try the wrong signature:

Just for kicks try running this command avrdude -c usbtiny -p atmega8
  -U flash:w:test_leds.hex

You'll see that it stops at step 2, once the signature is different
  than the expected one it stops. This is because code that is compiled
  for an attiny2313 wont run on an atmega8 (this is true of most
  microcontrollers, the .hex files are not cross compatible)

But more interestingly, Avrdude prints out the signature read back from the target!  So, if you run the same test, you could tell if Avrdude is able to communicate at all with the target.  That is, you may see all zeros or all ones or even an alternate message from Avrdude. Which could be an indication that the target is not talking.

Thank you for the detailed answer. I have accepted the answer as it did point me to some very interesting findings. One of the findings is the fact that even a "Briked" ATMEGA328P-PU or any AVR chip for this matter can have it's "Virginity" restored according to This Post

More than a year down the road, I learned a few things, and I am answering my own question so that if anyone faces the problem I faced (and I know how stressful it is) can give this a go. It may help.
One of the most interesting things I have learned is Mr. Nick Gammon's (Someone have actually called him Mr. Arduino) wonderful collection of sketches designed to do exactly this sort of thing.
If you ever need to find out what is the signature of your ATMega328 (or any arduino micro controller chip for this matter, visit this site.
The main reason I asked the question was to "un-brick" my ATMega328s, and I have actually done some thing wrong that to this day I can not figure out that resulted in 4 chips giving the error in the question. Just when I was about to give up, I found this link from Mr Gammon's website which sorted out the problem in 3 out of the 4 ATMegas, the fourth I am keeping to test a high voltage programmer in the future.
Thank you.

when you try to change the signature there are 2 areas where the code 1E 95 0F is displayed. If you try changing the signature in the wrong position, then will it show the error message 'microcontroller not found'. I did the same mistake once. I would suggest you rely on the find option in the Edit menu and search for the code.
Edit > Find > Search 1E 95 0F > ( opt for 'down') search next.


text:
How to not wait for USB to become active?
EDIT: My original question was a bit "off" since the Arduino Nano I was using appeared to be faulty. This edited question is based on my other Arduino Nano which is working.
When I plug my Arduino into the PC, it keeps blinking it's LED until I open the Serial Monitor.
After opening the serial monitor the Arduino will start to execute my code.
How can I get my Arduino to "not wait on a connection", or simply put, start whenever it receives power.
I believe it's the bootloader which somehow doesn't time-out (I'm not sure if that's how the bootloader works).
The code below (though I don't see why this would make it hang until a connection):
void setup() {
  // put your setup code here, to run once:
  Serial.begin(256000);
  Serial.write("Restart");
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {
    incomingByte = Serial.read();

    // say what you got:
    startSend();
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
    stopSend();
  }else{
    startSend();
    Serial.println("I'm still standing");
    stopSend();
    delay(400);
  }
}

(Code is only for testing purposes)

It's likely people will need to see your code (sketch) in your question in order to help.

I've just changed board, and it seems to work a lot better. But it still seems  Arduino won't start until I open the serial monitor.

After you post your code this answer may not apply.  But, guessing, you may benefit from changing your code from:
loop()
{
 data = Serial.read();
 // Do other sutff
}

To something like this:
loop()
{
 if(Serial.available() > 1)
 {
  data = Serial.read();
 }
 // Do other stuff
}

Hmm, it appeared to be some vague hardware problem. My CH340G board runs fine, the FTDI (from China) doesn't, I think it's a fake.

And, the code won't upload while I have it connected to the MAX485, I think it might "drain the bits".


text:
Possible to "inline" PROGMEM strings into a structure array initialization?
I have the following structure:
struct inst_t {
    const char *s1;
    const char *s2;
};

I'd like to initialize a constant array of this structure like this where all the strings are PROGMEM'ed:
const char START[] PROGMEM = "START";
const char ATZ[] PROGMEM = "ATZ";
const char ATE0[] PROGMEM = "ATE0";
const char OK[] PROGMEM = "OK";

static inst_t insts[] = {
    { START,      NULL },
    { ATZ,        OK },
    { ATE0,       OK }
};

You can see there is a lot of duplication here though. Is there anyway way I can inline the PROGMEM strings directly into this array initialization without separately declaring each string as being in PROGMEM?

If the strings are similar size you can, like this:
const int NUMBER_OF_ELEMENTS = 10;

typedef struct {
   char description [12];
} descriptionType;

const descriptionType descriptions [NUMBER_OF_ELEMENTS] PROGMEM = {
 { "Furnace on" },
 { "Furnace off" },
 { "Set clock" },
 { "Pump on" },
 { "Pump off" },
 { "Password:" },
 { "Accepted" },
 { "Rejected" },
 { "Fault" },
 { "Service rqd" },
 };

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();

  for (int i = 0; i < NUMBER_OF_ELEMENTS; i++)
    {
    // make a copy of the current one
    descriptionType oneItem;
    memcpy_P (&oneItem, &descriptions [i], sizeof oneItem);

    Serial.println (oneItem.description);
    }   // end of for loop

  }  // end of setup

void loop () { }

This is a bit wasteful of program memory, because you need to allow for the largest string (your example had them all similar sizes) but what you save is not needing a two-byte pointer for each string, so if they are all similar lengths, it will take about the same memory.
See my page about PROGMEM.


text:
Ways to implement touch sensitive surface?
I'm building a tic tac toe board for my kids where tapping on a plexiglass surface in any one of the 9 squares would light it up.
What are some ways I can pull off making each of those 9 squares touch sensitive?
Doesn't need to be anything fancy, but the kicker is that it can't be something attached directly to the plexiglass surface (as that'd obscure the LED light underneath).
Current thinking is buy a sheet of this pressure-sensitive conductive material and cut it in to squares, then somehow transfer pressure form the plexiglass down to the square on the bottom of the box, but I may be overcomplicating it.

Can the nine squares of plexiglas be configured as floating items, perhaps secured along only one edge? If so, you could place a pressure sensor under each of the nine pieces. The illumination need not be directly under the plexiglas and can instead be mounted to provide an edge-lit panel. You would want adjacent tiles to be painted black on the edge to prevent cross-illumination. There are a number of such sensors on Adafruit, but the more practical unit is seven dollars. You may be able to use the sheet stuff and create something that works.

If you have to have under-tile lighting, you could have through-hole standoffs that pass the force under a substrate to the conductive material. I think your question is more engineering than arduino, but it should be easily resolved.

Transparent touch sensitive surfaces are usually based on parasitic capacitance like on an iPhone.  While you can buy loose glass touch surfaces, it is difficult to use such devices if not already attached to an LCD.  The same is true for the much cheaper resistive touch surfaces like on a Newton.
If you are already using LEDs, I would suggest investigating using the LED to detect the light from the reflection of a finger.  I found people talking about this here, here and here.
I believe this is a still from a video that someone else made using this technique:

For your tic tac toe box I could see touching a location for X's or for O's.  Then touching 1 of 9 boxes you would want to place the symbol in.
Added later...
As @Gerben pointed out there are other options.  I like solving hardware problems in software.  And reversing the potential on an LED then sampling the voltage over time is a snap to implement on many modern embedded processors.
If you are open to hardware solutions, microchip.com makes a chip which projects an electrical field in front of a PCB for 3 dimensional gesture recognition.  However, the PCB layout is touchy.

Also, there are gesture sensors that (probably) use IR radiation to track movement.  Here's one that supposedly does X Y & Z as well as sense colors.  And it sounds like there is already an Arduino library written for some simple gestures. Looks like there's a YouTube video as well.

I'd probably use some dedicated IR reflective sensors, instead of using the leds you are driving. That would make things a bit easier, and probably more accurate.