View
216
Download
0
Category
Preview:
Citation preview
Credits
Design Team MitchelResnick BrianSilverman PaulaBontá RobbieBerg NatalieRusk
Industrial Design: SmartDesign
Graphic Design: BigBlueDot
Wewouldliketogivespecialthanksto:
PICOstaffmembersChadBurt,CatherineCournoyer,JackGeddes,MikeGillis,DannyLutz,DanielleHamel,andLaurelleMiciakfortheirinvaluableideas,help,andenthusiasm.
DianaGeeSilvermanfortheon-linehelp,DannyLutzforthesounds,andLawrenceShubertforguidingPICOthroughtheintricateaspectsofcompliancetestingandmanufacturability.
stafffromthePlayfulInventionandExploration(PIE)projectfordevelopingnewCricketactivities,particularlyKeithBraafladt,StephanieHunt,ChipLindsey,HidekiMori,KristenMurray,MikePetrich,MargaretPezalla-Granlund,NatalieRusk,MichaelSmith-Welch,KarenWilkinson,andDianeWillow.
MITresearchersandstudentswhocontributedtoCricketR&D,particularlyAndyBegel,RobbieBerg,RahulBhargava,RickBorovoy,FredMartin,BakhtiarMikhak,MitchelResnick,andBrianSilverman.
theLEGOCompanyforitscontinuingsupport,particularlyKjeldKirkKristiansen,LisbethValtherPallesen,JensMaibom,andErikHansen.
©2006-2008.ThePlayfulInventionCompanyInc.Allrightsreserved.Thismaterialmaynotbereproduced,displayed,modified,ordistributedwithouttheexpresspriorwrittenpermissionofthecopyrightholder.
Contents
Credits 2lntroduction 4PicoBlocks 8Blocks Summary 12Blocks - Detailed by Category 14Melody and Rhythm Editors 32Graphing Data 37The PicoBlocks Text Language 38Common Error Messages 52
PicoBlocks - Reference�
lntroduction
Welcome!ThisReferenceGuideprovidesanoverviewofthePicoCricketfamilyofpartsandthePicoBlockssoftwareusedtoprogramthePicoCricket.
IfyouarejustgettingstartedwiththePicoCricketandPicoBlocks,pleasegothroughtheSetupGuideandGettingStartedbookletfirst,togetanoverallintroduction.Ifyouwantmoredetailedinformation,thencomebacktothisReferenceGuide.
WearecontinuallyupdatingtheReferenceGuide.Youcandownloadthelatestversionfromwww.picocricket.com/support
PicoCricket Family
ThePicoCricketfamilyincludesthefollowingparts:
PicoCricket
ThePicoCricketisatinycomputerthatcancontrolthingsintheworld.ThePicoCrickethasfourportswhereyoucanpluginotherdevices,suchassensors,motors,andlights.Youcanpluganyofthesedevicesintoanyoftheports.
PicoBlocks - Reference �
ThePicoCrickethasthreetypesofindicatorlights:
Theon-off indicator lightturnson(orange)whenyouturnonthePicoCricket.Ifthebatteriesarelow,thelightflashesrapidlywhenyouturnonthePicoCricket.
Theprogram-running indicator lightturnson(green)whenthePicoCricketisrunningaprogram,anditchangescolortoamberwhenthePicoCricketisrunningtwoprogramsatthesametime.
TheIR-communication indicator lightsflash(yellow)whenthePicoCricketiscommunicatingthroughitsinfraredtransmitter.
IfyoupushthePicoCricketbuttonwhilethePicoCricketisrunningaprogram,theprogramwillstop.Ifyoupushthebuttonwhennoprogramisrunning,thePicoCricketwillre-runthelastprogramthatitran.
EvenwhenyouturnthePicoCricketoff,itremembersthelastprogramthatitran.Soifyourunaprogram,turnoffthePicoCricket,turnitbackonlater,andpushthebutton,thePicoCricketwillruntheprogramagain.
Beamer
TheBeamertransmitsinformation(viainfraredsignals)fromyourcomputertoyourPicoCricket.WhenyouwriteaprogramusingPicoBlockssoftwareonyourcomputer,yousendtheprogramtothePicoCricketviatheBeamer.
PicoBlocks - Reference�
ThePicoCricketKitincludesaUSB-serialcableforconnectingtheBeamertoaUSBportonyourcomputer.Alternatively,youcanconnecttheBeamertoaserialport,usingastandardserialcable(notincluded).
WhenyouaresendinginformationtothePicoCricket,makesurethattheantennasontheBeamerarefacingtowardstheantennasonthePicoCricket.WhiletheBeamerandPicoCricketarecommunicating,theindicatorlightsintheantennaswillflashyellow(onboththeBeamerandthePicoCricket).
TheBeamerhasarangeofabouta1meter.NotethataBeamercancommunicatewithonePicoCricketatatime.IfyouhavemultiplePicoCrickets,makesurethatonlyoneofthemisinrangeoftheBeameratanytime.
Actuators
Actuatorsaredevicesthatmakethingshappenintheworld.ThePicoCricketKitincludesfourtypesofactuators:coloredlights,soundbox,motor(withmotorboard),andnumericdisplay.
Name Description Programming Blocks Icon
Light Youcansetthecolorofthelightacrosstheentirerainbow,fromredtoviolet.Youcanalsosetthebrightnessofthelight.
SoundBox
Thesoundboxisasmallsynthesizerthatcanplaynotes,melodies,soundeffects,andrhythms.PicoBlockssoftwareincludesspecialeditorsforcreatingmelodiesandrhythms.Youcansetandchangewhichinstrumentwillplaynotesandmelodies.
note
Motorand
MotorBoard
ThemotorboardconnectstothePicoCricket,andtheLEGOmotorconnectstothemotorboard.Youcanturnthemotoronandoff,andsetitspoweranddirection.
DisplayThethree-digitdisplaycanshowanynumberbetween0and999.Itisespeciallyusefulfordisplayingsensorvalues.
PicoBlocks - Reference �
Sensors
SensorsallowyourPicoCrickettorespondtosounds,lights,orotherchangesinitsenvironment.
Name Description Programming Blocks
Icon
LightSensor
Reportsthebrightnessoflight.Forexample,youcanusethelightsensortodetectwhensomeonecastsashadowwiththeirhand–orwhenthesunshinesthroughthewindow.
dark?
brightness
SoundSensor
Reportstheloudness(orvolume)ofsound.Forexample,youcanusethesoundsensortodetectwhensomeoneclapstheirhands–orwhensomeonesingsintothesensor.
loud?
loudness
TouchSensor
Reportsifthebuttonispressed.Forexample,youcanwriteaprogramthatmakessomethinghappen(amotorspinningoralightchangingcolor)whensomeonepressesthetouchsensor.
touch?
ResistanceSensor
Reportstheresistanceinthecircuitformedbythealligator-clipcables.Ifyouputdifferentmaterials(forexample,play-doughorabanana)betweenthealligatorclips,theresistancewillchange.Youcanalsousetheresistancesensortodetectwhenthealligatorclipsaretouchingeachother(orconnectedthroughaconductivematerial,suchasaluminumfoil).
connected?
resistance
Eachoftheprogrammingblockswillbedescribedfurtherinthefollowingpages.Forexamplesofhowtousetheactuatorsandsensors,see“MagicLantern”andothersampleprojectplacemats.
PicoCricket Care
1.RemembertoturnoffthePicoCricketwhenyouaren’tusingit.
2.Iftheorangeon-offindicatorlightflashes,itmeansthatyourPicoCricketisrunningoutofbatteries.Tochangethebatteries,followtheinstructionsintheSetupGuide.
3.Begentlewiththecableconnectors.Ifyoupushtheconnectorsupanddownwithtoomuchforce,theconnectorswillbreak.
4.KeepyourPicoCricketdevicesawayfromwaterandotherliquids.
5.IfyourPicoCricketismisbehaving,checktheTroubleshootingsectioninourwebsite:www.picocricket.com/troubleshooting
PicoBlocks - Reference �
PicoBlocks
Overview
PicoBlocksisaprogramminglanguagedesignedspecificallyforprogrammingyourPicoCricket.WithPicoBlocks,youcreateprogramsbysnappinggraphicalblockstogetherintostacks.
Tools
?? STOPUndo
2
Thetoolsareusedfortakingdifferentactionsontheblocks,suchascopyingblocks,deletingblocks,orsendingblockstothePicoCricket.Whenyouclickonatool,thecursorturnsintothattool.
Arrow
UsetheArrowtodragblocksfromtheBlocksPalettetotheWorkspace,orwithintheWorkspace.Tomoveanentirestack,dragfromthetopblock.Draggingablockfromthemiddleofastackwillalsomoveanyblocksattachedbeneaththeoneyouaredragging.
YoucangetridofblocksbydraggingthemoffoftheWorkspace,inanydirection.Ifyoudeleteblocksbymistake,clickUndo
ThisisyourWorkspaceDraganddropblockstocreateyourstacks
These are the tools
Click on the tabs to get different categories of blocks
This is a stack
BlocksPalette
PicoBlocks - Reference �
Magic Wand
UsetheMagicWandtorunaprogram.WhenyouclickonablockorstackwiththeMagicWand,itsendstheprogramtothePicoCricketandtellsthePicoCrickettoruntheprogram.
chirp
foreversetlight color
brightness
YoucanusetheMagicWandtoclickonblocksintheBlocksPalette,thesamewayyouclickonblocksintheWorkspace.Thisfeatureisusefulfortestingoutablock.
Anotherwaytorunaprogramisbydouble-clickingwiththeArrow,insteadofsingle-clickingwiththeMagicWand.
Scissors
UsetheScissorstogetridofblocks.Clickingonablockinastackwillalsocutallblocksattachedbelowit.
Ifyoudeleteblocksbymistake,clickUndo .
YoucanalsogetridofblocksbydraggingthemoutoftheWorkspace.
waituntil
motoron
reverse
motoronfor
touch?
10
waituntil
motoron
touch?
Stamper
UsetheStampertocopyblocksandstacks.Clickoncetocopy,thenmovetoanewlocationandclickasecondtimetopaste.WhenyouclickonablockinastackwiththeStamper,italsocopiesallblocksattachedbelowit.
YoucanswitchtotheStampertemporarilyusingCtrl+ ,or + .
waituntil
motoron
reverse
motoronfor
touch?
10reverse
motoronfor 10
PicoBlocks - Reference 10
?? Help
UsetheHelptooltogetmoreinformation.IfyouclickonablockwiththeHelptool,awindowwithmoreinformationwillappear.
2 Second Wand
UsetheSecondWandtotellthePicoCrickettorunasecondstackatthesametimeasitisrunningsomethingelse.Toruntwostacks,clickononewiththeMagicWand,thentheotherwiththeSecondWand.
Forexample,youcanusetheSecondWandtostartbackgroundmusicordisplaysensorvalueswhileanotherprogramisrunning.
melody12
display
forever brightness2
Tags
UsetheTagstoolwhenyouwanttotelltwodevicesofthesametypetododifferentthings.Forexample,ifyouplugtwocoloredlightsintoaPicoCricket,andthensendasetlight-colorcommandtothePicoCricket,thePicoCricketwillchangethecolorofbothlights.Ifyouwanttoturneachlighttoadifferentcolor,youneedtouseTags.
setlightcolor
wait 10
setlightcolor
wait 10
??
PicoBlocks - Reference 11
EachofthefourportsonthePicoCricketislabelledwithadifferentnumberofdots.Ifyouwanttosendacommandtoaparticularport,thenyouneedto“tag”theblockwiththeappropriatenumberofdots.Forexample,ifyouplugcoloredlightsintoports and ,thenyoucansetthecolorofeachlightindividuallywiththefollowingblocks:
setlightcolor
setlightcolor
Totagablock,clickontheappropriatedotintheTagstool,thenclickontheblockthatyouwanttotag.
setlightcolor
Toremoveatagfromablock,clickinthecenteroftheTagstoolandthenclickontheblock.
setlightcolor
STOP Stop
ClickontheStopsigntostopallprogramsrunningonthePicoCricket.MakesurethatthePicoCricketis“insight”oftheBeamer.Alternatively,youcanstopprogramsonthePicoCricketbypressingthewhitebuttononthePicoCricket.NotethatstoppingprogramsonthePicoCricketdoesnotturnofflightsattachedtothePicoCricket.Ifyouwanttoturnoffthelights,slidetheon-offswitchintotheoffposition.
PicoBlocks - Reference12
Blocks Summary
ThislistshowsallofthebasicblocksinPicoBlocks.
setlight color setsthelight’scolor
setlight power setsthelight’spower
lightoff turnsthelightoff
displaydisplaysavalueonthedisplay
chirp makesthePicoCricketchirp
note playsanote(pitchandduration)
playsound
Kitten playsasound
setinst
Piano setsaninstrumentforthenextnoteormelody
settempo
set
volume
setsthetempoorvolumeforthenextnote,melodyorrhythm
motoron motor
off turnsmotoronoroff
motoronfor
turnsthemotoronforacertainperiodoftime
reverse reversesthemotor’sdirection
thisway that
way setsthemotor’sdirection
setpower setsthemotor’spower
touch?reportstrueifthetouchsensoris
pressed
brightness reportsavaluefromthelightsensor
dark? reportstrueifthelightsensordetectslittlelight
loud?reportstrueifthesoundsensor
detectsaloudsound
loudness reportsavaluefromthesoundsensor
connected? reportstrueiftheresistancesensordetectsaresistanceof0
resistance reportsavaluefromtheresistancesensor
beamIR beamsavaluetoanotherPicoCricket
IRreportsavaluebeamedby
infraredfromanotherPicoCricket
newIR? reportstrueifanotherPicoCrickethasbeamedanewvaluebyinfrared
timer reportsthePicoCricket’stimervaluein100thsofasecond
resettimer
setsthePicoCricket’stimerto0
clear erasesallthedata
collectstoresavalueinthePicoCricket’s
memory
rewind goesbacktothebeginningofthedata
next data reportsthevalueofthenextdatastoredinthePicoCricket’smemory
waitwaitsanumberofticks(where10
ticks=1second)
waituntil waitsuntiltheconditionistrue
foreverrepeatsablockorstack
forever
repeatrepeatsablockorstack
acertainnumberoftimes
PicoBlocks - Reference 13
Blocks Summary - Continued
if
then
runsablockorstackiftheconditionistrue
if
then else
ifconditionistrue,runonestack;ifnot,runtheotherstack
stopall stopseverything
stackstop stopsthisstack
createsspacebetweenblocks, sothattheydon’toverlaponeanother
number specifiesanumber(clicktohighlight,andthentypeinanumber)
+ - x / computesarithmeticoperations
r a n d o mpicksarandomvaluebetweenthetwonumbers
<>
makesacomparisonbetweentwonumbersandreportstrueorfalse
=
and reportstrueifbothconditionsaretrue
or reportstrueifeitherconditionistrue
not reportstheoppositeofacondition
sitsontopofstack,andallowsyoutotypeinnameforthestack
store inbox1 box1 setandreportvaluesforvariables
store inbox2 box2
PicoBlocks - Reference1�
Blocks - Detailed by Category
Light Blocks
setlight color
whichcolor
wait
setlight color
5
4
setlight color
turnsthelightblue
waitsfor4ticks
turnsthelightpink(color5)
SetstheLED’scolorandturnsiton.Youcansetthecolorbyusingthecolorslider,orchoosinganumberbetween0and100.Colorsarenumberedasfollows:
Defaultvalue:setlightcolor 0
setlight power
howbright
setlight power
wait 40
setlight power 100
setslighttohalfpowerandturnsiton
waitsfor40ticks
setslightbacktofullpower
setlightpowercantakenumbersbetween0(nolight)and100(fullpower).Youcansetthepowerbyusingtheslideroranumberblock.Defaultvalue:setlightpower 100
lightoff
wait
setlight color
15
lightoff
turnsthelightgreen
waitsfor15ticks
turnsthelightoff
lightoffturnsthelightoff.
pinkredyellowaqualightblueviolet020406080100
1030507090magentaorangegreencyanblue
PicoBlocks - Reference 1�
display
displaywhat
r a n d o m
display 15 95 displaysarandomnumber
Displaysavalueonthedisplay
Sound Blocks
TheSoundpalettestartswithsixbasicblocks(shownbelow).YoucancreateadditionalblockswiththeMelodyandRhythmeditors.Seepage32forinformationoncreatingmelodiesandrhythms.
chirp makesthePicoCricketchirponce
MakingthePicoCricketchirpisagoodwaytotestwhetheryourcomputeriscommunicatingproperlywiththePicoCricket.
note howhighanote
note5
50playsthenote50
for5ticks(halfasecond)
howlongnotecanplaynotesbetween0(lowest)and100(highest).YoucanplaynoteswiththePicoCricketspeakerorwiththeSoundBox(butitwillsoundmuchbetterwiththeSoundBox).Forcomposingmelodies,wesuggestusingtheMelodyEditorratherthanputtingindividualnoteblockstogether.Defaultvalue:note 50 2
playsound playsthissound(kitten)
playsound
Kitten
23playsound playssound23(horse)
Selectasoundwiththesliderorenteranumberbetween0and100.Thereare24soundsavailable(seetablebelow).
PicoBlocks - Reference1�
# Sound # Sound # Sound
1 Piano 9 Claps 17 PicoCricket
2 Flute 10 Cowbell 18 Fairydust
3 Pizzicato 11 Maracas 19 HighQ
4 Strings 12 Slap 20 Dog
5 Trombone 13 Timbale 21 Rooster
6 Vibes 14 WoodBlock 22 Goose
7 Agogo 15 Guiro 23 Horse
8 Cabasa 16 Bloops 24 Kitten
AllthesesoundsrequiretheSoundBox.Sound0isthePicoCricketchirp.Fornumbersgreaterthan24,playsoundplaysthenextsoundinthelist:25playssound1,26playssound2,...andsoon.Defaultvalue:playsound 24 (kittten)
setinst setinstrumentwhichinstrument
5
16
setinst
Trombone
note
setsinstrumenttotrombone
playsnote16(onthetrombone)for5ticks(halfasecond)
Setstheinstrumenttobeusedforsubsequentnotesormelodies.Youcanselecttheinstrumentwiththesliderorattachanumberbetween0and100.setinstrument 0setsthenoteormelodywiththePicoCricket’sbeeper.Theinputsforsetinstrumentarethesameasforplaysound(shownintableabove).Youcanuseanysoundasaninstrument,buttheydon’tallworkwell.Defaultvalue:setinstrument 1 (piano)
settempo
melody1
settempo 100 setstempoto100(fastest)
playsmelody1atthefastesttempo
settempotakesvaluesbetween0(slowest)and100(fastest).Thefastesttempo(100)equalsto240bpm(beatsperminute),whiletheslowest(0)equalsto60bpm.Defaultvalue:settempo 50 (120bpm)
PicoBlocks - Reference 1�
setvolume
30
5
50note
setvolume
setsthevolumeto30(quiet)
playsnote50for5ticks(halfasecond)
setvolumetakesvaluesbetween0(nosound)and100(loudest).SetvolumeonlyworkswiththeSoundBox.Defaultvalue:setvolume 80
Action Blocks
motoron
motoroff
motoron
motoroff
wait 20
turnsthemotoron
waitsfor20ticks(2seconds)
turnsthemotoroff
motoroffmakesthemotorcoasttoastop.Ifyouwantthemotortostopmoreabruptlyormoregently,tryusingthebrakeandcoastcommandsinthePicoBlocksTextLanguage.
motoronfor howlong
motoronfor 20 turnsonmotorfor20ticks(2seconds)
10ticks=1secondTurnsthemotoronforthespecifiednumberofticks,thenturnsitoff.motoronfordoesthesamethingasastackwithmotoron,thenwait,thenmotoroff.Defaultvalue:motoronfor 10
reverse
reverse
motoronfor 20
motoronfor 40
motorgoesonewayfor20ticks
changesdirection
goestheotherwayfor40ticks
reversecausesthemotortochangethedirectioninwhichitisspinning.reversedoesnotturnthemotoron,itonlychangesthedirection.
PicoBlocks - Reference1�
thisway
thatway
thisway
thatway
motoronfor 10
motoronfor 10
setsmotortoonedirection
turnsonfor10ticks
setsmotortotheoppositedirection
turnsonagainfor10ticks
thisway setsthemotorinonedirection,thatway setsitintheotherdirection.Whichdirectioniswhichdependsonhowthemotorispluggedin.thiswayandthatwaydonotturnonthemotor,theyonlysetthedirection.
setpower
setpower 10
motoron
setsmotorpowerto10
turnsthemotoron
setpowertakesvaluesbetween0(nopower)and100(strongestpower).setpowerdoesnotturnonthemotor,itonlysetsthepower.Defaultvalue:setpower 100
Sensors Blocks
touch? isthetouchsensor
if
then
forever touch?
chirp
beingpressed?
chirpsifthetouchsensorispressed
touch? reportstruewhenthetouchsensorisbeingpressed.TheexampleabovewillmakethePicoCricketchirpcontinuouslywhileyouarepressingthebuttononthetouchsensor.Ifyouwanttochirponlyonceeachtimeyoupushthebutton,youshouldmakeastacksimilartotheoneshownbelow:
PicoBlocks - Reference 1�
foreverwaituntil touch?
touch?waituntil not
chirp
waitsuntilthetouch sensorisreleased
dark?
waituntil dark?
playsound
Dog
waitsuntilthelightsensordetects darkness
playsthissound(dog)
dark?reportstrueifthelightsensordetectsthebrighnesstobelessthan15.
brightness
brightnessdisplay displaysthenumberreportedbythelightsensor
brightnessreportsnumbersbetween0(nolight)and100(lotsoflight)
loud?
loud?
setlight color
waituntilwaitsuntilthesoundsensor
detectsasound
turnsthelightpink
loud?reportstrueifthesoundsensordetectsasoundwithloudnessgreaterthan60.
loudness
waituntil > loudness 30
setlight color
waitsuntilthesoundsensordetectsaclap
turnsthelightgreen
loudnessreportsnumbersbetween0(nosound)and100(loudsound).
PicoBlocks - Reference20
connected?
foreverwaituntil connected?
chirp
waitsforresistancesensor todetectaconnection
whenaconnectionissensed,itchirps
connected? reportstrueiftheresistancesensordetectsaresistanceoflessthan50.
resistance
foreverdisplay resistance
displaysthenumberreported bytheresistancesensor
resistancereportsnumbersbetween0(noresistance)and100(lotsofresistance).Ifyouaregettingnumbersinaverynarrowrange,itisusefultoadjusttherangeandsensitivityoftheresistanceblock.Todothat,shiftclickontheblocktoaddsliders.Thenadjustthesliderslikethis:
resistance trythisifyouaren’tgettinglownumbers
resistancetrythisifyouaren’tgettinghighnumbers
Remembertousethemagicwandaftermovingthesliders
Slidersareusefulinsituationswhereyouwanttouseresistancevaluescontrolsomethinglikethecolorofalight:
forever resistancesetlight
color
Iftheresistanceischangingbyonlyasmallamount,youwillonlyseeanarrowrangeofcolors.Youcanusesliderstoextendtherangeofcolorsthatyouseeastheresistancechanges.
Toseehowthisworks,consideraspecificexample.Imaginethatyouconnectaresistancesensor,acoloredlightandadisplaytoyourPicoCricket.ThenconnectthealligatorclipsoftheresistancesensortoalumpofPlay-Doughandstarttheprogram:
forever resistancesetlight
color
display resistance
PicoBlocks - Reference 21
SupposeyoufindthatasyousqueezethePlay-Dough,thenumbersonthedisplayvaryoverthenarrowrangefrom40and80.Thecolorofthelightwillchangefromyellowtoblue/green.
Bymovingslidersintothepositionsshownbelow–withtheleftslideratthe40positionandtherightslideratthe80position,youwillexpandtherangeofnumbersonthedisplaytostretchallthefrom0to100,andthelightcolorwillvaryfromredthroughpurple.
foreversetlight color
display
resistance40 80
resistance40 80
beamIR
beamIRforever
wait 10
r a n d o m
0 100 beamsanumberbetween 0and100
beamIR beamsanumbertoanotherPicoCricketviainfrared(IR).Tousethiscommand,youneedtwoPicoCrickets:onebeamingtheIRsignal,theotherreceivingtheIRsignal.SeeexampleforIRblockbelow.Werecommendusingnumbersintherange0to100.Numbersoutsidethisrangemayproduceunexpectedresults.
newIR? IR
newIR?
IR
foreverwaituntil
10note
waitsforanewIRmessagefromanotherPicoCricket
playsanotebasedonthenumberreceived
IRstandsforInfraRed.newIR?reportstrueifanewinfrared(IR)signalhasbeenreceived.IRreportsthevalueofthelatestinfraredsignalreceived.
PicoBlocks - Reference22
resettimer timer
resettimer
waituntil > timer 500
motoron
waitsuntilthetimer isgreaterthan500
turnsonmotor
100ticksofthetimerequals1second
Data Blocks
clear
collect
collect
clear
200repeat
brightness
wait 1
storethenumberreportedbythe lightsensorinthePicoCricket’smemory
wait1tick(1/10second)before collectingthenextdatapoint.
collectstoresadatapoint(anumberfrom0to100)inthePicoCricket’smemory.A
PicoCricketcancollectupto200datapoints.Clickon graph toseeagraphofthecollecteddata.
rewind next data
next data
rewind
200repeat
wait 1
setlight color
setthecolorofthelighttothevalueof thenextdatathathasbeenstoredinthe PicoCricket’smemory
wait1tick(1/10second)before playingbackthenextdatavalue
rewindpreparesthePicoCricketto“playback”collecteddata,startingwiththefirstdatapoint.
setstimerto0
eraseallthedataHowmanydatapointsdoyouwanttocollect?
gobacktothebeginningofthedata
PicoBlocks - Reference 23
nextdatareportsthevalueofthenextnumberstoredinthePicoCricket’smemory.Uponreachingtheendofthecollecteddata,nextdataloopsbacktothebeginningofthedata.
Whenarewindblockisfollowedbyacollectblock,thePicoCricketstartscollectingnewdata,permanentlyerasinganyolddata.
Flow Blocks
wait
wait 20
lightoff
setlight color turnsthelightpink
waitsfor20ticks(2seconds)
turnsthelightoff
10ticksequals1secondDefaultvalue:wait 10
waituntil
touch?
motoron
waituntil
motoroff
turnsonmotor
waitsuntilthetouchsensorispressed
turnsoffmotor
Waitsuntil theconditionistrue.
PicoBlocks - Reference2�
forever
motoronfor
wait 3
3forever
repeatthisforever
Tostoptheforever,pushthebuttononyourPicoCricketorclickon STOP
repeat
howmanytimes
10
motoronfor
repeat
4
reverse
repeatthis10times
if
then
ifthisistrue...
if
then
chirp
connected?forever
thiswillhappen
placeherewhateveryouwanttodoaftertheiffinishes
Iftheconditionreportstrue,thenthePicoCricketwillruntheblocksbelowtheword“then.”
placeherewhateveryouwanttodoaftertherepeatfinishes
PicoBlocks - Reference 2�
if
then else isthistrue?
if
then else
motoron
motoroff
touch?forever
otherwisedothis iftrue,dothisIftheconditionreportstrue,thenruntheblocksundertheword“then”;ifnot,runtheblocksunder“else”.
stopall
if
then
forever
motoron
stopall
touch?
chirp
ifthisistrue...
everythingstops(includingthemotor)
Stopsallprogramsandmotors(butleaveslightson).stopallisequivalenttopressingthebuttononthePicoCricket.
stackstop
if
then
forever
stackstop
touch?
chirp
ifthisistrue...
thisstackstops
stopstack stopsonlythecurrentstack.Youcanusethisblocktostoponestackwhilecontinuinganotherstack.
PicoBlocks - Reference2�
Forexample:
colorswillstopwhenthetouchif
then
stackstop
setlight color
brightness
colors
colors
lightoff
melody1
touch?forever
sensorispressed,yettheotherstackwillcontinue.Thelightwillbeturnedoffandmelody1willbeplayed.
VerticalSpacer
WithoutSpacers WithSpacers
motoronfor
repeat
reversemotoronfor
4
10
4
repeat 10
4
4
reverse
motoronfor
motoronfor
Usespacerstokeeptheblocksfromoverlapping.(Addingspacersdoesnotchangethewaytheprogramruns.)
HorizontalSpacer
WithoutSpacers WithSpacers
motoronfor
repeat
reversemotoronfor
4
10
4
repeat 10
4
4 reversemotoronfor
motoronfor
Usespacerstokeeptheblocksfromoverlapping.(Addingspacersdoesnotchangethewaytheprogramruns.)
PicoBlocks - Reference 2�
Numbers Blocks
number
setpower 50
motoronfor 20
setsmotorpowerto50(halfpower)
turnsonmotorfor20ticks(2seconds)
Clickon totypeinanumber. acceptsnegativenumbers.DefaultValue:10NumbersinPicoBlocksarelimitedtointegersbetween-32768and+32767.
+ addstwovaluesthisplusthat
motoronfor 10 + brightness
Turnsonmotorfor10plusthevalueofthebrightnesssensor(forexample,ifthebrightnesssensoris30,motorturnsonfor40ticks).
- subtractstwovalues thisminusthat
setlight power - brightness100
Turnsonlightwithapowerof100minusthevalueofthebrightnesssensor(forexample,ifthebrightnesssensoris60,lightpowerwillbe40).
x multipliestwovalues thismultipliedbythat
r a n d o m
0 10setlight color x 10
Setsthelight’scolortoarandomnumbermultipliedby10(forexample,iftherandomnumberis7,setsthecolorto70whichiscyan).
/ dividesthefirstvaluebythesecondvalue thisdividedbythat
/motor
onfor 10 brightness
Turnsonmotorforthevalueofbrightnesssensordividedby10(forexample,ifthebrightnesssensoris50,motorturnsonfor5).
PicoBlocks - Reference2�
r a n d o m
reportsarandomnumberbetweenthisandthat
motoronfor
r a n d o m
10 50turnsonmotorforarandomnumberof
ticks(inthiscaseitcouldbe10,or50,or anythinginbetween...)Defaultvalue: random 0 100
> ifthisisgreaterthanthat...
>brightness 50if
then
forever
chirp thiswillhappen
number1>number2reportstrueifnumber1isgreaterthannumber2.
<ifthisislessthanthat...
<brightness 60if
then
forever
chirp
thiswillhappen
number1<number2reportstrueifnumber1islessthannumber2.
=ifthisisequalsthat...
=brightness 50if
then
forever
chirp
thiswillhappen
number1=number2reportstrueifthetwonumbersareequal.
PicoBlocks - Reference 2�
and waitsuntilthisandthatarebothtrue...
waituntil and
chirp
touch? loud?
then,thiswillhappen
andreportstrueiftheresultofthefirstcondition(touch?)andthesecondcondition(loud?)arebothtrue.
orifthisorthatistrue...
orif
then
forever
chirp
touch? loud?
thiswillhappen
orreportstrueiftheresultofthefirstcondition(touch?)orthesecondcondition(loud?)istrue.
not
waituntil
motoron
motoroff
waituntil not
touch?
touch? waitsuntilthetouchsensorisnotpressed
not reportstrueiftheconditionisfalse.notreportsfalseiftheconditionistrue.
PicoBlocks - Reference30
My Blocks
Youcanusethisblocktogiveanametoastackofblocks–andcreateanew blockthatdoesthesamethingastheentirestack.Here’show:
1.Attachtheblockatthetopofthestackyouwanttoname.
chirp
chirp
2.Clickandtypeaname.3.Anewblockwiththatnameappearsin .
4.Useitinotherstacks.
2chirps
4repeat
chirps8times
store inbox1 box1
store inbox2 box2 Usetheseblocksforsettingand
retrievingthevaluesofvariables.
Use store inbox1
tostoreavalue,anduse box1 toretrieveit.
store inbox1
r a n d o m
30 49
box1setlightcolor
setlightcolor
wait
box1
5
box1storesa randomnumber
turnsalightthatrandomcolor
waitsfor5ticks
turnsasecondlightthesamecolor
PicoBlocks - Reference 31
Tochangethenameofavariable,dragitintotheworkspace,clickonit,andtypeinthenewname.
store inbox1
box1setlight color
10
store inmy-color
my-colorsetlight color
10
Whenbox1isrenamedintheworkspace,theblocksinthepaletteareautomaticallyupdated.
renametheblock
PicoBlocks - Reference32
Melody and Rhythm Editors
PicoBlockshastwoeditorsforcreatingmusic:aMelodyEditorandaRhythmEditor.
Tocreateanewmelodyorrhythm(ortoeditanexistingone),firstclickontheSoundtab.AtthebottomofSoundpalettearetwobuttons,oneforopeningtheMelodyEditor,theotherforopeningtheRhythmEditor.
Afteryoucreateanewmelodyorrhythm,itwillappearasanewblockintheSoundpalette.Youcandragthesemusicblocksintotheworkspace,andconnectthemtostacks,justasyouwouldwithanyotherblockinPicoBlocks.
TheseblockswerecreatedusingtheMelodyEditorandRhythmEditor.
OpenstheMelodyEditor
OpenstheRhythmEditor
PicoBlocks - Reference 33
Melody Editor
Clickon toopentheMelodyEditor.
Ifthisisyourfirstmelody,youwillseeablankMelodyWorkspaceforcreatingyourmelody.Ifyouhavepreviouslycreatedmelodies,youwillseeoneofyourexistingmelodiesintheMelodyWorkspace.Youcaneditthismelody–orselectoneofyourotherexistingmelodiestoedit(byclickingonablockinthepaletteontheleftside)–orcreateanewmelody(byclickingonthe“Create”buttonatthetop-left).
Toaddnotestoyourmelody,eitherclickonthekeyboard,orclickdirectlyintheMelodyWorkspace.
Whenyouarefinishedcreatingyourmelody,click OK toturnyourmelodyintoablockandexittheMelodyEditor.
Playorstop
Insertionpoint:thenextnotepressedonthekeyboardwillstarthere
MiddleC clickheretoinsertarestDragheretomaketheMelodyWorkspacebiggerorsmaller
Tocreateanewnote,clickonthekeyboardordirectlyintheMelodyWorkspace
Changeinstrument,volume,ortempo
Selecttheduration
ClickheretosavethemelodyasablockandexittheMelodyEditor
Clickheretocreateanewmelody
MelodyWorkspace
Youcanimportandexportmelodyfileswithextension.pbm
Dragthisendtochangelengthofnote
PicoBlocks - Reference3�
Dragonthebackgroundtoselectnotes.Movetheselectednotesbydraggingthemtootherlocation.
Youcanalsocopy ,cut
andplay theselection.
Youcanalsoplaytheselectionbydoubleclickingonit.
AllofyourmelodiesappearattheleftoftheMelodyEditor.Clickonthemelodythatyouwanttoedit.
Tochangethenameofamelody,clickontheblockandtypeanewname.
Use tomakeacopyofamelody.Use todeletemelodies.
twinkle
twinkle
PicoBlocks - Reference 3�
Rhythm editor
Clickon toopentheRhythmEditor.
Ifthisisyourfirstrhythm,youwillseeablankRhythmWorkspaceforcreatingyourrhythm.Ifyouhavepreviouslycreatedrhythms,youwillseeoneofyourexistingrhythmsintheRhythmWorkspace.Youcaneditthisrhythm–orselectoneofyourotherexistingrhythmstoedit(byclickingonablockinthepaletteontheleftside)–orcreateanewrhythm(byclickingonthe“NewRhythm”buttonatthetop-left).
Whenyouarefinishedcreatingyourrhythm,click OK toturnyourrhythmintoablockandexittheRhythmEditor.
Changevolume,ortempo
Loop,playorstop
ClickheretosavetherhythmasablockandexittheRhythmEditor
DragheretomaketheRhythmWorkspacebiggerorsmaller
Clickordragheretocreateanote
Clickheretocreateanewrhythm
Youcanimportandexportrhythmfileswithextension.pbr
PicoBlocks - Reference3�
AllofyourrhythmsappearattheleftoftheRhythmEditor.Clickontherhythmthatyouwanttoedit.
Tochangethenameofarhythm,clickontheblockandtypeanewname.
Use tomakeacopyofarhythm.Use todeleterhythms.
PicoBlocks - Reference 3�
Graphing Data
TheGraphingToolletsyouviewagraphofdatathatyouhavecollectedonyourPicoCricket.
ToopentheGraphingTool,firstclickontheDatatab,thenclickonthegraph buttonatthebottomoftheDatapalette.
Toseeagraphofthecollecteddata,turnonyourPicoCricketandaimit
attheBeamer,thenclickonthe Upload and Graph buttonatthebottomoftheGraphingTool.
Youcancollectandviewupto200datapoints,whereeachdatapointisanumberfrom0to100.
OpenstheGraphingTool
Saveanimageofthegraph
Agraphofyourcollecteddata
Savethecollecteddataasalistofnumbersinatextfile
Thenumberofdatapointscollected
Beamdatatothecomputerandgraphit
ExittheGraphingTool
PicoBlocks - Reference3�
The PicoBlocks Text Language
Overview
PicoBlocksletsyouconstructcomputerprogramsbysnappingdifferentblockstogether,likepiecesofapuzzle.Thisapproachmakesiteasytogetstarted;differentkindsofblockshavedifferentshapesandcanonlysnaptogetherincertainways.Theshapesofthepiecesprovidealotofguidanceastohowstructureyourprograms,helpingyoubuildprogramsthatworkthewayyouwantthemtowork.Butifyoutrytowritelongerprogramsyoumayfindthatusingtheblockscangetcumbersome.Forexample,allofyourstacksmaynolongerfitathescreenatthesametime.Also,therearesomeadvancedprogrammingfeaturesthatarenotavailableusingtheblocks.Asyourprogramsbecomelongerandmorecomplex,youmaywanttoconsiderusingtheTextLanguagethatisavailablefromwithinthePicoBlockssoftware.ThePicoBlocksTextLanguageissimilartothecomputerlanguageLogo.(FormoreinformationonLogoseewww.logofoundation.org.)TobeginwritingprogramsintheTextLanguage,clickonthetexticonlocatedinthelowerlefthandcornerofthePicoBlocksWorkspace.TheTextLanguageWorkspace,showninthefigurebelow,willappear.
ClickonthetexticontoswitchtothetextlanguageWorkspaces
ClickheretoswitchbackandforthbetweentheTextandtheBlocksWorkspaces
ProcedureAreaDefinenewwordshere
CommandCenterTypecommandshereand
thenpressEnter
PicoBlocks - Reference 3�
TrytypingthefollowingcommandsintheCommandCenter.(PresstheEnterkeytoruneachline.) chirp The PicoCricket chirps! chirpwait2chirp The PicoCricket chirps twice.
Note that spaces are very important in the Text Language; they are used to determine where words start and end. For example, if you leave out the space between wait and 2 in the last example you will get an error message that says “I don’t know how to wait2”. This is because PicoBlocks does not understand the wordwait2.
EachblockinPicoBlockshasanassociatedwordinthetextlanguage.Thegeneralruleforfindingthenameofthewordinthetextlanguagethatisassociatedwithaparticularblockisaverysimpleone1:
Justcopywhat’swrittenontheblock,leavingoutaspaceifthereisone.
Forexample,plugalightintoyourPicoCricketandtypethefollowingintheCommandCenter:
setlightcolor20ThelightturnsredNotethattherearenospacesinthewordsetlightcolor.
NowtrytypingthefollowinglineintheCommandCenter:
repeat5[chirpwait2]
IntheTextLanguagesquarebracketsareusedtoenclosethelistofwordsthataretoberepeated.Youcangetguidanceabouthowthetextwordcorrespondingtoaparticularblockismeanttobeusedbyclickingonthatblock,whichyoucanfindonthelefthandsideoftheTextLanguageWorkspace.Forexampleifyouclickonthe“repeat”blockthefollowingtextwillappearintheCommandCenter:
repeat10[WHATEVER]Inthismessage“WHATEVER”ismeantasaplaceholderforthelistofcommandsthatyouwantrepeated.
Other Examples
Pluginatouchsensorandasoundboxandtype:
waituntil[touch?]playsound24Youshouldheara“meow”whenyoupressthetouchsensoronthetouchsensor.
Ifyoutype:forever[waituntil[touch?]playsound24]youshouldnowhearthe“meow”eachtimeyoupressthetouchsensor.Intheselasttwoexamplesyouwillneedtomakesureyoutypethesquarebracketsintheproperplaces.
Pluginadisplayandtype:display7*9+6
TheTextlanguageusesparenthesestodeterminetheorderofinwhichthingsaredone.Comparetheaboveresulttowhatyougetifyoutype:
display7*(9+6)
1 Exceptionstothisruleoccurforthecasesoftheifandifelsewords;sincethetextworddoesnotinclude“then”.Foracompletelistoftheblocksandcorrespondingtextwords,seetheSummaryofTextLanguageWordschartattheendofthissection.
PicoBlocks - Reference�0
Procedures
Youcan“teach”yourPicoCrickettounderstandnewwordsbydefiningproceduresintheProceduresAreaoftheTextLanguageWorkspace.Proceduresaredefinedusingthefollowinggeneralform: toprocedure-name procedure-body end
Theproceduredefinitionstartswiththekeywordto,followedbythenameoftheprocedure.Nextcomesthebodyoftheprocedure,whichisalistofwordsthatdescribewhattheprocedureistodo.Thekeywordendisusedtocompletetheproceduredefinition.
Forexample,intheProcedureAreatype: tochirp-twice chirpwait5chirp end
You’venowtaughtyourPicoCricketanewword;ifyoutypethewordchirp–twiceintheCommandCenter,thePicoCricketwillchirptwice.
Procedures with Inputs and Outputs
Youcancreateproceduresthattakeinputsorproduceanoutput.Forexample,youcancreateaprocedurenamedchirpsthattakesaninputthatisusedasthecounterinarepeatloop.Notethatthenameoftheinputmustbeginwithacolon.: tochirps:num repeat:num[chirpwait5] end
Typing chirps10intheCommandCenterwillcausethePicoCrickettochirp10times.
Youcancreateaprocedurethattakestwoinputsthatwilldetermineboththenumberofchirpsandthedurationofthepausebetweenchirps:
tochirps2:num:pause repeat:num[chirpwait:pause] end
Typing chirps2103intheCommandCenterwillcausethePicoCrickettochirp10times,withapauseof3tenthsofasecondbetweenchirps.
Proceduresmayreturnvaluesusingtheoutputcommand.Forexample,youcandefineaprocedurecalledhalfby:
tohalf outputbrightness/2 end
PicoBlocks - Reference �1
Then,withadisplayandalightsensorpluggedin,trytypingintheCommandCenter:
displayhalf
Or,youcandefineaprocedurecalleddark?thatreturnsatrueoffalseresult:
todark? output(brightness<20) end
NowifyoutrytypingintheCommandCenter:
forever[ifdark?[chirp]]yourPicoCricketshouldchirpwhenitisdarkenough.
Make Your Own BlocksYoucanusetheTextLanguagetomakedifferentkindsofblocks,whichyoucanthenusetobuildprogramsinthePicoBlocksWorkspace.ThisfeatureallowsyoutocontinuedoingmuchofyourprogrammingusingtheBlocksLanguage,withtheTextLanguagebeingusedasasupplementwhenitsadvancedfeaturesareneeded.
NewblocksaredefinedbytypingintheProceduresArea.Theblockdefinitionsbeginwiththekeywordblock.Forexample:blockchirp1chirpwait3chirpend
chirp1
Makesablockthatchirpstwice.
Blocksthatyouhavedefinedwillautomaticallybecreatedandplacedinthe“MyBlocks”area.Youcancreateblockswithuptothreeinputs.Forexample,tocreateablockwithoneinput:blockchirp2:numrepeat:num[chirpwait3]end
chirp2
Makesablockthatchirpsanumberoftimes.
Tocreateablockwithtwoinputs:
blockchirp3:num:pauserepeat:num[chirpwait:pause]end
chirp3
Makesablockthatchirpsanumberoftimes,withtheabilitytovarythelengthofthepausebetweenchirps.
Whenyoudefineablockthatoutputsanumber,PicoBlockswillautomaticallycreateanumber–shapedreporterblock:blockbright2output2*brightnessend
bright2
Reportsanumbertwiceasbigasthebrightnessmeasuredbythelightsensor.
PicoBlocks - Reference�2
Usethekeywordbblockwhenyouwanttomakeablockthatoutputstheresultofatrue/falsecondition:
bblockquiet?outputloudness<5end
quiet?
Using Tags in the Text Language
PicoBlocks“tags”areusedwhenyouareplugginginmorethanoneofthesamekindofpart,twolightsortwomotorsforexample,andyouwantthesepartstoactdifferently.(SeetheprevioussectiononTagsonpages10and11.)InprogramswrittenintheTextLanguage,awordwithoutatagwilladdressallpartsofthesametype.Forexample,iftwolightsarepluggedintoyourPicoCricket,thecommand
setlightcolor90 willturnbothlightsblue.
Ifyouwanttoreferonlytothelightpluggedintothe port,addaperiodtotheendoftheword,withoutaspace:
setlightcolor.90
Similarly,toreferonlytothelightpluggedintothe port,addtwoperiodstotheendoftheword,withoutspaces:
setlightcolor..90
Toreferonlytothelightpluggedintotheport,addaperiodandacolontotheendoftheword,withoutspaces:
setlightcolor.:90
Toreferonlytothelightpluggedintotheportjustaddtwocolonstotheendoftheword,withoutspaces:
setlightcolor::90
Thismethodoftaggingtextwordswillworkwithotherwords2.Forexample
display.:57willdisplaythenumber57onadisplaypluggedintotheportand
forever[iftouch?..[chirp]]willcausethePicoCrickettochirpifatouchsensorthatispluggedintothe portispressed.
Global Variables
Inthe“MyBlocks”tabyouwillfindblocksforstoringnumbersintwodifferent“globalvariables”calledbox1andbox2.IntheTextLanguageyoucanusethekeywordglobal:tocreateuptofiveadditionalglobalvariables.Forexample,byincludingtheline: global:times,pause
Note:Tagswillnotworkwithwordsrelatedtothesoundbox.2
PicoBlocks - Reference �3
intheProceduresAreayouwillcreatetwonewglobalvariablescalledtimesandpause.Now,trytypingthefollowinginthecommandcenter:
storeintimes5storeinpause3 repeattimes[chirpwaitpause]
ThePicoCricketshouldchirp5times,withpausesof3tenthsofasecondbetweenchirps.
IfyouclickontheMyBlockstabyouwillalsofindthatnewblockscorrespondingtothenewvariablestimesandpausehavebeencreated.
Local Variables
Thewordmakeallowsyoutochangethevalueofaninputtoaprocedure.Forexample,ifyoudefineaprocedurecalledrainbowby:
torainbow:a repeat30[setlightcolor:amake“a:a+1wait2] end
then,withalightpluggedintoyourPicoCricket,typing
rainbow20intheCommandCenterwillcausecolors20through49toflash.
Variablesofthiskindarecalled“localvariables”becausetheyareonlyavailableforusebytheprocedureinwhichtheyaredefined.BecausePicoBlockshasaverylimitednumberofglobalvariables(7),localvariablescanbehelpfulbecausetheydonotuseanyoftheglobalvariableslots.
Data Memory
APicoCrickethas200bytesofmemoryusedforstoringcollecteddata.Thesememorylocationscanbeaccessedsequentiallyusingthecollectandnextdatablocks,asexplainedonpage22.
Alternatively,datamemorylocationscanberandomlyaccessedusingreaddataandwritedataasfollows:
readataaddress-reportsthevalueoftheone-bytenumberthathasbeenstoredataparticularaddressindatamemory.writedataaddressnumber-storesaone-bytenumberataparticularaddressindatamemory.
Forexample,typing:writedata14775storesthenumber75ataddress147indatamemory.Toverifythis,plugadisplayintoyourPicoCricket,andtype:
displayreaddata147Thenumber75shouldappearonthedisplay.
PicoBlocks - Reference��
Tool Not Available in the Text LanguageThe“secondwand”isnotavailableintheTextLanguage.
Summary of Text Language WordsThefollowingtableshowsthetextwordthatcorrespondstoeachPicoBlocksblockandgivesanexampleofhowthewordcanbeused.
LightBlock Word Example Usage
setlight color setlightcolornumber
Setlightcolortakesaninputfrom0to100.setlightcolor70Thelightchangestocyanandturnson.
setlight power setlightpowernumber
Setlightpowertakesaninputfrom0to100.setlightpower50Thelightturnsonathalfpower.
lightoff
lightoff lightoffThelightturnsoff.
display displaynumberDisplaysavalueonthedigitdisplay:display709Thedisplayshowsthenumber709.
Textonly
setrgbnumbernumbernumber
Setsthecolorofthelight.Setrgbtakes3inputs(red,green,andblue),eachwitharangefrom0to100.Thethreeinputsmixtogiveoneparticularlightcolor.setrgb0100100Thelightturnscyan.
SoundBlock Word Example Usage
chirpchirp chirpwait3chirp
ThePicoCricketchirpstwice.
note notenumbernumber
Notetakestwoinputs.Thefirstinput(anumberbetween0and100)determinesthepitchofthenoteandthesecondinputdeterminesthedurationofthenote(intenthsofasecond).note365Thesoundboxplaysanoteforhalfasecond.
playsound playsoundnumber
Playsasoundonthesoundboard.Playsoundtakesanynumberbetween0and100.Thereare24built-insounds.Playsoundrepeatsthelistinsequencefornumbersgreaterthan24.playsound24Thesoundboxmeows.
PicoBlocks - Reference ��
SoundBlock Word Example Usage
setinst setinstrumentnumber
Setstheinstrumentforthenextnote,ormelodytobeplayedonthesoundboard.Setinstrumenttakesanynumberbetween0and100:setinstrument4note365Thesoundboxplaysviolinnote.
settempo
settemponumber
Setsthetempoatwhichthenextrhythmormelodywillbeplayedonthesoundboard.Settempotakesanynumberbetween0-lowestpace-and100-fastestpace.settempo50melody1Thesoundboxplaysamelodyatthestandardtempo.
setvolume
setvolumenumber Setsthevolumeatwhichthenextnote,sound,rhythmormelodywillbeplayedonthesoundboard.Setvolumetakesanynumberbetween0-lowestvolume-and100-highestvolume:setvolume30playsound24setvolume100playsound24Thesoundboxmeowssoftly,thenloudly.
InadditiontotheblocksabovecanaddyourownblockstotheSoundtabbycreatingmelodiesand/orrhythmsintheirrespectiveeditors.Themelodyorrhythmnamebecomesatextwordthatyoucanuse.
ActionBlock Word Example Usage
motoron
motoroff
motoronmotoroff
Turnsamotoronoroff.motoronwait10motoroffThemotorspinsfor1second.
motoronfor
motoronfornumberTurnsthemotoronforasetperiodoftime(intenthsofasecond).motoronfor10Themotorspinsfor1second.
reversereverse Changethedirectioninwhichthemotorspins.
repeat6[motoronfor3reverse]Themotorwigglesbackandforth.
thisway
thatway
thiswaythatway
Setthemotortospininaspecificdirection.thiswaymotoronfor10thatwaymotoronfor10Themotorspinsonewayfor1second,thentheotherwayfor1second.
setpower
setpowernumber Setpowertakesaninputfrom0to100.setpower100motoronfor10Themotorspinsquickly.setpower30motoronfor10Themotorspinsslowly.
PicoBlocks - Reference��
ActionBlock Word Example Usage
textonly brake Causesthemotortostopimmediately.Thisisslightlydifferentfrommotoroff,whichdoesashortbrakefollowedbyacoast.motoronwait10brakeThemotorspinsfor1second,thenimmediatelycomestorest.
textonly coast Turnsoffthepowertothemotorbutdoesnotbrakeit,sothatthemotorslowlycomestorest.motoronwait10coastThemotorspinsfor1second,thenslowlycomestorest.
SensorsBlock Word Example Usage
touch? touch?
Reportstrueifthetouchsensorispressed.waituntil[touch?]chirpThePicoCricketwaitsuntilthetouchsensorispressedbeforechirping.
dark? dark?
Reportstrueifthevaluemeasuredbythelightsensorislessthan15.waituntil[dark?]chirpThePicoCricketwillchirpafterthelightsensordetectslittlelight.
brightness brightness
Reportsthevaluemeasuredbythelightsensorasanumberfrom0to100.forever[displaybrightnesswait1]Thedisplayshows,andcontinuallyupdates,thelightlevelmeasuredbythelightsensor.
loud?loud?
Reportstrue(thenumber1)ifthevaluemeasuredbythesoundsensorisgreaterthan60.waituntil[loud?]chirpThePicoCricketwillchirpafterthesoundsensordetectsaloudsound.
loudness loudness
Reportsthevaluemeasuredbythesoundsensorasanumberfrom0to100.forever[displayloudness]Thedisplayshows,andcontinuallyupdates,thesoundlevelmeasuredbythesoundsensor.
connected? connected?
Reportstrueifthevaluemeasuredbytheresistancesensorislessthan50.waituntil[connected?]chirpThePicoCricketwaitsuntilthealligatorclipsontheresistancesensorconnectbeforechirping.
PicoBlocks - Reference ��
SensorsBlock Word Example Usage
resistance resistanceReportsanumberfrom0to100.forever[displayresistancewait1]Thedisplayshows,andcontinuallyupdates,theelectricalresistancemeasuredbytheresistancesensor.
textonly rawresistanceReportsthevaluemeasurebytheresistancesensorasanumberbetween0and1023;rawresistanceprovidesfinerresolutionthanresistance.forever[displayrawresistancewait1]Thedisplayshows,andcontinuallyupdates,theelectricalresistancemeasuredbytheresistancesensoronascaleof0to1023.(Numbersof1000orgreaterappearasdashes.)
textonly rawrange
Rawrangeisusedtoadjustthesensitivityoftheresistancesensor.Ittakesasaninputeitherthenumber0,1,or2.Aninputof0resultsinthehighestsensitivityandshouldbeusedwhenmeasuringresistancesof1000ohmsorless.Aninputof1ismediumsensitivityandisthedefaultsetting.Itworksbestforresistancesofabout10,000ohms.2isthelowestsensitivityandshouldbeusedtomeasureresistancesof100,000ohmsormore.rawrange0displayrawresistance
beamIRbeamirnumber BeamsanumberfromthePicoCricket’sinfraredtransmitter.
beamir4
newIR? newir?Reportstrue(thenumber1)ifthePicoCricket’sinfraredreceiverhasreceivedanewvalue.waituntil[newir?]chirpThePicoCricketchirpswhenanewnumberisbeamedtoit.
IR ir
ReportsthevalueofthemostrecentnumberbeamedtothePicoCricket.totestwaituntil[newir?]ifir=20[chirp]endThePicoCricketchirpsifthenumberbeamedtoitisequalto20.
resettimer
resett ResetstozerothevalueofthePicoCricket’sinternaltimer.Seenextexample.
timer timer
ReportsthePicoCricket’stimervalue.Timermeasurestimeinhundrethsofasecond.totestresettchirpwaituntil[touch?]displaytimerend
ThedisplayshowstheamountoftimethathaselapsedbetweenwhenthePicoCricketchirpsandwhenthetouchsensorispressed.
PicoBlocks - Reference��
DataBlock Word Example Usage
clearclear
Permanentlyerasesallcollecteddata.Useclearbeforestartingtocollectnewdata.Seenextexample.
collectcollectnumber
Storesadatapoint(anumberfrom0to100)inthePicoCricket’smemory.clearrepeat200[collectloudness]
rewindrewind
PreparesthePicoCricketto“playback”collecteddata,startingwiththefirstdatapoint.rewindrepeat200[displaynextdatawait5]
next data nextdataReportsthevalueofthenextnumberstoredinthePicoCricket’smemory.rewindrepeat200[displaynextdatawait5]
textonly datalengthReportsthetotalnumberofdatapointsthathavebeencollected.displaydatalength
textonly writedataaddressnumber
Storesaone-bytenumberataparticularaddressinthedatamemory.writedata4775
textonly readdataaddressReportsthevalueoftheone-bytenumberstoredataparticularaddressinthedatamemory.displayreaddata47
FlowBlock Word Example Usage
wait waitnumberWaitsacertainamountoftime(intenthsofasecond).chirpwait10chirpThePicoCricketpausesforasecondbetweenthetwochirps.
textonly mwaitnumberWaitsacertainamountoftime(inmilliseconds).setlightcolor20mwait10lightoffThelightflashesverybriefly.
textonly no-opDoesnothingforabout40microseconds.repeat10[no-op]ThePicoCricketwaitsfor400microseconds.
waituntil waituntil[condition]
Waitsuntiltheconditionistrue.waituntil[touch?]chirpThePicoCricketwaitsuntilyoupressthetouchsensorbeforechirping.
PicoBlocks - Reference ��
FlowBlock Word Example Usage
foreverforever[list] Repeatsalistofinstructionsforever.
forever[chirpwait3]ThePicoCricketchirpscontinuously.
repeat repeatnumber[list]
Repeatsalistofinstructionsasetnumberoftimes.repeat5[chirpwait2]ThePicoCricketchirpsfivetimes.
if
thenifcondition[list]
Runsalistofinstructionsifacertainconditionismet.forever[iftouch?[chirpwait1]]ThePicoCricketchirpsifyoupressthetouchsensorandisquietifyoudonotpressit.
if
then else
ifelsecondition[list1][list2]
Runsthefirstlistofinstructionsifacertainconditionismetandthesecondlistifitisnot.totestforever[ifelsetouch?[setlightcolorrandom099][lightoff]]endThelightflashesrandomcolorsifyoupressthetouchsensorandturnsoffifityoudonotpressit.
stopall stopall
Stopseverything:programs,motors,etc.StopallisequivalenttopressingthebuttononthePicoCricket.totestmotoronforever[iftouch?[stopall]setlightcolorrandom099]endThelightsandmotorsstopwhenyoupressthebutton.
stackstop stopstack
Terminatesexecutionofaprocedure,returningcontroltothecallingprocedure.totestforever[iftouch?[stopstack]setlightcolorrandom099]end
Thereisnoneedforspacersinthetextlanguage.
Thereisnoneedforspacersinthetextlanguage.
PicoBlocks - Reference�0
NumbersBlock Word Example Usage
number numberReportsanumber.NumbersinPicoBlocksarelimitedtointegersbetween-32768and+32767.display7Thedisplayshowsthenumber7.
+ number+number Reportsthesumoftwonumbers.display7+4Thedisplayshowsthenumber11.
- number-number Reportsthedifferenceoftwonumbers.display7-4Thedisplayshowsthenumber3
x number*number Reportstheproductoftwonumbers.display7*4Thedisplayshowsthenumber28.
/ number/numberReportsthequotientoftwonumbers,roundeddowntothenearestinteger.display7/4Thedisplayshowsthenumber1.
textonly %Reportstheremainderwhentwonumbersaredivided.display7%4Thedisplayshowsthenumber3.
r a n d o m randomnumbernumber
Reportarandomnumber,thetwoinputsdeterminingthelowerandupperlimits.displayrandom010Thedisplayshowsarandomnumberfrom0to10.
< number>number
Reportstrue(thenumber1)ifthevalueofthefirstinputisgreaterthanthevalueofthesecondinput.totestforever[ifbrightness>30[chirp]]endThePicoCricketchirpsifthelightsensormeasuresavaluegreaterthan30.
> number<number
Reportstrue(thenumber1)ifthevalueofthefirstinputislessthanthevalueofthesecondinput.totestforever[ifbrightness<30[chirp]]endThePicoCricketchirpsifthelightsensormeasuresavaluelessthan30.
=number=number
Reportstrue(thenumber1)ifthevalueofthefirstinputisequalthevalueofthesecondinput.forever[ifbrightness=30[chirp]]ThePicoCricketchirpsifthelightsensormeasuresavalueexactlyequalto30.
PicoBlocks - Reference �1
NumbersBlock Word Example Usage
andconditionandcondition
Reportstrue(thenumber1)ifthefirstandsecondconditionsarebothtrue.totestforever[if(brightness<30)andtouch?[chirp]]end
ThePicoCricketchirpsifthelightsensormeasuresavaluelessthan30andthetouchsensorisalsopressed.
orconditionorcondition
Reportstrue(thenumber1)ifthefirstorthesecondconditionsarebothtrue.totestforever[if(brightness<30)ortouch?[chirp]]endThePicoCricketchirpsifthelightsensormeasuresavaluelessthan30orthetouchsensorispressed.
not
notcondition Reportstrue(thenumber1)iftheresultoftheconditionisfalse(number0).totestforever[ifnottouch?[chirp]]endThePicoCricketchirpsifthetouchsensorisnotpressed.
My BlocksBlock Word Example Usage
blocknameblock-definitionend
Youcanusethetextlanguagetomakeyourownblocks.(SeesectionMakeYourOwnBlocksabove.)
store inbox1 storeinbox1number
Storesanumberintheglobalvariablecalledbox1.storeinbox157displaybox1Thedisplayshowsthenumber57.
box1 box1Reportsthenumberstoredintheglobalvariablecalledbox1.storeinbox157
textonly global: Youcanusethetextlanguagetocreatenewglobalvariables.(SeesectionGlobalVariablesabove.)
textonly make“namevalue Makeallowsyoutochangethevalueofalocalvariable.(SeesectionLocalVariablesabove.)
PicoBlocks - Reference�2
Common Error Messages
Error Message Explanation
TheBeamercannotseethePicoCricket
TheBeamerissending,butnoPicoCricketisresponding.
Solution:MakesurethePicoCricketisturnedon,andthatthePicoCricketandtheBeamerarefacingeachother.Formoreinformation,seewww.picocricket.com/troubleshooting
Can’tfindtheBeamer PicoBlockswasn’tabletoopenthecommunicationport.
Solution:MakesuretheBeamerisproperlyconnectedtoyourcomputer.IfyouareusingWindows,makesureonlyonecopyofPicoBlocksisrunning.Formoreinformation,see:www.picocricket.com/support
Can’tsaveanemptyscore Youtriedtoexportamelodyorrhythmthatisempty.
Solution:Makesuretheblockcontainsnotes,thenclickExportagain.
Can’tuse____asaname PicoBlocksdoesnotallowthatwordasaname.Numbers,namesstartingwith%or[,andexistingwordsareconsideredinvalid.
Solution:Typeanothername.
Communicationproblem TherewasacommunicationproblemwhilePicoBlockswasdownloadingdatatoyourPicoCricket.
Solution:MakesurethattheBeamerandthePicoCricketarefacingeachother,thentryagain.IfthePicoCricket’syellowantennalightskeepflashingevenwhenyouarenotdownloading,thePicoCricketisprobablyreceivinginfraredinterferencefromamonitororotherdevice.ShieldthePicoCricketfromthemonitor.Formoreinformation,seewww.picocricket.com/troubleshooting
Missinginputto_______ One(ormore)oftheblocksrequiresinput.
Solution:Checkthateveryblockhassomethingattachedonitsrightsidewhenrequired.(Youcantellbytheshapeofablockwhetherittakesaninput.)
Forexample,displayneedsanumber(orothervalue)attachedasaninput:
display 100
Repeatrequiresanumbervalueatthetopright.Italsorequiresplusoneormoreblocksunderits“arm”torepeat:
repeat
chirp
10
Tip:Tocheckifablockneedsinputs,clickontheblockwiththe
Helptool ??
PicoBlocks - Reference �3
Error Message Explanation
Idon’tknowhowto______ PicoBlockstriedtorunanamethatdoesn’texist.
Solution:Ifyounameastack,thenPicoBlockscreatesablockwiththatname.Toruntheblock,youneedtokeepthenamedstackintheWorkspace,soPicoBlocksknowswhattodo.
Thename____alreadyexists Thereisalreadyanexistingblockwiththesamename.
Solution:Typeanothername.
Numberblockdoesn’tlike_____
Youtypedaninvalidcharacterin
Solution:Typeonlynumbers.
Projectcontainstoomanyblocks
Yourprojectcontainstoomanyblocks.
Solution:Deleteallstacks,melodiesandrhythmsthatarenotbeingused.
Toomanyblocksinthestack Thestackcontainstoomanyblocks(andusesuptoomuchmemory).
Solution:Usearepeattodomorewithfewerblocks.Or,placea onthetopofthestack,andclickonittotypeinaname.
Toomanymusicblocks:Limitof24
Youhavemademorethanthemaximumnumberofmusicblocks.Themaximumnumberofmelodiesandrhythmsis24blocks.
Solution:Deletesomeofthemelodyorrhythmblockssothattheprojecthasnomorethan24total.
Toomanynotesforonemusicblock
Thecurrentmelodyorrhythmistoolong.
Solution:Dividethemelodyorrhythmintotwoblocks.Todothis,firstcopythecurrentmusicblock.Inthisblock,deletethesecondhalfofthenotes.Intheotherblock,deletethefirsthalfofthenotes.Nowyoucanusethesetwoblockstogethertoplaytheentiresequence.
waituntilneedsinput Thewaituntilblockneedsaninputblockthatfits.
Solution:Attachablockthatfitsontotherightsideofthewaituntilblock.
Examples:
waituntil loud?
or >waituntil 50 brightness
PicoBlocks - Reference��
Error Message Explanation
Youcan’tcopyanemptymusicblock
Youtriedtocopyamelodyorrhythmthatisempty.
Solution:Addnotes,thencopytheblock.
Youcan’tnameastack______
Thenametypedonthe containsinvalidcharacters.Itcannotcontainthefollowingcharacters:.%“+-*/][oraspace.Numberscanonlybeusedincombinationwithletters.
Solution:Typelettersonthe
Youdon’tsaywhattodowith________
PicoBlockstriedtorunablockthatreturnsavalue,buttherewasnoblockattachedtoreceivethatvalue.
Solution:Attachablockthatwillfitthatshape(andreceivethevalue).Forexample:
touch?waituntil
Text-Only Error Messages ThefollowingerrormessagesonlyappearwhenusingthePicoBlocksTextLanguage.
Error Message Explanation
_______:ablockcan’thavemorethan3inputs
Youcan’tmakeablockwithmorethan3inputs.
Solution:Storetheothervaluesasglobalvariables,andusethenamesofthesevariablesinyourprogram.Formoreinformation,seeGlobalVariablesinthePicoBlocksTextLanguagesectionofthisreferenceguide.
______hasnovalue PicoBlockscouldnotfindavalueforthespecifiedname.
Solution:IntheTextArea,checkthatyouhavecorrectlytypedthenameoftheinput.Inputsshouldhaveacolonprecedingthem,butglobalvariablesshouldnot.
_______:outputblockcanonlyhave1input
Ablockthatoutputscanonlyhave1input.
Solution:Storetheothervaluesasglobalvariables,andusethenamesofthesevariablesinyourprogram.Formoreinformation,seeGlobalVariablesinthePicoBlocksTextLanguagesectionofthisreferenceguide.
()error
misplaced)
Aparenthesisismissingormisplaced.
Solution:Checkthatthereareanequalnumberofopenandclosedparenthesis(),andthattheyarecorrectlyplaced.
PicoBlocks - Reference ��
Error Message Explanation
Can’tnameaglobal_______ Youneedtotypeinadifferentnamefortheglobalvariable.
Solution:Useonlylettersandnumbersasnamesforglobalvariables.SeeGlobalVariablesinthePicoBlocksTextLanguagesectionofthisreferenceguideformoreinformation.
Can’tuse_____asnameofaninput
PicoBlocksdoesn’tlikenumbersasthenameofaninput.
Solution:Youneedtotypeinadifferentnamefortheinput.Avoidusingnumbersasinput.Also,makesuretoputacolonbeforethenameoftheinput.
Forexample:blockmydance:turnsrepeat:turns[motoronfor10reverse]end
Missing[Missing]
Thereisamissingbracket:]or[.
Solution:Makesurethereareanequalnumberofopenandclosedbrackets.
MissingnameaftertoMissingnameafterblockMissingnameafterbblock
Solution:Thewordsto,block,andbblockneedtobefollowedbyavalidname.Forexample:blockmylightssetlightcolor60wait10lightoffend
Nooutputfrom_____ Thewordorblockindicateddoesnotprovideoutput.
Solution:Makesureeveryblockhassomethingattachedonitsrightsidewhenrequired.SeethePicoBlocksTextLanguagesectionformoreonhowtouseoutput.
Toomanyglobals Therearetoomanyglobalvariablesintheproject.Themaximumnumberofvariablesis7(includingbox1andbox2).
Solution:Deletesomeoftheglobalvariablessothattheprojecthasnomorethan7total.
waituntilneedsalistasinput. waituntilneedsalistasinput.
Solution:Addalistinbracketsafterwaituntil
Forexample: waituntil[touch?] chirp
Recommended