BTSmartFan Servo/DC motor controlled using Bluetooth
http://www.instructables.com/id/Just-make-it-BT-Smart-Fan-/
Revision 0:7441087c2a16, committed 2015-06-29
- Comitter:
- justinkim
- Date:
- Mon Jun 29 01:27:03 2015 +0000
- Commit message:
- first release
Changed in this revision
diff -r 000000000000 -r 7441087c2a16 Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Mon Jun 29 01:27:03 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 7441087c2a16 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 29 01:27:03 2015 +0000 @@ -0,0 +1,101 @@ +/** + ****************************************************************************** + * @project Smart BT Fan + * @author Justin Kim + * @version V1.0.0 + * @date 29-JUN-2015 + * @brief Main program body +******************************************************************************* +**/ + +/* Includes ------------------------------------------------------------------*/ +#include "mbed.h" +#include "Servo.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +Serial pc(USBTX, USBRX); +Serial bt(PA_14, PA_13); +Servo myservo(D14); +PwmOut Motor(D3); +DigitalOut direction(D12); + +/* Private function prototypes -----------------------------------------------*/ + +/* Private functions ---------------------------------------------------------*/ +/** + * @brief Main Function + * @param None + * @retval None + */ +int main(void) +{ + char ch; + pc.baud(115200); + bt.baud(115200); + pc.printf("Hello World!\n\r"); + bt.printf("Hello World!\r\n"); + + direction.write(1); + Motor.period_ms(1); + + while(1) + { + if(bt.readable()) + { + ch=bt.getc(); + pc.printf("%c",ch); + bt.printf("%c",ch); + + if(ch == '*') + { + myservo = 0.5; + } + else if(ch == '+') + { + myservo = myservo + 0.1; + } + else if(ch == '-') + { + myservo = myservo - 0.1; + } + else if(ch == '@') + { + Motor.write(0.8); + } + else if(ch == '!') + { + Motor.write(0); + } + } + + else if(pc.readable()) + { + ch=pc.getc(); + bt.printf("%c",ch); + pc.printf("%c",ch); + + if(ch == '*') + { + myservo = 0.5; + } + else if(ch == '+') + { + myservo = myservo + 0.1; + } + else if(ch == '-') + { + myservo = myservo - 0.1; + } + else if(ch == '@') + { + Motor.write(0.8); + } + else if(ch == '!') + { + Motor.write(0); + } + } + } +}
diff -r 000000000000 -r 7441087c2a16 mbed-src.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-src.lib Mon Jun 29 01:27:03 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-src/#30f9462b5296