background image

41

5.3.3. 

How a Light Sensor Works

Let’s take a look at your Light Sensor’s values. Use a USB cable to connect your Studuino to your PC. Now 
choose 

Test ON

 from the 

Run

 menu. Start Test Mode and you’ll see the Sensor Board displaying 

[A6] Light 

Sensor

.

The Light Sensor has a range of 0-100, with 0 being complete darkness and 100 being bright light. Now try 

covering the Light Sensor with your hand while you look at the Sensor Board to see how the values change.

Once you’re finished, choose 

Test OFF

 from the 

Run

 menu to close Test Mode.

5.3.4. Programming

Now we’re going to program your LED to turn on as the Light Sensor detects darkness.

We’ll also be learning how to use the 

 block.

 Drag 

 from the 

Control

 Palette to the Script Field.

The Light Sensor’s values will

change in response to the amount of 

light

Drag and drop

Содержание Studuino

Страница 1: ...Studuino Block Programming Environment Guide Part 01 LEDs Buzzers and Sensors Published 2014 11 01 Revised 2018 06 28...

Страница 2: ...version 2017 01 16 Updated for new Studuino website 2017 04 14 Changed access guide based on new Studuino website 2018 01 22 Revised to include software and OS updates 2018 06 28 Updated description o...

Страница 3: ...4 3 Playing a Buzzer 17 4 4 Playing a Melody 19 4 5 Using a List to Play Melodies 22 5 Push buttons and Sensors 31 5 1 Connecting an LED 31 5 2 Push buttons 31 5 2 1 Port Settings 32 5 2 2 How Push bu...

Страница 4: ...ch Sensor 52 5 5 2 Port Settings 52 5 5 3 How a Touch Sensor Works 53 5 5 4 Programming 53 5 6 Sound Sensors 56 5 6 1 Connecting a Sound Sensor 56 5 6 2 Port Settings 56 5 6 3 How a Sound Sensor Works...

Страница 5: ...ime 2 Setup 2 1 Installing Studuino Software Follow the steps below to download the instruction manuals you ll need to install your Studuino software 1 Go to the Studuino website at http www artec kk...

Страница 6: ...sensor is connected to A0 A3 The gray wires of your sensor connecting cables should face towards the center of the board Gray Black Black A4 A5 A6 A7 A0 A1 A2 A3 2 2 Connecting Parts Connecting Senso...

Страница 7: ...ervomotors can be connected to the Servomotor connectors The gray wires of your Servomotor cables should face towards the center of the board DC Motor connector M1 can t be used at the same time as Se...

Страница 8: ...to the POWER connector Sensors LEDs Buzzers and Push buttons can run on a USB connection but DC Motors and Servomotors require power from the Battery Box You ll also need a Battery Box in order to pow...

Страница 9: ...sor LED Buzzer connector A4 on your Studuino 3 2 Port Settings Before you start programming you ll need to tell the Block Programming Environment which Studuino ports you ll be using Open the Block Pr...

Страница 10: ...6 Click Click OK Check the box here Check A4 under Sensor LED Buzzer and choose LED You ve now set the Studuino ports you ll be using in the Block Programming Environment Choose LED...

Страница 11: ...d Palette Now drag to the Script Field and connect it to the block Drop the block once you see the white line Drag and Drop Command Palette Block Palette Make sure the block is connected Move blocks a...

Страница 12: ...er correctly if you see any of the messages below Check the solutions and try again Message Solution Could not access to Studuino Make sure Studuino is connected to the PC Make sure your USB cable is...

Страница 13: ...ver Click Control in the Command Palette then drag from the Control Palette to the Script Field Connect it to the blocks of your last LED program Right click on the block Now click Duplicate in the me...

Страница 14: ...ery second indefinitely Use a USB cable to connect your Studuino to your PC Now choose Transfer from the Run menu to transfer your program The LED will blink once every second once the transfer finish...

Страница 15: ...links based on the program from 3 4 Making an LED Blink This section will teach you how to set the number of repeats by using the block Drag from the Control Palette to the Script Field Move the block...

Страница 16: ...r to restore a block if you ve accidentally deleted it Connect the group of blocks you made in to the block Drag and drop Now you ve programmed your LED to blink ten times in a row Use a USB cable to...

Страница 17: ...will automatically blink the number of times you set You can start a transferred program by choosing Run from the Run menu Once you ve transferred a program you can run it using power from your Batte...

