background image

9

Otona

 

no 

Kagaku

10

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. 

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. 

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). 

If completed successfully, the [Done uploading]  message appears. 

IMPORTANT 

For Mac

If 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.

To bring up a saved sketch, open [File]  [Sketchbook] , and select 
the desired file from the folder.

Basic principal 2

Making other LEDs blink

Basic principal 3

Changing  the  time  of  the  LED 

flashing 

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. 

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. 

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.

To edit the sketchbook…

To save the sketch you made…

1) In [File]  [Save as] , assign a name to the sketch and save it to the 

[Sketchbook] . 

3) Once the sketch has been saved, the [Saved]  message will 

appear at the bottom of the Sketch screen. 

2) Check the save destination location, and assign a name to the 

sketch. 

Description of a Sketch Used to Make One LED Flash

Details of the sketch to be operated

1

  Sets pin D13 to an output 

   (in the first step only)
   

2

  Sketch enters a loop

     

3

  LED connected to pin D13 is 

turned ON

     

4

  Sketch waits 1 second

     

5

  LED connected to pin D13 is 

turned OFF

     

6

  Sketch waits 1 second

     

7

  Sketch returns to beginning of 

the loop

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 
becomes more complex. First, "Flashing of one LED ([Blink] in the [Digital] section of the sketch example)" is 
described here. 
As a basic structure, this sketch has two blocks. Actually, parts enclosed in the curly brackets,

 { }

, are the 

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()

on line (2) is the name of that block. In the same way, lines (7) to (12) make up another block, and the "

void 

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. 
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 

loop()

function writes the central code that can be executed repeatedly. Words and numbers inside the 

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, 
when the code is being read later on. 
Below, let's take a look at the details of the content of each line. 

(1) 

int ledPin = 13;

/ Command for 

instructing the Japanino to substitute a 13 in for 

the number where the word "led" comes up. 

Indicates that the LED is connected to pin D13.

(1) 
(2)
(3)
(4)
(5) 
(6) 
(7) 
(8)
(9) 

(10)
(11)
(12) 

(2) 

void setup()

/ Specifies that the functions 

in the lines below are functions that can be 

executed once only, when the power is turned 

on or the Japanino is reset. 

(4)

pinMode(ledPin, OUTPUT);

pinMode() 

is a function for indicating ON/OFF for pins set 

to outputs. Specifies ledPin = 13 (which already 

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. 

(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. 

(3)

{

/ Indicates the start of a setup() function. 

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

}

How to Use the Supplement

Содержание Japanino

Страница 1: ... and the Japanino reverts to initial conditions however heat will again be generated until the cause of the problem is eliminated Because not knowing the cause of the malfunction could lead to accidents please stop discontinue use in such cases you might burn yourself if you touch the resettable fuse while it is generating heat The part on the Japanino labeled 5V provides about 4 6 V of voltage du...

Страница 2: ...Tighten down the loosened cable holder once again 6Attach the handle gear and handle knob from the front side with washer head screws to complete One cable holder comes already attached to the main unit casing as shown in the picture below This cable holder is to be loosened Attach stand A and stand B by screwing in screws in four places as shown in the diagram Turn the handle clockwise to lightly...

Страница 3: ...dicator LED Reset button IC chip ICSP terminal Pin D13 activity indicator LED IC chip Overcurrent protection Resettable Fuse Place for connecting the battery box The battery box becomes a 5 V to be exact a 4 5 V power supply Button for resetting the exchange etc of data Sometimes used for writing etc of sketches for Mac A terminal used for writing etc to a boot loader Not normally used An Atmel mi...

Страница 4: ...at the COM port number assigned for the Japanino is the same on the PC and in the IDE and that the IDE recognizes that the connected Micro Computer is a Japanino If this is not done you will not be able to upload sketches programs to the Japanino Please make sure to confirm that this is done If using two or more Japanino units you will need to check the COM port numbers for each when inserting the...

Страница 5: ...the number of grammar rules used increases as the sketch becomes more complex First Flashing of one LED Blink in the Digital section of the sketch example is described here As a basic structure this sketch has two blocks Actually parts enclosed in the curly brackets are the 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...

Отзывы: