How to write a good answer
Some new users on Stack Exchange may find the system of flagging, voting and commenting a bit difficult to follow, or frustrating, even.
This post is intended as a guide to writing a good answer.
A good answer
- Will help the OP (Original Poster - the person who asked the question)
- May be accepted by the OP, thus giving a +15 reputation bonus
- May be up-voted by multiple people, each up-vote giving a +10 reputation bonus
- May attract positive or helpful comments under the answer
- Will help other people in the future (people with a similar question)
- As your reputation increases your privileges on the site will increase
A bad answer
- May attract down-votes, each down-vote deducting 2 reputation points from the person who made the answer
- A lot of down-votes may cause the question to be automatically closed
- May be flagged for moderator attention, possibly leading to its deletion
- Too many negative flags (agreed to by the moderators) may lead to a temporary suspension of privileges
- May attract negative comments
This is not a forum
Stack Exchange has a different model to most forums. On a forum (for example The Arduino Forum) answers are likely to build on previous answers, a bit like this:
Q. I've connected my LED to the Arduino output pin and earth, and set that pin to OUTPUT and HIGH. However the LED does not light up. Why is that?
John: You may have it in backwards.
Emma: You also need a current-limiting resistor.
James: Good idea! 220 ohms would be about right.
Olivia: Make sure you have the pin set to OUTPUT.
Ethan: See this web page
Sophia: What colour LED is it?
In a forum this is perfectly reasonable, and the overall answer is an amalgamation of each response. However here most of those answers would be down-voted or flagged as too short, "not an answer", or "link-only".
If you are used to forums, you may be aggrieved that a response that was perfectly acceptable on a forum gets down-votes, negative comments, or is possibly deleted entirely.
Answers should stand alone
Answers on Stack Exchange should stand on their own, and not rely upon snippets of information from other answers, or comments.
What you need to do is take the time to make a comprehensive reply that will not only help the OP today, but stand as a beacon of helpfulness for people in the next ten years! Something like this:
LEDs are polarized, and thus have to be fitted the correct way around. If you have a LED tester or multimeter you can usually work it out by measuring the LED. There are some visual clues, however. If the leads haven't been cut the longer one is the positive lead (anode):
Also, the negative lead (cathode) will have a small notch cut out of the plastic (viewed from below) like this:
LEDs need to be protected from too much current. If you connect an LED directly across a battery or Arduino output pins, the high current through the LED will damage both the LED and the Arduino. You need to limit current, typically to around 20 mA. This is often done with a resistor in series, like this:
Note that the part of the LED symbol with the bar is the negative side (cathode). The 220 ohm resistor will limit the current to around 15 mA for a red LED.
You can visit a LED calculator site. Example of the calculations:
The forward voltage varies depending on the colour of the LED, and typical ones (from that site) are:
You can do the calculations yourself by considering that with a forward voltage drop of 2V for a red LED, then there must be a 3V drop over the resistor. Using Ohm's Law:
R = V / I
R = 3 / 0.015
R = 200
The closest standard value is 220 so we use 220 ohms here. Re-arranging the formula we can work out the exact current:
I = V / R
I = 3 / 220
I = 0.014
Thus this arrangement will actually draw 14 mA from the output pin which is in spec for an Arduino output pin.
const byte ledPin = 5;
More information about using LEDs at Mike Cook's site: The care and feeding of LEDs
The example answer above illustrates:
- Images of parts to make clear which terminal is which
- A schematic of the connections
- Example code
- An explanation of why a certain resistor value was used
- Some off-site references for more reading
Answers should not only contain links to other sites
Links can, and probably will, go "link dead" over time. Thus an answer of "see www.xyz.com" which may be helpful today will be useless when "xyz.com" becomes defunct. Preferably summarize, paraphrase, or re-state what the linked site says. Then include the link, if necessary, as "further information". Of course, don't claim the other person's work as your own, so you could say something like "As John Smith says at xyz.com, blah blah blah ...".
Comments on answers
Please feel free to comment on someone's answer if you think something is unclear, or wrong. If you see an obvious typo, and you have enough reputation to do so, you can edit the answer to fix up the problem. However do not change the original intent of the answer.
Make another answer
If you see an answer that you believe isn't the greatest, or there is a better way of doing things, then feel free to post a different answer that explains the situation better. Stack Exchange is designed for this to happen, so that the best answer gets the most votes and "floats" to the top of the answer pool.
If you like an answer, vote for it!
If you see a good answer, vote it up. This helps others (like the OP) know that other people agree with the answer. It also helps the person making the answer get more reputation.
Answers are NOT for:
- Asking another question - start your own question for that.
- A "me too!" answer - that is, saying you have the same problem as in the question, and asking if anyone solved it.
- To ask for more information about the question - use a comment for that if you have enough reputation. If not, answer some other questions until you have built up enough reputation to make comments (currently 50 reputation).
- For the OP to add additional information, like schematics, code, photos, explanations. Edit the question to do that.
- To comment on another answer - use a comment under the answer to do that.
- How do I write a good answer?
- What should I do when someone answers my question?