11

How do I ask a good question about the Arduino?

We’d love to help you. To improve your chances of getting an answer, here are some tips:


Search and research

Have you thoroughly searched for an answer before asking your question? Sharing your research helps everyone. Tell us what you found and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and above all, it helps you get a more specific and relevant answer!

If you ask something like how to connect neopixels to arduino and we know that Google has 77,000 hits for that question, we won't be very interested, unless you explain how your problem differs from the usual ones. Include a couple of links from pages that you have researched, to show that you have done some homework, and then describe your problem.


Be on topic

On topic:

  • Specific questions about Arduino boards, code, and the Arduino IDE. Feel free to ask about anything related to Arduino.
  • Questions about other IDEs, clones/counterfeits/derivatives, and other coding languages for Arduino. Feel free to ask about any language for coding Arduino.
  • Board recommendations. Make sure to include detailed information about the project you are doing and your requirements. If your question is too vague, it may be put on hold.
  • Library recommendations. Make sure to include detailed information about the requirements. If your question is too vague, it may be put on hold.
  • Code review: Use the tag project-critique for advice on how to improve your code/project.

Off topic:

  • General Coding: If your question is about coding not related to Arduino, try Stack Overflow

    • If the solution would be the same with or without Arduino, then it's usually a general coding question.
  • General Electronics: If your question is about making electronics or other electricity questions not related to Arduino, try Electrical Engineering.

    • If knowledge of Arduino would improve a question, it's on topic. Otherwise, it might not be a great fit for our site.

Make a meaningful title

Try to summarize your problem with a helpful and informative subject line. Helpful subjects draw in people who might know the answer. Unhelpful ones are likely to be skipped.

Examples of unhelpful subject lines:

  • Noob here, help needed
  • Help me, quickly!
  • Got error
  • Lost, help me
  • Problem with my circuit
  • No idea what I am doing

Good subject lines might be:

  • Problem interfacing 24LC256 EEPROM to Arduino Uno using I2C
  • LED flashes twice as quickly as expected
  • How can I work out how many Neopixels (WS2812 LEDs) are in a string?

Post in proper sentences

This is a forum you are using, not a mobile phone.

As a courtesy to the people you are hoping to have help you, type complete sentences. That is:

  • Start with a capital letter.
  • Spell words properly.
  • Finish with a period (full-stop). (Just the one, thanks!)
  • Break longer posts into paragraphs, and not have a "wall of text" hitting the reader.

Post your code, formatted correctly

Here is the "blink" sketch, copied and pasted into a post:

void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }

Pretty hard to read, isn't it? Now just select all the code, and press Ctrl+K (think of the word "Kode"). That formats it nicely like this:

void setup() {
  pinMode(13, OUTPUT);
}
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Basically all it has done is indent everything by 4 spaces.

You can force the syntax-colouring you see above by putting this before the code:

<!-- language: lang-c++ -->

Format your code in the IDE before posting

In the Arduino IDE (Integrated Development Environment) format your code by pressing Ctrl+T before posting it here. The auto-format indents code properly so you can see what code is under an if, for example.

Properly formatted code helps to work out logic errors, for example if you accidentally have an extra semicolon which shouldn't be there.

Do not post screen-shots or photos of your code

Do not take a screenshot of your code, or photograph it with your phone. Copy and paste the code as text and put it into your question as described above. A screenshot or photograph can't be copied and pasted into replies, nor can we copy and paste the code into the IDE and test it ourselves on your behalf.


Post a Minimal, Complete and Verifiable Example

To help us to reproduce the problem, post a Minimal, Complete and Verifiable Example that demonstrates the problem. This may not always be possible, but in many cases (for example, displaying numbers on a 7-segment LED display) it is very practical. This helps separate out the problem (not being able to display) from the non-problem (how you calculate those numbers).


Provide links to any libraries used

Many libraries have variants (for example, keypad libraries, SD card libraries, LCD display libraries). To help reproduce (and understand) your problem provide a link to the exact library you are using.


If the question mentions hardware, be specific

Don't just say "I have a temperature sensor connected to my Arduino".

  • Say which sensor (part number)
  • Give a link to the datasheet which describes the part or the board
  • Say where you got if from (eg. Adafruit, Sparkfun, eBay) with a link to the specific page where it appears
  • Say which Arduino (eg. Arduino Uno)

Include a photo of your set-up

If the issue sounds like a hardware issue, take a clear, in-focus picture of your hardware. The photo should clearly indicate which wires go where. Preferably use a different colour for each wire like in this picture:

Example photo of board


Include a schematic

Many projects involve extra hardware (switches, LEDs, motors, other parts). Draw or make a schematic showing how they are connected together. Do not use Fritzing which is not the same as a schematic and often difficult to read. You can get free software which draws schematics from Express PCB (you need the ExpressSCH program). This runs under Windows. You can also use Eagle although the learning curve may be greater with that. As a last resort sketch out your schematic with pencil and paper and scan or photograph it, and include that.

Example of ExpressSCH schematic:

Example schematic


Be clear what the question is

A good question states:

  • What you expected to happen; and
  • What actually happened

For example, "I expected the LED to flash every second" (the expectation) "but it doesn't flash / flashes every 5 seconds / is always on / is always off".

  • Avoid saying "it doesn't work". What doesn't work?
  • Distinguish between:
    • Compiler errors (that is, you can't even compile the program)
    • Uploading errors (it compiles, but doesn't upload to the board)
    • Run-time errors (it compiles and uploads, but does something you don't expect it to)

Tips for getting the most out of your post

  • Mention which Arduino you have. Is it a Uno? Leonardo? Due? Mini? Mega? The problem might be specific to a certain model.
  • Describe your problem in detail.
  • If it relates to an electronics part (chip or board), give the exact part number and preferably a link to the data sheet.
  • Describe how you have connected things like switches. Are they wired to ground? Or +5V? Are there pull-up or pull-down resistors? Post a circuit if there is doubt.
  • Post a complete sketch (program code)! If you don't you waste time while people ask you to do that. However, with coding problems, if possible post a Minimal, Complete and Verifiable Example that demonstrates the problem - not hundreds of lines of code. If the problem goes away in the minimal sketch, it wasn't where you thought it was.
  • Copy and paste code. Don't retype "from memory" on your mobile phone, in the train.
  • If you get an error, post the error (copy and paste). Not just "I got an error".
  • If you have debugging information in your sketch, post your debugging displays.
  • If you are using a library that does not come with the IDE (in other words, you downloaded it from somewhere) please post a link to this library.
  • Describe what you expected to happen, and what actually happened. Not just "it doesn't work".
  • If possible, describe what you are really trying to do, not what you think might work. For example "I am trying to turn on an aquarium heater and pump at the same time", not "how do I break out of an interrupt?".
  • Try to narrow down the problem, whether coding or electronic. Don't confuse us and yourself by trying to do everything at once. For example, if you are having problems reading a sensor, make up a simple test case, that tests that sensor (both electrically and in code).
  • Be nice - people are trying to help you here. If you are asked for more information, provide it calmly. Resist the urge to say something is "obviously" the case, or "I already mentioned that".

Don't cross-post!

Do not cross-post the same question on different Stack Exchange sites. See Is cross-posting a question on multiple Stack Exchange sites permitted if the question is on-topic for each site?. Work out which site is the best fit for your question (sometimes this can be a bit hard) and stick to one site.

You might consider:

If you have asked on another site (like the Arduino Forum) it is polite to mention that you have also asked there (post a link to the question). Some people here are members of Arduino Forum as well as Arduino Stack Exchange, and rather than helping you more if you post on both sites, may ignore both questions.


Don't double-post!

If you haven't got an answer in a couple of days, do not post the same question again. Regular users will soon spot that and flag your reposted question for deletion.

You can add a bounty to a question if you in a hurry for it to be answered. However you will need 50 reputation to do that.

Another thing you can do to help get a question answered is review your question. Have you followed the suggestions above? Maybe more details, links to parts, schematics, images, code, and so on, would help other people work out what the problem is, and post an answer.


Other resources

  • See Jon Skeet's post: Writing the perfect question As Jon says, imagine you are trying to answer your own question.

    Once you’ve finished writing your question, read it through. Imagine you were coming to it fresh, with no context other than what’s on the screen. Does it make sense? Is it clear what’s being asked? Is it easy to read and understand?

  • Is it a homework question. That can be OK, so don't try to hide it (we can usually tell, when people say something like "my task is to do X").

    If you admit it is homework we can still try to help you, but also try to help you to learn the underlying concepts. In other words, don't expect an answer that you just type up and hand in, but expect people to help you to help yourself with the issue.

  • If you aren't sure of some procedural issue (for example, you can't post a lot of images) you can ask on the Meta Arduino Site which is there for asking about how the site itself works.


Related

How to write a good answer for Arduino Stack Exchange

  • In the Post Your Code section, I suggest adding a note about the using the Auto format tool in the Arduino IDE before posting (Tools->Auto Format) (Ctrl-T) – Craig Jun 28 '18 at 18:48
  • @Craig Good idea! I've done that. – Nick Gammon Jun 29 '18 at 2:32

You must log in to answer this question.

Browse other questions tagged .