Motor Driver

In use of Motor Driver

Thanks to my team members: Shuainan Yang and Cynthia Ye

IMG_0323.jpg

For this project, we decided to create a magic ball. When the hands of the user approach the ball from both sides, there will be feathers flying in the other box, and there will also be playing a Harry Potter's theme song. The height of the feathers and the music's volume will depend on the distance between the user's hands and the magic ball. If hands get closer, then furs will be higher, and the volume will be higher.

(Now we realized that volume cannot be controlled by the sensor, so we decided to change to when the user touch the ball, then song will be played automatically).

Firstly, we used the ultrasonic sensor to control the LED lights as a test, but it failed several times because the LED lights only turned on or off. We serial. print the value of the LED light, and in about 170, the LED light will turn on, but an ultrasonic sensor cannot make it lighter or darker. So we look our circuit, and I re-try the lab that we did several weeks ago, then finally, I realized that we should use PWM from the Arduino. Otherwise, it will not have a range for us to control the light of the LED. After this test, because the fan that we bought is not delivered yet, we replaced the LED light with a motor, and it worked.

https://youtu.be/j5y9Irsbgro

https://youtu.be/OCmHlkQp4Mw

Q: Now we map the range of the fan from 255 to 135, but when it first starts, it needs us to use our hand to touch the fan, then it will work.

A: There is a threshold for the fan, and it has to pass to the amount if the number, then the fan can be work. Therefore, we decided to set the fan starting with 135.

Secondly, we put fan into the box to blow up the feather, we used one fan first, but the result didn't turn well. So, we decided to add one more fan, here is the test:

IMG_4844.HEIC

IMG_8860.HEIC

This is the testing:

When we ran the code first, we realized that in the for loop, the LED lights have to go through a cycle, then it will be able to detect the distance of the hands, so we decided to use mills to solve this problem, but now we need to figure out how to use sensor control the tone in this loop.

time=millis();
    int fadein=128+127*sin(2*PI/fade*time);
    analogWrite(ledPin1,fadein);
    analogWrite(ledPin2,fadein);