New blocks! Random, music and analogue
- On March 29, 2016, 3:13 p.m.
- By Thomas Macpherson-Pope
We are thrilled to announce loads of new CodeBug programming blocks that will help you make even more exciting projects. You can now create random numbers, music and read analogue values using CodeBug! We have received lots of requests for these blocks and can't wait to see what you will create with them.
The Random block is great for creating games, amazing patterns or dice.
The random block is used by giving it two numbers which define the range you want your random number to be in. So if you set it from 2 to 5, it would return you 2, 3, 4 or 5 randomly. The Random block can be found in the Maths menu. Check out this fortune teller project that uses the random number block to help you answer life's difficult questions.
Analogue inputs let you measure things -- so you could sense temperature, light or moisture. They're setup the same way as digital inputs; click on the start cog, tick the leg you want to set as an input, click the cog again to close the window, and select analogue input from the dropdown next to the leg you have chosen. The read analogue leg block from the Inputs/Outputs menu takes a leg number and returns a value from 0 to 255, which represents the analogue value it reads on the leg. You can use this new block to create sensitive controls for CodeBug using potentiometers. Check out this dial control project to see how to use the Analogue inputs.
The new Music menu has a number of different blocks to help you create musical masterpieces. You can play a note for a number of beats, adjust the tempo and pause for a number of beats. The play tone block takes a note block and a beat block, but can also be used with a simple number block in milliseconds. You can make all sorts of noisy projects including Happy Birthday tune player and a Morse code generator.
Activity guides describing these new blocks will be coming soon. Please share any cool projects you make using these new blocks with us on Twitter.