Страница 18: ...in the block let s try using a variable to change multiple values at once Open the Command Palette and click the Variables button Now click Make a variable You ll be asked for a variable name Name yo...

Страница 19: ...nd intervals Wait for time 0 5 seconds Wait time 0 5 seconds Click here and type Drag and Drop Drag and Drop Use a USB cable to connect your Studuino to your PC Now choose Transfer from the Run menu t...

Страница 20: ...ino Black Black Gray Keep an eye on your cables The gray wire should be at the top A5 Buzzer Gray Black Black 4 2 Port Settings Before programming you ll need to set the ports in the Block Programming...

Страница 21: ...d by using the and blocks Choose New under the File menu to open a new program Drag from the Motion Palette and connect it to the block Click in the block to show the keyboard Hover your mouse over an...

Страница 22: ...The note equivalent for each number is shown below Drag from the Control Palette and connect it to the block Drag and drop Drag from the Motion Palette and connect it to the block Now you ve programme...

Страница 23: ...Buzzer can do this by playing several notes in a row You ll need to add a block to the program you created in 4 3 Playing a Buzzer Set the blocks to 0 3 and 0 1 seconds Right click the block to duplic...

Страница 24: ...20 Repeat step to make seven groups of repeat blocks Delete the last block and drag any extra blocks back to the Command Palette to delete them Drag and drop...

Страница 25: ...ve programmed your Buzzer to play the melody for Twinkle Twinkle Little Star Use a USB cable to connect your Studuino to your PC Now choose Transfer from the Run menu to transfer your program Your Buz...

Страница 26: ...y using a list Making a List Click the Make a list button in the Variables Palette Now name it list_note You ll see two things an empty list and a group of blocks that control it These blocks control...

Страница 27: ...em to 0 12 and 15 Click and the blocks connected to will be run in order This will add the values 0 12 and 15 to the list Delete the blocks you made in Now connect the block to and set it to add 30 at...

Страница 28: ...g to the Script Field connect it to your program and set it to replace the number at row 3 with 6 Click Drag and drop A new second row with a value of 30 will be inserted into the list The value at ro...

Страница 29: ...eplace or delete values in a list You can also access the information in the list with the following blocks Block What it Does Gets the value of the specified row Gets the length of the specified list...

Страница 30: ...it seven times We can simplify this program by using a list to set the notes of the blocks Delete the block Now click the x on the right to delete all of the items in the list Click on any item in the...

Страница 31: ...the in the block and choose new Name the function init_code And now you ve made a function that will store the melody for Twinkle Twinkle Little Star to a list Any blocks connected to the block will r...

Страница 32: ...e and connect it to Now click to choose the init_code function Drag from the Motion Palette and connect it to Drag two from the Control Palette and set them to 0 3 and 0 1 Choose init_ code Drag and d...

Страница 33: ...he Make a variable button in the Variables Palette Name the variable number Drag and connect your new variable blocks to the places shown below Set the value of to 1 This dialog box lets you name the...

Страница 34: ...repeats so the number variable can play each note registered to the list in order Use a USB cable to connect your Studuino to your PC Now choose Transfer from the Run menu to transfer your program Th...

Страница 35: ...1 Connecting an LED You ll need to use an LED so go ahead and plug one into connector A4 on your Studuino 5 2 Push buttons You can find the Push buttons right on your Studuino They re assigned to conn...

Страница 36: ...og box Make sure that boxes A0 A3 are checked under Button and that you ve selected LED for Sensor LED Buzzer connector A4 and check the box if it isn t checked already 5 2 2 How Push buttons Work Let...

Страница 37: ...ET button on the Studuino board while in Test Mode will cause the connection between your Studuino and PC to be interrupted and the message below to appear Message Solution Could not acces to Studuino...

Страница 38: ...also be learning how to use the block Drag from the Motion Palette to the Script Field Drag from the Motion Palette to the Script Field Drag from the Control Palette and connect it to the bottom of yo...

Страница 39: ...5 Set the new block to OFF Now connect your duplicated blocks to the original ones Drag from the Control Palette to the Script Field Fit the blocks from into the opening of Drag and drop Drag and drop...

Страница 40: ...36 Set the number of repeats to 2 Drag from the Control Palette to the Script Field Drag from the Operators Palette and add it to the block Drag and drop Drag and drop...

Страница 41: ...nto the left side of the block Set the right side to 0 Move the blocks from into the opening of the block The block you just made will make your LED blink twice when you press the Push button and chan...

