Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed servo_motor mbed-rtos
Revision 1:f43b9b2d82be, committed 2019-12-18
- Comitter:
- marvas
- Date:
- Wed Dec 18 12:34:42 2019 +0000
- Parent:
- 0:75bd93370a68
- Commit message:
- servo(pot ile) ve step motor kontrolu
Changed in this revision
--- a/main.cpp Wed Dec 18 11:13:06 2019 +0000
+++ b/main.cpp Wed Dec 18 12:34:42 2019 +0000
@@ -1,17 +1,58 @@
#include "mbed.h"
+#include "rtos.h"
+#include "servo.h"
+
+float oku;
+Thread servo_is_parcasi;
+servo servo_motor(PC_8);
+AnalogIn pot(PA_0);
PortOut step_motor(PortB,0xC006);
-int main()
+int adim=0;
+int aci=0;
+void servo_motor_metodu()
{
while(1)
{
-step_motor=0x0002;//PB_1 hex
-wait_ms(3);
-step_motor=0x0004;//PB_2 hex
-wait_ms(3);
-step_motor=0x4000;//PB_14 hex
-wait_ms(3);
-step_motor=0x8000;//PB_15 hex
-wait_ms(3);
+ oku=pot.read();//0.0 ile 1.0 arasında değer okuması yapar
+ aci=int(oku*175);
+ printf("%d \n",aci);
+
+ servo_motor.derece(aci);
+ }
+ }
+
+int main()
+{
+ servo_is_parcasi.start(servo_motor_metodu);
+ step_motor=0x0000;
+ while(1) {
+ adim++;
+ if(adim<500) {//saat yönünde döner
+ step_motor=0x0002;//PB_1 hex
+ wait_ms(3);
+ step_motor=0x0004;//PB_2 hex
+ wait_ms(3);
+ step_motor=0x4000;//PB_14 hex
+ wait_ms(3);
+ step_motor=0x8000;//PB_15 hex
+ wait_ms(3);
+ }
+ else if(adim==500)
+ {
+ step_motor=0x0000;
+ }
+ else if(adim>500 && adim<750) {//saat yönünün tersine döner
+ step_motor=0x8000;//PB_15 hex
+ wait_ms(3);
+ step_motor=0x4000;//PB_14 hex
+ wait_ms(3);
+ step_motor=0x0004;//PB_2 hex
+ wait_ms(3);
+ step_motor=0x0002;//PB_1 hex
+ wait_ms(3);
+ } else {
+ adim=0;
+ }
}
return 0;
- }
\ No newline at end of file
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Dec 18 12:34:42 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servo_motor.lib Wed Dec 18 12:34:42 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/marvas/code/servo_motor/#a693d4a007d6