• UID1571
  • 登录2018-05-18
  • 粉丝4
  • 发帖134
  • 科研点数0点
优异服役勋章
耕耘者十字勋章
zt07elecfreaks 发布于2018-01-16 16:16
0/120

Create an Electro-Theremin

楼层直达
Goals

Learn to use an analog sensor with the micro:bit.

Make an electro-theremin!





Materials

1 x BBC micro:bit

1 x Micro USB cable

1 x Buzzer

2 x F-F Jumper Wires

1 x Potentiometer



Procedure

Step 1

Plug in your Buzzer to Pin0. Make sure the positive lead is connected to the yellow signal pin and the negative lead is connected to the black ground pin on the breakout board.

Plug in the potentiometer to Pin1. You can plug according to the color. Make sure that the wire colors and the pin colors on breakout board are well matched!



Step 2

In Makecode, we'll track the value of the potentiometer using a variable. Variables are like buckets that can hold changing values.

Make a new variable called reading (or anything you like, really) in the Variable drawer.

We want to constantly set our reading variable to the analog value of the potentiometer instead of the digital.

Reading the analog value allows us to access a whole range of signals from the potentiometer, instead of just a digital 1 or 0. Find this block in the Pins drawer.



Step 3

Check your minimum and maximum values for your potentiometer by showing the number of the reading variable.

Turning the knob anti-clockwise all the way gives you the minimum, and clockwise all the way gives you maximum.

Notice how the values jump? That's because the micro:bit takes some time to scroll a large number across the screen, and by the time you read a new value, the potentiometer would be way ahead!



Step 4

Now we're going to use those values you just read from your potentiometer to map out your notes!

Our music blocks may not have a range as wide as your potentiometer. In this instance, we want to make sure the highest potentiometer value still corresponds to the highest note we can play.

Check out the value of the lowest and highest notes in the micro:bit piano keys.

Using the map block from the Pins drawer to key in all the values.



Step 5

You may have noticed we made another variable called note in the previous step. Make sure you set the note variable to the mapped values. Ring the tone using the note variable. Upload it all into your micro:bit and you are ready to make some noise!



Cool stuff!

Now you've learned how to play around with the potentiometer, you can try to use it to control LEDs, servos, and other components! And if you get your hands on another analog sensor, you'll know just how to use it!

This article is from TINKERCADEMY:

https://tinkercademy.com/tutorials/electro-theremin/ .
https://www.elecfreaks.com/11084.html
您需要登录后才可以回帖
发表回复

杩斿洖椤堕儴