Goal: Simulate the reactions of a nervous / lonely puppy using servo's + the mbed LPC1768.
Dependencies: mbed-rtos-edited mbed Servo C12832
nervousPuppy.h
- Committer:
- SeanDoyle
- Date:
- 2015-01-14
- Revision:
- 3:74dfce05dd99
- Parent:
- 2:8415bea33a95
- Child:
- 4:2b47356f4b7d
File content as of revision 3:74dfce05dd99:
#include "mbed.h" #include "rtos.h" #include "Servo.h" #include <math.h> #include <string> #define Cos(a) cos(PI/180*(a)) #define Sin(a) sin(PI/180*(a)) #define PI 3.1415926 class nervousPuppy{ public: nervousPuppy(); bool isLonely(); bool isScared(); bool shutdown(); void detectPlayer(); float getPlayerDistance(); void setPlayerDistance(float dist); float calculateAngle(string axis); void changePosition(string servo,float angle); private: //Servo tilt(); //Servo rotate(); Mutex lockForDistance; //Not sure why needed float playerDistance, playerError; bool scared, lonely; const float LONELY = 10.0f; //Placeholder number const float SCARED = 3.0f; //Placeholder number const float RADIUS = 2.0f; //Placeholder number const float SHUTDOWN = 1.0f; //Placeholder number const float PULSE_RATE = 10; //Placeholder number - Pulses per second const float SERVO_TILT_LIMIT = 45; //Placeholder number - max angle servo can tilt by const float SERVO_ROTATE_LIMIT = 45; //Placeholder number - max angle servo can rotate by };