IX: Electronic Output Devices
I.LED strip
If you want to make a spectacle with dozens of sole LED, that job will be really tough because you need to operate them under different pins and write really complicated program for each of them. But for LED strips, that job becomes much easier since you could operate dozens of LED in a particular LED strip under only one pin and program them together. Let me show you a demo of LED strip that I make in the class.
You can see that you can finish a lot of tasks in a strip: blinking, changing colors, fading and etc. Here is the program of my demo.
Actually, you can easily find it in the libraries of Arduino: Sketch-Include Library-Manage Libraries-Search Adafruit NeoPicxel-Install
At the same time, if you want to know more things about LED strips, you can visit and explore the website of Adafruit NeoPicxel.
II.Buzzer
I used a lot of output devices in the past class like LED and motors, so I need to choose a different output device for this lab time. I am a music fan so that choosing buzzer is a easy decision for me. When my sister was only a 3 years old kid, I always wanted to play a song for her. But I don’t know any instruments, this time is a good opportunity for me to make up for this pity. I choose the most famous nursery rhyme in China-two tigers. You can click the play button to play my audio record.
I find the frequency of every pitch from the reference tables for frequencies of musical notes.
By the way, because of this project, I have to review the music score. After finding the corresponding frequencies for the different musical notes, I program my song. I swear this is the longest program I’ve ever written. Here is the programming:
int buzzerPin = 2;
void setup() {
// put your setup code here, to run once:
}
void loop() {
tone(buzzerPin, 261.63, 500);
delay(500);
tone(buzzerPin, 293.66, 500);
delay(500);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 261.63, 500);
delay(550);
tone(buzzerPin, 261.63, 500);
delay(500);
tone(buzzerPin, 293.66, 500);
delay(500);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 261.63, 500);
delay(550);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 349.23, 500);
delay(500);
tone(buzzerPin, 392, 1000);
delay(1000);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 349.23, 500);
delay(500);
tone(buzzerPin, 392, 1000);
delay(1050);
tone(buzzerPin, 392, 375);
delay(375);
tone(buzzerPin, 440, 125);
delay(125);
tone(buzzerPin, 392, 375);
delay(375);
tone(buzzerPin, 349.23, 125);
delay(125);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 261.63, 500);
delay(550);
tone(buzzerPin, 392, 375);
delay(375);
tone(buzzerPin, 440, 125);
delay(125);
tone(buzzerPin, 392, 375);
delay(375);
tone(buzzerPin, 349.23, 125);
delay(125);
tone(buzzerPin, 329.63, 500);
delay(500);
tone(buzzerPin, 261.63, 500);
delay(550);
tone(buzzerPin, 261.63, 500);
delay(500);
tone(buzzerPin, 196, 500);
delay(500);
tone(buzzerPin, 261.63, 1000);
delay(1050);
tone(buzzerPin, 261.63, 500);
delay(500);
tone(buzzerPin, 196, 500);
delay(500);
tone(buzzerPin, 261.63, 1000);
delay(1050);
}
You can also download myPROGRAM!
Problems:
-
Duration of the syllable: Because we babrely talk about the real time of every syllable in music and I’m not very good at music, I can only estimate the duration of every syllable and keep modifying the delay by my experience.
-
You need to be careful of the third argument in the tone() and the number in the delay()function. When you put 1000 in the third argument in the tone()function and put 1050 in the delay()function, your program will only have a 50 milliseconds “rest”. You need to do a subtraction here.
III.Motor
I tried miniwatt motor before this class, but I need a powerful motor for my final project to pull the car. As a result, I try to add a powerful DC motor into my circuit after finishing the buzzer project.
Problems:
-
Initially, the DC motor in the circuit doesn’t work at all. But for the miniwatt motor, it works well. The reason is that a powerful DC motor need around 9 volts to operate well. So I need to find a way to solve this problem-transistor.
-
After using the transistor, I make a mistake about the attachment of different legs of the transistor. Unlike most elements in the circuit, you need to attach a transistor to three different holes of Arduino NANO-5v, GND, and Pin. I firstly connect the motor to the Pin. Although the motor works, it rotates very slowly. Later Rob finds this mistake and reattaches the motor to the 5v. After being corrected, the motor works well.
**If someone also is confused about how to use a transistor in the circuWEBSITE.it, please visit this**
- Even though the motor works well, I want to try to speed it up more. For this, Andrei and Rob both agree that we can use a extra power. But no matter how we attach the extra power to diffrent holes of the Arduino, it doesn’t function. It’s really weird. Although Andrei, Rob, and I spend 40 minutes after the lab time trying to solve this problem, we still have no idea.
The Project
With the wrong attachment of the transistor:
After correcting:
You can see that the rotation of the motor become much faster with the right attachment of the transistor.
Summary
During this class and lab time, we do a lot of interesting things with the LED strip and buzzers. I have a try with a output device that I never use and program it before. These new things bring me new thinking about engineering: we think about making things not only in industry but also in normal life. And during constrcuting new output device, I do something worthful for my final project.