-1

I don't know if I am allowed to ask this question because really I could just look this up on google. The reason I'm asking here is because in google when you look up the definitions for the following commands, they treat you like you have good knowledge of arduino boards work. I however want to be treated as a beginner who just started learning arduino boards.

So I want to know the definitions of the following commands in a way that I could learn and teach new beginners without getting them confused.

So I want to know the clear definitions of these following commands:

analogWrite and also why does it have a limit of 255? what does this 255 mean?

analogRead and also why does this have a limit of 1023? what does this mean?

digitalWrite and also how does this differ from analogWrite?

digitalRead and also how does this differ from analogRead?

Loop and setup also what is the void before it?

Variables and also how they are declared?

Map and also what does it map and how?

Serial.write and also how does this differs from analogWrite and digitalWrite?

If/else commands and when they should and shouldn't be used?

Like I said, I do not know whether the question is appropriate, but could be helpful to all the beginners learning Arduino.

closed as too broad by Majenko, KIIV, Code Gorilla, gre_gor, Nick Gammon Mar 21 '17 at 21:24

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    It strikes me that you need to read some basic "Introduction to C programming" tutorials. – Majenko Mar 21 '17 at 10:26
  • 1
    @Majenko Having basic instructions in this site could help too, even if it might not be the first go-to place to learn about arduino's. The answer provided below is clear, short and simple to understand, which is what beginners look towards. – Utsav Mar 21 '17 at 10:29
  • 4
    This site is not the place for basic tutorials. There's already plenty of them around if you just google. Most of your questions can be answered by first learning the basics of the C syntax, which seems to be the information you are lacking to make sense of everything else. – Majenko Mar 21 '17 at 10:39
  • 1
    "I could just look this up on google". Yes, you could. – Enric Blanco Mar 21 '17 at 11:44
  • 2
    I would recommend the Arduino on-line reference and tutorials. Please see arduino.cc/en/Guide/HomePage and explore the Learning menu. – Mikael Patel Mar 21 '17 at 12:32
3

These are a lot of different questions. However, you can find most of the Arduino related answers in the official reference: Arduino reference Guide

Some other answers:

  • how to declare variables:

e.g.

int x;

SerialWrite sends data to the serial port/UART, analogWrite and digitalWrite puts a voltage to a pin (simplified).

AnalogWrite is normally used for a value that has a range (like the intensity of a led), digitalWrite for an On/Off state (can also be for a led but just on/off).

if/else commands can be used to make a program make a decision.

e.g.

if (a == 10)
{ 
    Serial.println("10");
}
else
{
    Serial.println("Not 10");
}

void means 'nothing' ... in principle it means the functions (setup and loop) do not return any value. You can also define functions which return a value, e.g.

int add(int a, int b)
{
    return a + b;
}

Read in any C/C++ manual about the commands, get a beginner programmers handbook.

The limit of a pin, means the value cannot be more than 255 or 1023. This means that the range of the value you can get/set is between 0 and 255 or 1023. The map command can be used to make a value within the range required.

  • short, simple, understandable and easy to remember. Thank you. Quick question about something, what do you mean the limit of a "pen"?, what is a 'pen'? is there a reason why they have limits? – Utsav Mar 21 '17 at 10:26
  • @Utsave: you are welcome ... and I meant pin, not pen (I updated the answer). The main reason is that it has to be mapped to a value usable for computers. In practice e.g. a voltage can be anything from 0.00000 to 5.0000 V for example. However, computers use bits/bytes and it is not useful to keep 10 significant digts. With 1024 (0-1023 values) the accuracy is good enough and 1024 is 10 bits (2 to the power 10). – Michel Keijzers Mar 21 '17 at 10:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.