CC
COLLEGE OF
                                                       S
                                                COMPUTER STUDIES
                   MOOD CUE
        In Partial Fullfilment for the Course
BACHELOR OF SCIENCE IN COMPUTER ENGINEERING
                   In the Subject
       CpE Elec 111 MICROELECTRONICS
                   Submitted by:
               Collamar, Abiegail R.
              Enriquez, Mikka Ella P.
          Faigmani, Mark Kliem Well M.
              Ison, Eindrae Clarence
              Robiso, John Dave R.
                   Submitted to:
              Engr. Arnold F. Reano
                    Instructor I
                                                                COLLEGE OF
                                                                              CC
                                                                              S
                                                                COMPUTER STUDIES
                            TABLE OF CONTENTS
I.   OVERVIEW
        Servo motors are a special type of motor that don’t spin around in a circle,
     but move to a specific position and stay there until you tell them to move
     again. Servos usually only rotate 180 degrees (one half of a circle).
     Combining one of these motors with a little cardboard craft, you’ll be able to
     let people know if they should come and ask for your help on their next
     project or not. Similar to the way you used pulses to PWM an LED in the
     Color Mixing Lamp Project, servo motors expect a number of pulses that tell
     them what angle to move to. The pulses always come at the same time
     intervals, but the width varies between 1000 and 2000 microseconds.
        While it’s possible to write code to generate these pulses, the Arduino
     software comes with a library that allows you to easily control the motor.
     Because the servo only rotates 180 degrees, and your analog input goes from
     0-1023, you’ll need to use a function called map() to change the scale of the
     values coming from the potentiometer. One of the great things about the
     Arduino community are the talented people who extend its functionality
     through additional software. It’s possible for anyone to write libraries to extend
     the Arduino’s functionality. There are libraries for a wide variety of sensors
     and actuators and other devices that users have contributed to the
     community. A software library expands the functionality of a programming
     environment. The Arduino software comes with a number of libraries that are
     useful for working with hardware or data. One of the included libraries is
     designed to use with servo motors.
     MATERIALS
     Table 1. The Materials and Equipment Used in the Laboratory Activity
                  Potentiometer                         Male Headed Pins
                    Servo Motor                            100uf Capacitor
                                                                 COLLEGE OF
                                                                               CC
                                                                               S
                                                                 COMPUTER STUDIES
          The table above shows the different equipment and materials that are
       need to understand the project to build which entitled “Mood Cue” where the
       elements required are : potentiometer, servomotor, male headedpins and two
       100uf capacitor.
II.    PROCEDURES
          1. Attach 5V and ground to one side of your breadboard from the
             Arduino.
          2. Place a potentiometer on the breadboard, and connect one side to 5V,
             and the other to ground. A potentiometer is a type of voltage divider.
             As you turn the knob, you change the ratio of the voltage between the
             middle pin and power. You can read this change on an analog input.
             Connect the middle pin to analog pin 0. This will control the position of
             your servo motor.
          3. The servo has three wires coming out of it. One is power (red), one is
             ground (black), and the third (white) is the control line that will receive
             information from the Arduino. Plug three male headers into the female
             ends of the servo wires (see Fig. 3). Connect the headers to your
             breadboard so that each pin is in a different row. Connect 5V to the red
             wire, ground to the black wire, and the white wire to pin 9.
          4. When a servo motor starts to move, it draws more current than if it
             were already in motion. This will cause a dip in the voltage on your
             board. By placing a 100uf capacitor across power and ground right
             next to the male headers as shown in Fig. 1, you can smooth out any
             voltage changes that may occur. You can also place a capacitor
             across the power and ground going into your potentiometer. These are
             called decoupling capacitors because they reduce, or decouple,
             changes caused by the components from the rest of the circuit. Be
             very careful to make sure you are connecting the cathode to ground
             (that’s the side with a black stripe down the side) and the anode to
             power. If you put the capacitors in backwards, they can explode.
III.   PROGRAM CODES
          #include <Servo.h>// Importing the Servo lybrary
          Servo MyServo;//Variable refering to the servo lybrary. It has all the
                function that the lybrary has.
          int const PinPot=A0;//Connecting the potentiometer to an analog and
                 creating the properly constant
         int ValuePot;//Creating variable
                                                                COLLEGE OF
                                                                              CC
                                                                              S
         int Angle;//Creating variable
                                                                COMPUTER STUDIES
         void setup() {
         MyServo.attach(9);//Relating the servo to the pin 9
         Serial.begin(9600);//Initialting the serial port
         void loop() {
         ValuePot=analogRead(PinPot);//Reading PinPot
         Serial.print("Potentiometer position:");//Showing the previous on the serial
                monitor
         Serial.print(ValuePot);
         Angle=map(ValuePot,0,1023,0,179);//Changing the scale values
         Serial.print(", Angle: ");
         Serial.print(Angle);
IV.   SCHEMATIC DIAGRAM AND BREADBOARD DIAGRAM
         As it is shown in the figure above,the potentiometer must be connected to
      an analog input as long as to the 5v entry and to the ground. Otherwise, the
      servo must be to a digital as it input to the 5v and the GND. Then, it will
      connect to the capacitors properly as it have the polarity. It includes with the
      codes, that are used in this activity. However, in this case it doesn’t present
      any of differences from the code on the module.
V.    CONCLUSIONS
         The observation at this project indicates not only the learning but more
      about Arduino but also that you are committed to using it to produce fantastic
      turn on a few LEDs won't make a difference. But soon,COLLEGE        OF
                                                                               CC
      results. Despite this, it is likely accurate to state that understanding how to
                                                           this we'll go through
                                                                               S
                                                                 COMPUTER STUDIES
      how to start things moving. A servomotor will be utilized to do this. As you are
      probably aware, it is a type of motor that moves into a position and stays
      there if no additional instructions are given. In addition, it should be
      understood that a
      servo that employ the same method used for PWM on the prior project to
      inform the servo what angle it should rotate at. Nevertheless, that the
      information sent
      to the servo would either be one or the other based on the pulse width
      adjustment. To achieve this, a potentiometer will be utilized as an analog
      input. In this manner, the servo will rotate along with the potentiometer.
VI.   REFERENCES
      https://programminginarduino.wordpress.com/2016/03/01/project-05/