background image

19

4.4. 

Playing a Melody

Now it’s time to program your Buzzer to play the notes C, C, G, G, A, A, and G, the melody for Twinkle, 

Twinkle, Little Star. The 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 duplicate it. Now connect the new blocks to the 

original ones. 

Drag and drop

Right click 

Choose Duplicate

Connect the duplicated 
blocks to the originals

Summary of Contents for Studuino

Page 1: ...Studuino Block Programming Environment Guide Part 01 LEDs Buzzers and Sensors Published 2014 11 01 Revised 2018 06 28...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Page 63: ...59 Now connect your duplicated blocks to the original ones Drag from the Control Palette to the Script Field Drag and drop...

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

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

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

Reviews: