Simply creates a servo object from a motor object, to allow the control of the angle. uses the solar panel to look for the brightest spot, then stops.
Dependencies: mbed
Fork of Lab6_Basic by
main.cpp
- Committer:
- dogcatfee
- Date:
- 2017-11-14
- Revision:
- 8:0d8f931d6f8c
- Parent:
- 7:33a516c08c09
File content as of revision 8:0d8f931d6f8c:
#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]={24,69,72}; 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); } }