Страница 42: ...ks from into the opening of the block Connect the group of blocks you made in to the block Now you ve programmed your LED to blink two times when you press button A0 Drag and drop Drag and drop Drag a...

Страница 43: ...ctly if you see any of the messages below Check the solutions and try again Message Solution Could not access to Studuino Make sure Studuino is connected to the PC Make sure your USB cable is properly...

Страница 44: ...ramming Environment to match the parts connected to your Studuino Select Edit from the menu and choose Port Settings to open the Port Settings dialog box Check A6 under Sensor LED Buzzer and choose Li...

Страница 45: ...darkness and 100 being bright light Now try covering the Light Sensor with your hand while you look at the Sensor Board to see how the values change Once you re finished choose Test OFF from the Run m...

Страница 46: ...side of the block Set the right side to 50 Since your Light Sensor values respond to the amount of light in the room look at the Sensor Board to decide which value to put into the right side Drag from...

Страница 47: ...Sensor value is less than 50 and turn it off when the room is bright Light Sensor value is greater than 50 Drag to the Script Field Move the blocks from into the opening of the block Connect the group...

Страница 48: ...Test Mode click Never disconnect your USB cable while in Test Mode The blocks currently running will have a white outline Take a look at the Sensor Board as you cover the Light Sensor with your hand a...

Страница 49: ...programming you ll need to set the ports in the Block Programming Environment to match the parts connected to your Studuino Select Edit from the menu and choose Port Settings to open the Port Settings...

Страница 50: ...ject becomes closer The values will be at their maximum when 6 10 mm away from an object and will decrease again as you move it closer to the object The color and texture of an object will also have a...

Страница 51: ...Photoreflector We ll also be learning how to use the block Drag from the Motion Palette to the Script Field Drag from the Control Palette and connect it to the bottom of your program Click the block...

Страница 52: ...48 Set the new block to OFF Now connect your duplicated blocks to the original ones Drag from the Control Palette to the Script Field Drag and drop...

Страница 53: ...and drop it into the left side of the block Set the right side to 15 Now move the blocks from into the opening of the block The block you just made will blink your LED when an object becomes closer th...

Страница 54: ...m the Motion Palette and connect it to Now set it to OFF Connect the group of blocks you made in to the block Now you ve programmed your LED to blink when an object is close If an object is close Blin...

Страница 55: ...k Now look at the Sensor Board as you bring the object closer and check that the LED blinks when the value goes over 15 Choose Transfer from the Run menu to transfer your program to your Studuino Now...

Страница 56: ...oose Touch Sensor You ll also need to check A4 and choose LED 5 5 Touch Sensors A Touch Sensor is a kind of switch that detects whether or not you press it You can use one to detect things like collis...

Страница 57: ...nd a value of 0 when you press them Now try pressing your Touch Sensor while looking at the Sensor Board to see how the values change Press the Touch Sensor and the value will change to 0 Once you re...

Страница 58: ...54 Drag from the Control Palette and connect it to Drag from the Operators Palette and into the block Drag and drop Drag and drop...

Страница 59: ...onnect it to the other blocks Drag and drop Drag and drop Now you ve programmed your LED to light up when you press the Touch Sensor Make sure your Studuino is connected to your PC Now choose Transfer...

Страница 60: ...ire should be at the top LED Sound Sensor 5 6 2 Port Settings Before programming you ll need to set the ports in the Block Programming Environment to match the parts connected to your Studuino Select...

Страница 61: ...increasing towards 50 as sounds become louder Try clapping near the Sound Sensor or blowing directly on it as you look at the Sensor Board to see how the values change Values change in response to vol...

Страница 62: ...58 Drag from the Control Palette and connect it to the other blocks Drag and drop Click the block and choose duplicate Set the new block to OFF Uncheck Select Duplicate This will duplicate the blocks...

Страница 63: ...59 Now connect your duplicated blocks to the original ones Drag from the Control Palette to the Script Field Drag and drop...

Страница 64: ...he Operators Palette into the block Drag from the Sensing Palette and drop it into the left side of the block Set the right side to 30 Move the blocks from into the opening of the block Drag and drop...

Страница 65: ...ells a blinking LED to turn off when you blow on the Sound Sensor and the value goes over 30 Connect the group of blocks you made in to the block Drag from the Motion Palette and connect to the block...

Страница 66: ...you ve opened Test Mode click Never disconnect your USB cable while in Test Mode Now look at the Sensor Board as you blow on the Sound Sensor and check that the LED turns off when the value goes over...

Отзывы: