ECE 111 At Oregon State University / Mbed 2 deprecated Lab6_Basic

Dependencies:   mbed

Fork of Lab6_Basic by ECE 111 At Oregon State University

main.cpp

Committer:
dogcatfee
Date:
2017-11-14
Revision:
6:65dfd3886629
Parent:
4:b3a93554fedf
Child:
7:33a516c08c09

File content as of revision 6:65dfd3886629:

#include "mbed.h"
#include "Motor.h"
#include "Servo.h"
/************************************* Lab5 Motor to servo     **************************/
/*                                                                                      */
/*  File: main.cpp                                                                      */
/*  Author: Ziad Eldebri                                                                */
/*  Date Created: 9/19/2016                                                             */
/*  Description:              */
/*                                                                                      */
/****************************************************************************************/
// Edit ~ Matthew Sessions

// KL46
// Servo my_servo(PTB3,PTE19,PTE18,PTE31);
// KL43
Servo my_servo(PTB3,PTB0,PTB1,PTE29);
AnalogIn solar_panel(PTB2);

uint16_t reading_array[3];
int position_array[3]={30,75,120};
uint16_t largest = 0; 
int largesti = 0;
int i;

int main() 
{
    while (1) 
    {  
        for (i = 0; i < 3; i++)
        {
            my_servo.set(position_array[i]);
            wait(3);
            reading_array[i] = solar_panel.read_u16();
        }
        for (i = 0; i < 3; i++)
        {
            if (reading_array[i] > largest)
            {
                largest = reading_array[i];
                largesti = i;
            }
        }
        my_servo.set(position_array[largesti]);
        wait(15);
    }
}