Conrad 4019631150035 Operation Manual

Advent Calendar for Arduino 2017
In the past, the programming of microcontrollers used to be something for engineers and computer scientists. Today, everyone can get started with microcontroller technology, thanks to the Arduino platform and neat hardware and easy-to-understand software.
Behind the name Arduino
The Arduino comes from Italy and was named after the Italian king Arduin, who ruled in Ivrea until the year 1005. The headquarters of the Arduino manufacturer is in Ivrea. Also. the favourite bar of the Arduino developers, Massimo Banzi and David Cuartielles, was named after King Arduin.
Nano compatible board
The Arduino platform, meanwhile, offers a large variety of boards for different applications. This Advent calendar contains a board that is Arduino Nano compatible and is plugged straight onto a breadboard to connect additional electronics. The Advent calendar has a hardware experiment with the corresponding program for every day.
Most of the experiments of this Advent calendar are programmed with Snap4Arduino. This programming language is based on Scratch, which is by far one of the easiest programming languages to learn. Later on, we will also present the classic Arduino IDE. You can download the programs and layout drawings used in the Advent calendar here: www.buch.cd. Enter the code 15003-5 and follow the instructions.
Breadboard
The Advents calendar contains a breadboard for the fast prototyping of electronic circuits, without the need to solder anything. Here, elec­tronic components can be inserted straight into a hole of the grid.
Breadboard connections
All outer long rows of the breadboard are interconnected to each other via contacts (X and Y). These rows with contacts are often used as a plus and minus pole to power the circuits. The other rows with contacts have five contacts each (A to E and F to J), which are connected crossways with each other and there is a gap in the middle section of the board. Larger components can thus be plugged in and wired to the outside.
LEDs
LEDs (light-emitting diodes) will glow as soon as current passes in flow direction through them. LEDs are shown in circuits with an arrow­shaped triangle symbol, indicating the direction of flow from the positive pole to the negative pole or to the ground line. Almost any amount of current can pass through an LED in the direction of flow; there is very little resistance. In order to limit the current flow and thus pre­venting the LED from breaking, a 220-ohm series resistor is usually installed between the connection pin used and the anode of the LED or between the cathode and ground pin. Such a series resistor also protects the output of the Nano from excessive current. Series resistors are already installed in the LEDs that come with the Advent calendar and you can thus connect them straight to the pins.
Circuit diagram of an LED with a series resistor.
How do you connect an LED?
The length of the two connecting wires of an LED is different. The longer leg is the positive pole, the anode; the shorter leg is the cathode. Easy to remember: The plus sign has a dash more than the minus sign and thus makes the leg somewhat longer. Besides, most LEDs are flat at the minus side, similar to the minus sign. Also, easy to remember: Cathode = cut leg.
Resistors and colour codes
Resistors are used to limit current on sensitive electronic components and as series resistors for LEDs. Resistance is measured in ohms. 1,000 ohms equal to one kilo-ohm, abbreviated KΩ. 1,000 kilo-ohms equal to a mega-ohm, abbreviated MΩ. The Omega sign Ω is widely used in conjunction with the metric unit.
Colour Resistance value in ohm:
Ring 1 (tens)
Silver
Gold
Black
Brown 1 1 101 = 10 ±1 %
Red 2 2 102 = 100 ±2 %
Orange 3 3 103 = 1,000
Ring 2 (ones)
0 100 = 1
Ring 3 (multiplier)
10−2 = 0.01 ±10 %
10−1 = 0.1 ±5 %
Ring 4 (tolerance)
Yellow 4 4 104 = 10,000
Green 5 5 105 = 100,000 ±0.5 %
Blue 6 6 106 = 1,000,000 ±0.25 %
Violet 7 7 107 = 10,000,000 ±0.1 %
Grey 8 8 108 = 100,000,000 ±0.05 %
White 9 9 109 = 1,000,000,000
The coloured rings on the resistors indicate the resistor value. After a little practice, they are much easier to make out than the tiny numbers, which are still found on very old resistors.
Most resistors have four such colour rings. The first two colours are used for the digits, the third for a multiplier and the fourth for the toler­ance. This tolerance ring is usually gold- or silver-coloured – basically, colours, which are not used for the first rings. Thus, the direction of reading is always evident. The tolerance value itself plays no serious role in digital electronics. The table shows how to interpret the ring colours of resistor.
The direction how a resistor is installed is not important. However, the direction of installation is very important in the case of LEDs.
Precautionary measures
You should never attempt to connect some Arduino pins and then wait for what happens. Not all of the Arduino pins can be freely programmed. A few are fixed for power supply and other purposes. Some Arduino pins are connected directly to the microcontroller, and that is why a short circuit can destroy the Arduino completely - at least in theory. Arduino boards are amazingly resistant to cir­cuit faults. However, you must always connect a series resistor in between when connecting two pins via an LED. For logic signals, some Arduino compatible boards require 3.3 V, other 5 V. The Nano in this Ad­vent calendar uses a +5V signal as logical high or true.
Day 1
Today on the Advent calendar
•Nano (Arduino compatible board)
Nano preparation
For the Nano to work you will need:
•PC with Windows
•MicroUSB cable
•Driver
PC and Nano are connected with a MicroUSB cable. Almost all modern smartphones use this type of connector so, most likely, you will not need to purchase such a cable. The cable is used for power supply and also for data transmission.
Connect the cable to a USB 2.0 port on your PC, if possible. You may encounter problems with the connection, if you use an USB 3.0 port.
Software installation in a nutshell
Four steps to install the driver:
Installation of the device driver.
1. Download the example programs and the driver from www.buch.cd. Enter the code 15003-5 and follow the instructions on the screen.
2.Extract the ZIP archive into a folder anywhere under the Windows User folder.
3. Connect the Nano using the USB cable and then run the file
CH341SER.EXE
to install the driver. During installation confirm a request from
the Windows User account control.
4. In the installation screen click Install and wait until the installation of the driver is confirmed.
The LED glows
We use the easy-to-learn Snap4Arduino programming language for most Advent Calendar projects. You will find it among the Advent cal­endar downloads. Or you can download the latest version from snap4aruino.org .
The Snap4Arduino
Configuration
tool.
English
Select
in the list.
In Snap4Arduino click the Configuration icon and select Language from the menu.
However, you will need to establish a connection between PC and Nano, before you can start programming. For this purpose, we have the StandardFirmata software preinstalled on our Advent calendar Nano.
In Snap4Arduino, switch to the Arduino block in the top left corner and click Connect to Arduino. If only one COM interface appears, select it. If two interfaces are shown, then usually the lower one is the correct one.
Confirm the message with OK.
Choose an interface for the connection.
Error launching a new program.
When you launch a new program in Snap4Arduino, sometimes the connection to the Arduino is lost. Re-connect the Nano with one click, if such an error occurs when a new program is launched.
The connection to the Nano was successful.
The program
In Snap4Arduino, you do not need to type any programming code. The blocks are simply positioned by drag-and-drop. The block palette on the left in the window contains blocks of code arranged by topic.
Advent Calendar programs
Download the Advent Calendar programs from www.buch.cd or build one each day yourself with the illustration as your guidance. Unzip the ZIP file from the download to a directory on the hard drive. Then in Snap4Arduino click the file icon at the top on the left and select Import to import the programs into Snap4Arduino. The programs are in XML format. Once imported, the programs will be shown in their own library, which you can access via the Open menu item.
The first program
01led01
uses the most important block codes:
Most of the programs will start When the little green flag is clicked in the Control tool
continuous in the Control tool it an infinite loop that is repeated forever. Set up the digital pin... to... in the Arduino tool will set one of the Nano’s digital pins to the logical true or false value. You will find the green
block for logical values in the Operators tool. You can toggle between the true and false values directly in the block.
LED on pin 13
The Nano has its own LED, which is controlled via pin 13. It displays the status without the need of additional hardware.
wait... sec in the Control tool will have the program wait for a certain time before the next step is executed.
This is how the program works
The program will start when you click on the green flag in the upper right corner.
01led01
The
program will make the Nano LED flash.
A continuous loop will have the LED flash endlessly; that is, until the user clicks on the red Stop icon at the top on the right in Snap4Arduino.
When the LED on pin 13 turns on, a waiting time of 0.01 seconds follows. This is the time the LED will be lit. Then the LED on pin 13 turns off again. The program will now wait for half a second. That way, the LED will only light up briefly, while it is dark for a relatively longer time. The cycle is then repeated.
Note: Decimal Point Like most American programs, also Snap4Arduino uses the dot as a decimal separator while in Germany a comma is used.
Day 2
Today on the Advent calendar
• 1 Breadboard (SYB 46)
• 1 red LED with built-in series resistor
Alternating flashing light
02led02
is a simple program for two LEDs that will flash alternately.
Alternating flashing light on the Nano
Components: 1 Breadboard, 1 red LED with built-in series resistor
Make sure that the LED cathode (short leg) is connected to the GND pin and the anode (long leg) to the D2 pin.
Nano pins
All pins with D… are digital inputs or outputs, which can have the values true or false (on or off). Pins with A… are analogue inputs. GND pins are ground wires. Arduino compatible boards work with different voltages and by default they come with two different plus pins. Pin 3.3 supplies a voltage of +3.3 V. Pin 5V supplies a voltage of +5 V. Our Advent calendar Nano requires a +5 V for a logical true signal, other boards need only +3.3 V.
The program
02led02
The
program will have the built-in Nano LED and an externally connected LED flash in turns.
02led02
The
program features two LEDs flashing alternately.
This is how the program works
A continuous loop enables the two LEDs to blink endlessly; that is, for as long as the user does not click on the red Stop icon at the top on the right in Snap4Arduino.
After the built-in LED on pin 13 is turned on, a waiting time of 0.01 seconds ensures that StandardFirmata is not “swallowing” a command. Most Arduino compatible boards should always have a minimum wait time between two pins. For the Advent Calendar Nano, this is not really essential. Finally, the LED on pin 2 is turned off. The program will now wait for half a second.
Using the same method, the LED on pin 2 is then turned on and the LED on pin 13 is turned off. The cycle starts again from the beginning after half a second.
Day 3
Today on the Advent calendar
•Jumper wire (insulated)
Jumper wire
Today we have included a jumper wire in the Advent calendar. The jumper wire is used to create short connection bridges to connect rows on the breadboard. Cut the wire to the appropriate lengths needed for the experiments using a small side cutter. We recommend cutting the
wire end at a slight angle thus creating a kind of wedge, which will allow you to plug the wires into the breadboard easily. Remove about half a centimetre of the insulation at both ends.
Alternating flashing LED on the Nano.
LEDs flash at an adjustable speed.
The experiment of the 3rd day lets two LEDs blink alternately. This time, however, you can adjust the speed.
Components: 1 Breadboard, 1 red LED with built-in series resistor, 1 wire jumper
Today’s circuit shows the typical circuit configuration on the board. One of the horizontal contact strips will be used as ground line, which we connect to the GND pin on the Nano via a wire jumper. Make sure when configuring the circuit that the LED cathode (short leg) is plugged into the GND pin and the anode (long leg) is connected to pin 10 in our circuit of today.
The program
03led03
The ed to pin 10, will flash in turns. You can control the flash frequency via a slider on the screen.
program works similar to the one of yesterday and again the built-in LED on the Nano and the external LED, this time connect-
03led03
The
program lets two LEDs blink alternately and at an adjustable speed.
This is how the program works
Also, here, the Continuous loop lets the two LEDs flash alternately forever. We will use a variable instead of a fixed time between the
change.
Variables in Snap4Arduino
Variables are tiny storage locations that contain a number or any similar information for a program to recall. When the program is closed, these variables will be cleared automatically. However, first the variables must be created in Snap4Arduino using the command tool Variables and the button New variable, before we can use any. You can then drag the icon of the newly created variable from the block palette into a specific field of a block within the program. The block palette offers also various other blocks for reading and changing variables.
After a variable is created, it appears as an orange icon on the stage. Here, the current value of the variable is always shown. Right-click on this icon and select the Controller option.
Take the values 1 and 10 to set the Minimum value and Maximum value. Variables could have any value, but Snap4Arduino however can only set integers with the sliders.
In the program, the set value of the variable z is divided by 10 to obtain values between 0.1 and 1.0 seconds. The block palette Operators has blocks for basic calculation operations.
Day 4
Today on the Advent calendar
• 1 green LED with in built-in series resistor
LEDs flash randomly.
The experiment from the 4th day features three LEDs flashing in random order. The two external LEDs are plugged into the breadboard close to each other, since the program requires successive pin numbers. The third LED is the LED soldered to the Nano board and has the pin number 13.
Three LEDs blink randomly.
Components: 1 Breadboard, 1 red LED with built-in series resistor, 1 green LED with built-in series resistor, 1 wire jumper
The program
The program
04led04
is similar to the one we used on Day 2. Also, here, several digital pins are switched on and off in a row in an endless
loop. This time, pins are chosen at random.
How are random numbers generated?
In general, we assume that nothing randomly can happen within a program – then how is it possible that a program is able to generate random num­bers? If a large prime number is divided by any value, the x decimal point produces numbers, which are sheer unpredictable. They will also change without any regular pattern, if the divisor is constantly increased. The re­sult seems to be randomly, but it can be reproduced at any time by an iden­tical program or the repeatedly invoking of the same program. Now, if you take a number that was composed of some of these digits and you then divide it by a number that you take from the current time second or from the contents of any memory location on the computer, you will get a result that cannot be reproduced and this then is called a random number.
04led04
Program
lets LEDs blink randomly.
This is how the program works
At the start of each infinite loop run, the variable n is set to a random number between 11 and 13. This then indicates the pin number of the LED that should be lit. The circuit thus needs three successive pin numbers.
The speed how fast the colours change is controlled by means of a variable z, which is set via a slider and will then apply to each switching operation.
The randomly selected LED is switched on for the set time and then switched off for just as long. A new LED is randomly selected in the next loop run. It may well happen that the same LED goes on several times in a row.
Day 5
Today on the Advent calendar
• 1 yellow LED with built-in series resistor
Traffic light
The experiment of the 5th day will switch traffic lights by means of three LEDs in a typical series from red to red/yellow to green and via yellow back to red.
Traffic lights with three LEDs.
Components: 1 Breadboard, 1 red LED with built-in series resistor, 1 yellow LED with built-in series resistor,1 green LED with built-in series resistor, 1 wire jumper
The program
The program in an endless loop. In the intermediate phases of red/yellow and yellow, the traffic light will go on for 0.5 seconds each, in the phases of red and green the duration is 3 seconds each. You can set these times also differently in the wait...sec blocks.
05ampel01
is similar to the one we used on Day 3 . Also, here, a combination of LEDs are switched on and off one after the other
This is how the program works
Each run of the infinite loop starts with the red phase of the traffic lights with the yellow and green LEDs switched off. After 3 seconds, the yellow LED is also switched on. After a short red/yellow phase, which will last 0.5 seconds, the red and yellow LEDs are switched off and the green one is switched on. The green phase lasts 3 seconds, followed by a short yellow phase of 0.5 seconds, and the infinite loop starts a new run with red.
Program
05ampel01
lets LEDs blink alternately.
Day 6
Today on the Advent calendar
•1 Button
•1 10-kOhm-resistor (brown-black-orange)
Toggle LEDs using a switch
The experiment of the 6th day shows how to switch two LEDs via a button.
Two LEDs controlled by a button.
Components: 1 Breadboard, 1 red LED with built-in series resistor, 1 green LED with built-in series resistor, 1 button, 1 10-kOhm-resistor (brown-black­orange), 3 wire jumpers of different lengths
Digital pins are not only used for the output of data, for example via LEDs, but also for data input. For the input, we will use a button in our project of today, which is plugged directly onto the breadboard. The button has four connection pins, whereby the two opposite each other (large distances) are interconnected. As long as the button is pressed, all four connectors are interconnected. Unlike a switch, a button does not latch. The connection is immediately cut when the button is released.
If a digital input has a +5V signal, it will be evaluated as logically true.
Circuit diagram of a button with pull-down resistor.
If the button were open, the input would not have a clearly defined state. A program querying this pin could produce random results. To prevent this, a relatively very high resistance - usually 10 kOhm - is connected to ground. This so-called pull-down resistor pulls the status of the input pin down to 0 V, if the button is open. Because the resistance is very high, there is no risk of a short-circuit for as long as the but­ton is pressed. When the button is pressed, +5 V and the ground line are connected directly via this resistor.
The program
The program LED is lit while the button is not pressed.
06led06
turns on the green LED on pin 8, while it turns off the red LED on pin 12, when the button is pressed. Only the red
The program
06led06
lets you switch two LEDs with a button.
This is how the program works
The if…else… block of the Control block palette will execute the blocks within the upper brackets, whenever the query returns the value true. If this is not the case, the blocks within the brackets below will be executed.
The query reads the value of the digital pin 3 via a block from the Arduino block palette and checks whether this is true. Digital inputs can only have the values true or false.
If the value is true, then the button is pressed. If this is the case, the LED on pin 8 is turned on and the LED on pin 12 is turned off. If this is not the case, pin 3 has the value false and the LEDs are switched exactly the other way.
Day 7
Today on the Advent calendar
• 1 red LED with built-in series resistor
Dimming the LED
The experiment of the 7th day will dim an LED.
One LED is dimmed, the second one is lit with full brightness.
Components: 1 Breadboard, 2 red LEDs with built-in series resistors, 1 wire jumper
LEDs are typical components used in digital electronics to output signals. LEDs can have two different states, on and off, 0 and 1 or false and true. The same is true for the digital pins, which are defined as outputs. Logically that would mean, however, it is impossible to dim an LED.
But a trick makes it possible to control the brightness of an LED on a digital pin. If an LED is flashing fast enough, the human eye cannot perceive this anymore as flashing. The technique, known as pulse width modulation (PWM), produces a pulsating signal, which turns on and off at very short intervals. The signal voltage is always the same, only the ratio between level false (0 V) and level true (+3.3 V) is changed. The duty cycle is the ratio of the length of the switched-on state to the total duration of a switching cycle.
The smaller the duty cycle, the shorter is the LED glow time within a switching cycle. This will make the LED appear darker than a perma­nently switched on LED.
Left: Duty cycle 50% - on the right: Duty cycle 20%.
Loading...
+ 34 hidden pages