Added various bits, main reformatted. Added .get to class Servo to allow waiting for rotation before recording information.
Fork of Lab6_Basic by
main.cpp
- Committer:
- ziadeldebri
- Date:
- 2016-11-17
- Revision:
- 4:b3a93554fedf
- Parent:
- 3:b787aa49b900
- Child:
- 6:a64d79286726
File content as of revision 4:b3a93554fedf:
#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: */ /* */ /****************************************************************************************/ Servo my_servo(PTB3,PTE19,PTE18,PTE31); AnalogIn Spanel(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] = Spanel.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); } }