Week12

Output Devices

servo motor

Assignment:

  • add an output device to a microcontroller board you've designed, and program it to do something
  • measure the power consumption of an output device
  • Measure the power consumption of an output device

    You can see the complete documentation of group assignments on the opendot website at this LINK.

    Intro

    Also for the week of output I decided to focus on what could be useful for the final project. On the board of last week I had already assumed the connectors for a servo motor. Unfortunately, however, one of the connectors on the card has broken (that of the Hall sensor) so at this moment I can not connect inputs and outputs to program them at the same time.

    FINAL P. IDEA

    After two tiring weeks I managed to draw and mill a working board (for now). you can see all the process on my Input page and you can download the png file of board here:

       
    	
    	
        

    I wrote the code to make the board read through the Hall sensor the approach of the magnet placed on the drawer lock system.

    Now I have to be able to move the servo motor after reading this sensor. The servo must move only once and stop in the locked position. It will have to reactivate only when the card will communicate with the microcontroller positioned on the top of drawers. This operation will allow the piece to be unlocked, in order to remove it and open the drawer.

    PART1: MOVE A SERVO MOTOR

    Before starting I tried to better understand how a servo motor works and how it moves. I had already read part of the datasheet while designing the board to understand the pinout. I have not really chosen which servo motor I will use in the final project but it seems that there is not much difference (I hope).

    I started by testing the servo motor with an example code to understand how it works.

    test: SERVO MOTOR1

            
            #include  
            Servo myservo; //servo control
            int pos = 0; //posizione iniziale
          
            void setup(){
            myservo.attach(10); //(Digital pin 10) 
          
            Serial.begin(19200); // 19200 is the rate of communication
            Serial.println("Haupei"); // some output for debug purposes.
            }
            void loop() {
           for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
             myservo.write(pos);              // tell servo to go to position in variable 'pos'
             delay(15);  
             for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
             myservo.write(pos);              // tell servo to go to position in variable 'pos'
             delay(15);                       // waits 15ms for the servo to reach the position
             }
             }
             }