Musical e-textile bag

Auteur avatarDigijeunes | Dernière modification 9/12/2019 par Clementflipo

Musical e-textile bag IMG 1086.JPG
This tutorial requires an e-textile bag which includes a piezo speaker.
Difficulté
Moyen
Durée
1 heure(s)
Catégories
Vêtement & Accessoire, Électronique
Coût
20 EUR (€)
Autres langues :
English
Licence : Attribution (CC BY)

Introduction

In this tutorial you will learn how to make sounds with a piezo speaker mounted on the e-textile bag.

Matériaux

Outils

Étape 1 - Prepare the board and the bag

Connect one end of the micro USB cable to the computer, the other end to the Arduino Leonardo board.

Connect the positive side of the piezo speaker patch to pin 13 on the Arduino leonardo

Connect the negative leg of the piezo speaker patch to GND on the board. You can use either of the 3 GND pins available on the board.



Étape 2 - Set up the board on mBlock

Before you can start programming your Arduino, you will need to set it up on mBlock.

Choose the version depending on your operating system (e.g. If you have a MacBook, choose “Mac OS” / if you have Windows 10, choose “Windows 7 and above”).

Download mBlock 3, not the latest version (mBlock 5). Download and run the installation files and then open mBlock.

Select the Arduino Leonardo board from the “Boards” menu.

Then connect to your Arduino board (the COM port number varies based upon your computer’s USB plugs - when you choose the correct one to which your Arduino Leonardo is connected to, the ON and TX led lights on the board will turn solid green, and orange respectively).



Étape 3 - Coding on mBlock

On mBlock, you will need to create a simple code to have your piezo speaker patch play some notes.

The code should look exactly like this.

You need to drag and drop each block from the “Scripts” section on the middle to the blank area on the right hand side.

You will find each block in the following subsections:

  1. When <space> key pressed - “Events” subsection
  2. play tone pin <13> on note <C4> beat <Half> - “Robots” subsection
  3. wait 0.2 secs - “Control” subsection

Note the you can change small details to make your own personal code. For example you can change the length of each note or change the notes altogether.

When you are done coding, click on “Upgrade Firmware” in the Connect menu (at which point both the RX and the TX led lights on the board will flash orange).

Do this only once. You can now modify your code without having to Upgrade the Firmware each time.



Étape 4 - Coding on Arduino IDE

It’s possible that you will encounter problems connecting your Arduino Leonardo to mBlock. In that case, you may need to use Arduino IDE to code and upload the firmware onto your Arduino Leonardo board.

Download the software by visiting Arduino IDE > Scroll down until you see the “Download the Arduino IDE” section and choose the version based upon your operating system (e.g. If you have Windows 7, choose “Windows Installer” / if you have Windows 10, choose “Windows app”) > On the next page choose “Just download” and run the installation files.

Launch Arduino IDE select Arduino Leonardo from the Tools menu > Board.

Select the correct port from the Tools menu > Port.

Choose the toneMelody or toneMultiple example from File > Examples > 02.Digital > toneMelody / toneMultiple.

Finally, upload the code by using the right arrow (→) button at the top right corner of the window, by choosing Sketch > Upload or by pressing Ctrl+U on the keyboard

Alternatively, you can use both tools together in order to easily create code (by using the intuitive interface mBlock offers) and then reliably upload it to the board (by using the strong connection to the board that Arduino IDE offers).

In mBlock, you simply need to click on Edit > Arduino Mode and when the new pane opens up on the right-hand side, choose Edit with Arduino IDE.

Afterwards, simply follow the same steps as before to upload the code to the board and you should be good to go!


Commentaires

Draft