Gakken Japanino Montaj, Kullanım Kılavuzu - Sayfa 5

Bilgisayar Donanımı Gakken Japanino için çevrimiçi göz atın veya pdf Montaj, Kullanım Kılavuzu indirin. Gakken Japanino 5 sayfaları. 8-bit micro computer

Operate the P.O.V. with the Japanino
Experimenting with light
using LEDs
Basic principal 1
Making one LED flash
1
Connect the Japanino to a PC. Next, connect the P.O.V. to the
Japanino. Once you've connected everything, start up the IDE.
2
Click [File] [Examples] [Digital] [Blink] in order to open a sketch.
3
Click [Verify] to check to see if a sketch will work properly.
If completed successfully, the [Done compilling] message will
appear.
If the sketch fails, the background will turn red, and some kind of
message will appear (the part displayed in yellow includes invalid
content, or there is something lacking in the part directly before
it. After fixing the problem, click [Verify] again).
4
Click [Upload] to upload the sketch to the board. Once uploading is
done, the sketch will execute automatically, and an LED on the tip of
the P.O.V. (the LED attached to pin no. 13) and the Pin D13 activity
indicator LED on the Micro Computer board will flash.
IMPORTANT
For Mac
I
f a "Size of sketch after compiling: bytes (max. capacity, bytes)" message
appears in white letters in the Message Display box, immediately press the
RESET switch as shown in the diagram for about 1 second (after pressing it
for about 1 second, remove your hand).
If upkoading was not completed
properly, please try again starting from
the clicking on [Upload] step. If the
sketch fails to write properly no matter
how many times you try, please remove
the Japanino from the PC and try
reinserting it.
If completed successfully, the [Done uploading] message appears.
O tona
Kagaku
9
no
To save the sketch you made...
1) In [File] [Save as] , assign a name to the sketch and save it to the
[Sketchbook] .
2) Check the save destination location, and assign a name to the
sketch.
3) Once the sketch has been saved, the [Saved] message will
appear at the bottom of the Sketch screen.
To bring up a saved sketch, open [File] [Sketchbook] , and select
the desired file from the folder.
To edit the sketchbook...
The sketchbook folder is in [My Documents] (for Mac, it is saved in
[Documents] in [Home]). To change the name or to delete the
sketchbook, edit the file in this folder.
Basic principal 2
Making other LEDs blink
Change the "13" in [int ledPin = 13;] in the sketch to "12" (the
second LED from the end of the P.O.V.). Click [Verify] to check
that the sketch will work properly. After confirming, write the
sketch to the Micro Computer board.
Basic principal 3
Changing the time of the LED
flashing
Change [delay(1000)] in the sketch to [delay(100)]. Click
[Verify] to check that the sketch will work properly. After
confirming, upload the sketch to the Micro Computer board.
Description of a Sketch Used to Make One LED Flash
Details of the sketch to be operated
The word "sketch" (program) is a microcomputer term. Even though there are a lot of grammar rules that
could apply to a sketch, IDEs are programming software applications for beginner programmers, so they are
made to be comparatively simple. However, the number of grammar rules used increases as the sketch
1
Sets pin D13 to an output
becomes more complex. First, "Flashing of one LED ([Blink] in the [Digital] section of the sketch example)" is
(in the first step only)
described here.
As a basic structure, this sketch has two blocks. Actually, parts enclosed in the curly brackets, { }, are the
2
Sketch enters a loop
blocks. The "{" indicates the start of a block, and the "}" indicates the end. The block name is written on the
line before the "{." In other words, in this sketch, lines (3) to (5) make up one block, and the "void setup()"
3
LED connected to pin D13 is
on line (2) is the name of that block. In the same way, lines (7) to (12) make up another block, and the "void
turned ON
loop()" on line 6 is the name of that block. These kinds of blocks are referred to as "functions." Once you
make these functions, you will be able to execute the commands in the blocks. When execution of a function
ends, the Japanino executes the next process in order after the lines for calling out the function.
4
Sketch waits 1 second
There are always two certain functions in any sketch. Those functions are setup() and loop(). The setup()
function writes a code that can be executed, as desired, only when the sketch first begins operating, and the
5
LED connected to pin D13 is
loop()function writes the central code that can be executed repeatedly. Words and numbers inside the
turned OFF
parentheses,(), are referred to as "arguments." Comments written after the "//" are written so that the person
writing the code can remember what a line is for, or so that a third party can understand what a line is for,
6
Sketch waits 1 second
when the code is being read later on.
Below, let's take a look at the details of the content of each line.
7
Sketch returns to beginning of
the loop
(1) int ledPin = 13;/ Command for
(1)
instructing the Japanino to substitute a 13 in for
(2)
the number where the word "led" comes up.
Indicates that the LED is connected to pin D13.
(3)
(4)
(2) void setup()/ Specifies that the functions
(5)
in the lines below are functions that can be
executed once only, when the power is turned
(6)
on or the Japanino is reset.
(7)
(8)
(3){/ Indicates the start of a setup() function.
(9)
(10)
(4)pinMode(ledPin, OUTPUT);/ pinMode()
is a function for indicating ON/OFF for pins set
(11)
to outputs. Specifies ledPin = 13 (which already
(12)
specifies in (1) that 13 should be substituted in
for "led" automatically) as an OUTPUT, because
output pins are needed to control the LED.
(5) } / Indicates the end of a setup() function.
(6) void setup() / Specifies that the functions in the lines
below are functions that can be executed repeatedly.
(7) { / Indicates the start of a loop() function.
(8) digitalWrite(ledPin, HIGH); / digitalWrite() is a function
for indicating ON/OFF of pins set as outputs (in a sketch, ON is a
HIGH and OFF is a LOW). In this case, 5 V of electricity flows
through the pin D13 connected to an LED, and the LED is turned
on.
How to Use the Supplement
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // Sets output for digital pins
}
void loop()
{
digitalWrite(ledPin, HIGH); // Set the LED on
delay(1000); // Wait for a second
digitalWrite(ledPin, LOW); // Set the LED off
delay(1000);// Wait for a second
}
(9) delay(1000); / Indicates that operation of the Japanino is to
stop (is not to proceed to the following step, that is, is to
maintain the present state) only for the specified number of
milliseconds (1 millisecond is 1/1000 seconds). In this case,
because the number inside the parentheses, (), is 1000,
operation is to stop for 1 second.
(10) digitalWrite(ledPin, LOW); / Turns the LED off when pin
D13 is OFF (=LOW).
(11) Same as (9).
(12) } / Indicates the end of a loop() function.
10