Skip to content

Commit 36989f9

Browse files
author
Alice Pintus
committed
first
0 parents  commit 36989f9

File tree

37 files changed

+374
-0
lines changed

37 files changed

+374
-0
lines changed

Language/Functions/Advanced IO/.gitkeep

Whitespace-only changes.

Language/Functions/Analog IO/.gitkeep

Whitespace-only changes.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
= analogWrite()
2+
3+
4+
// OVERVIEW SECTION STARTS
5+
[#overview]
6+
--
7+
8+
[float]
9+
=== Description
10+
Writes an analog value (http://arduino.cc/en/Tutorial/PWM[PWM wave]) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to `analogWrite()`, the pin will generate a steady square wave of the specified duty cycle until the next call to `analogWrite()` (or a call to `digitalRead()` or `digitalWrite()` on the same pin). The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno and similar boards, pins 5 and 6 have a frequency of approximately 980 Hz.
11+
[%hardbreaks]
12+
13+
image::http://arduino.cc/en/uploads/Main/ArduinoUno_R3_Front_450px.jpg[caption="", title="A beautiful Arduino UNO"]
14+
[%hardbreaks]
15+
16+
17+
[float]
18+
=== Syntax
19+
`analogWrite(pin, value)`
20+
21+
22+
[float]
23+
=== Parameters
24+
`pin`: the pin to write to. +
25+
`value`: the duty cycle: between 0 (always off) and 255 (always on).
26+
27+
28+
[float]
29+
=== Returns
30+
Nothing
31+
32+
--
33+
// OVERVIEW SECTION ENDS
34+
35+
36+
37+
38+
// HOW TO USE SECTION STARTS
39+
[#howtouse]
40+
--
41+
42+
[float]
43+
=== Example
44+
Sets the output to the LED proportional to the value read from the potentiometer.
45+
46+
47+
[source,arduino]
48+
----
49+
int ledPin = 9; // LED connected to digital pin 9
50+
int analogPin = 3; // potentiometer connected to analog pin 3
51+
int val = 0; // variable to store the read value
52+
53+
void setup()
54+
{
55+
pinMode(ledPin, OUTPUT); // sets the pin as output
56+
}
57+
58+
void loop()
59+
{
60+
val = analogRead(analogPin); // read the input pin
61+
analogWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
62+
}
63+
----
64+
[%hardbreaks]
65+
66+
67+
[float]
68+
=== Notes and Warnings
69+
This is because of interactions with the `millis()` and `delay()` functions
70+
[%hardbreaks]
71+
image::http://arduino.cc/en/uploads/Main/ArduinoUno_R3_Front_450px.jpg[caption="", title="A beautiful Arduino UNO"]
72+
[%hardbreaks]
73+
74+
75+
[float]
76+
=== See also
77+
[role="language"]
78+
* #LANGUAGE# http://arduino.cc/en/Reference/AnalogRead[analogRead()]
79+
* #LANGUAGE# http://arduino.cc/en/Reference/AnalogRead[analogRead()]
80+
81+
[role="definition"]
82+
* #DEFINITION# http://arduino.cc/en/Tutorial/PWM[PWM]
83+
84+
[role="example"]
85+
* #EXAMPLE# http://arduino.cc/en/Tutorial/Blink[Blink]
86+
87+
--
88+
// HOW TO USE SECTION ENDS

Language/Functions/Arduino DUE only/.gitkeep

Whitespace-only changes.

Language/Functions/Bits and Bytes/.gitkeep

Whitespace-only changes.

Language/Functions/Communication/.gitkeep

Whitespace-only changes.

Language/Functions/Communication/Serial/.gitkeep

Whitespace-only changes.

Language/Functions/Communication/Stream/.gitkeep

Whitespace-only changes.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
= Serial()
2+
3+
4+
// OVERVIEW SECTION STARTS
5+
[#overview]
6+
--
7+
8+
[float]
9+
=== Description
10+
Used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial port (also known as a UART or USART): Serial. It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. +
11+
You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board. Click the serial monitor button in the toolbar and select the same baud rate used in the call to `begin()`.
12+
[%hardbreaks]
13+
The *Arduino Mega* has three additional serial ports: `Serial1` on pins 19 (RX) and 18 (TX), `Serial2` on pins 17 (RX) and 16 (TX), `Serial3` on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground. (Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)
14+
[%hardbreaks]
15+
The *Arduino DUE* has three additional 3.3V TTL serial ports: `Serial1` on pins 19 (RX) and 18 (TX); `Serial2` on pins 17 (RX) and 16 (TX), `Serial3` on pins 15 (RX) and 14 (TX). Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip, which is connected to the USB debug port. Additionally, there is a native USB-serial port on the SAM3X chip, SerialUSB'.
16+
[%hardbreaks]
17+
The *Arduino Leonardo* board uses `Serial1` to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). `Serial` is reserved for USB CDC communication. For more information, refer to the Leonardo getting started page and hardware page.
18+
19+
--
20+
// OVERVIEW SECTION ENDS
21+
22+
23+
// FUNCTIONS SECTION STARTS
24+
[#functions]
25+
--
26+
27+
'''
28+
29+
[float]
30+
=== Functions
31+
http://arduino.cc[if] (Serial) +
32+
http://arduino.cc[available()] +
33+
http://arduino.cc[begin()] +
34+
http://arduino.cc[end()] +
35+
http://arduino.cc[find()] +
36+
http://arduino.cc[findUntil()] +
37+
http://arduino.cc[flush()] +
38+
http://arduino.cc[parseFloat()] +
39+
http://arduino.cc[parseInt()] +
40+
http://arduino.cc[peek()] +
41+
http://arduino.cc[print()] +
42+
http://arduino.cc[println()] +
43+
http://arduino.cc[read()] +
44+
http://arduino.cc[readBytes()] +
45+
http://arduino.cc[readBytesUntil()] +
46+
http://arduino.cc[setTimeout()] +
47+
http://arduino.cc[write()] +
48+
http://arduino.cc[serialEvent()]
49+
50+
'''
51+
52+
--
53+
// FUNCTIONS SECTION ENDS
54+
55+
56+
// SEEALSO SECTION STARTS
57+
[#seealso]
58+
--
59+
60+
[float]
61+
=== See also
62+
[role="language"]
63+
* #LANGUAGE# http://arduino.cc/en/Reference/AnalogRead[analogRead()]
64+
* #LANGUAGE# http://arduino.cc/en/Reference/AnalogRead[analogRead()]
65+
66+
[role="definition"]
67+
* #DEFINITION# http://arduino.cc/en/Tutorial/PWM[PWM]
68+
69+
[role="example"]
70+
* #EXAMPLE# http://arduino.cc/en/Tutorial/Blink[Blink]
71+
72+
--
73+
// SEEALSO SECTION ENDS

Language/Functions/Digital IO/.gitkeep

Whitespace-only changes.

Language/Functions/External Interrupts/.gitkeep

Whitespace-only changes.

Language/Functions/Interrupts/.gitkeep

Whitespace-only changes.

Language/Functions/Math/.gitkeep

Whitespace-only changes.

Language/Functions/Random Numbers/.gitkeep

Whitespace-only changes.

Language/Functions/Time/.gitkeep

Whitespace-only changes.

Language/Functions/Trigonometry/.gitkeep

Whitespace-only changes.

Language/Functions/USB (Leonardo and DUE only)/Keyboard/.gitkeep

Whitespace-only changes.

Language/Functions/USB (Leonardo and DUE only)/Mouse/.gitkeep

Whitespace-only changes.

Language/Structure/Arithmetic Operators/.gitkeep

Whitespace-only changes.

Language/Structure/Bitwise Operators/.gitkeep

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
= && (and)
2+
3+
4+
// OVERVIEW SECTION STARTS
5+
[#overview]
6+
--
7+
8+
[float]
9+
=== Description
10+
Boolean Operators can be used inside the condition of an `if` statement. +
11+
&& is true only if both operands are true, for instance in this example:
12+
13+
[source,arduino]
14+
----
15+
if (digitalRead(2) == HIGH && digitalRead(3) == HIGH) { // read two switches
16+
// ...
17+
}
18+
19+
is true only if both inputs are high.
20+
----
21+
[%hardbreaks]
22+
23+
--
24+
// OVERVIEW SECTION ENDS
25+
26+
27+
28+
29+
// HOW TO USE SECTION STARTS
30+
[#howtouse]
31+
--
32+
33+
[float]
34+
=== Example
35+
36+
37+
[source,arduino]
38+
----
39+
if (a >= 10 && a <= 20){} // true if a is between 10 and 20
40+
----
41+
[%hardbreaks]
42+
43+
44+
[float]
45+
=== Notes and Warnings
46+
Make sure you don't mistake the boolean AND operator, && (double ampersand) for the bitwise AND operator & (single ampersand). They are entirely different beasts.
47+
48+
49+
[float]
50+
=== See also
51+
[role="language"]
52+
* #LANGUAGE# http://arduino.cc/en/Reference/BitwiseAnd[&] (bitwise AND)
53+
* #LANGUAGE# http://arduino.cc/en/Reference/BitwiseAnd[|] (bitwise OR)
54+
* #LANGUAGE# http://arduino.cc/en/Reference/BitwiseXorNot[~] (bitwise NOT)
55+
* #LANGUAGE# http://arduino.cc/en/Reference/If[if]
56+
57+
--
58+
// HOW TO USE SECTION ENDS

Language/Structure/Boolean Operators/.gitkeep

Whitespace-only changes.

Language/Structure/Comparison Operators/.gitkeep

Whitespace-only changes.

Language/Structure/Compound Operators/.gitkeep

Whitespace-only changes.

Language/Structure/Control Structure/.gitkeep

Whitespace-only changes.

Language/Structure/Further Syntax/.gitkeep

Whitespace-only changes.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
= {} Curly Braces
2+
3+
4+
// OVERVIEW SECTION STARTS
5+
[#overview]
6+
--
7+
8+
[float]
9+
=== Description
10+
Curly braces (also referred to as just "braces" or as "curly brackets") are a major part of the C programming language. They are used in several different constructs, outlined below, and this can sometimes be confusing for beginners. +
11+
An opening curly brace "{" must always be followed by a closing curly brace "}". This is a condition that is often referred to as the braces being balanced. The Arduino IDE (Integrated Development Environment) includes a convenient feature to check the balance of curly braces. Just select a brace, or even click the insertion point immediately following a brace, and its logical companion will be highlighted.
12+
[%hardbreaks]
13+
Beginners programmers, and programmers coming to C from the BASIC language often find using braces confusing or daunting. After all, the same curly braces replace the RETURN statement in a subroutine (function), the ENDIF statement in a conditional and the NEXT statement in a FOR loop.
14+
[%hardbreaks]
15+
Unbalanced braces can often lead to cryptic, impenetrable compiler errors that can sometimes be hard to track down in a large program. Because of their varied usages, braces are also incredibly important to the syntax of a program and moving a brace one or two lines will often dramatically affect the meaning of a program.
16+
[%hardbreaks]
17+
18+
--
19+
// OVERVIEW SECTION ENDS
20+
21+
22+
23+
24+
// HOW TO USE SECTION STARTS
25+
[#howtouse]
26+
--
27+
28+
[float]
29+
=== Example
30+
The main uses of curly braces are listed in the examples below.
31+
32+
33+
34+
[float]
35+
==== Functions
36+
37+
38+
[source,arduino]
39+
----
40+
void myfunction(datatype argument){
41+
statements(s)
42+
}
43+
----
44+
[%hardbreaks]
45+
46+
47+
48+
49+
[float]
50+
==== Loops
51+
52+
53+
[source,arduino]
54+
----
55+
while (boolean expression)
56+
{
57+
statement(s)
58+
}
59+
60+
do
61+
{
62+
statement(s)
63+
} while (boolean expression);
64+
65+
for (initialisation; termination condition; incrementing expr)
66+
{
67+
statement(s)
68+
}
69+
----
70+
[%hardbreaks]
71+
72+
73+
74+
75+
[float]
76+
==== Functions
77+
78+
79+
[source,arduino]
80+
----
81+
if (boolean expression)
82+
{
83+
statement(s)
84+
}
85+
86+
else if (boolean expression)
87+
{
88+
statement(s)
89+
}
90+
else
91+
{
92+
statement(s)
93+
}
94+
----
95+
[%hardbreaks]
96+
97+
98+
--
99+
// HOW TO USE SECTION ENDS

Language/Structure/Main/.gitkeep

Whitespace-only changes.

Language/Structure/Main/attachments/.gitkeep

Whitespace-only changes.

Language/Structure/Main/setup.adoc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
= setup()
2+
3+
4+
// OVERVIEW SECTION STARTS
5+
[#overview]
6+
--
7+
8+
[float]
9+
=== Description
10+
The `setup()` function is called when a sketch starts. Use it to initialize variables, pin modes, when you start using libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board.
11+
[%hardbreaks]
12+
13+
[float]
14+
=== Syntax
15+
`setup()`
16+
17+
[float]
18+
=== Returns
19+
Nothing
20+
21+
--
22+
// OVERVIEW SECTION ENDS
23+
24+
25+
26+
27+
// HOW TO USE SECTION STARTS
28+
[#howtouse]
29+
--
30+
31+
[float]
32+
=== Example
33+
34+
[source,arduino]
35+
----
36+
int buttonPin = 3;
37+
38+
void setup()
39+
{
40+
Serial.begin(9600);
41+
pinMode(buttonPin, INPUT);
42+
}
43+
44+
void loop()
45+
{
46+
// ...
47+
}
48+
----
49+
[%hardbreaks]
50+
51+
--
52+
// HOW TO USE SECTION ENDS

Language/Structure/Pointer Access Operators/.gitkeep

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
= HIGH | LOW

Language/Variables/Conversion/.gitkeep

Whitespace-only changes.

Language/Variables/Data Types/.gitkeep

Whitespace-only changes.

Language/Variables/Utilities/.gitkeep

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
= sizeof()

Language/Variables/Variable Scope & Qualifiers/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)