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: Encoder HIDScope mbed
Fork of DemoHidScopeEncoder by
main.cpp
00001 #include "mbed.h" 00002 #include "HIDScope.h" 00003 #include "encoder.h" 00004 00005 Encoder motor1(D13,D12); 00006 PwmOut led(D9); 00007 HIDScope scope(1); 00008 00009 DigitalOut motor_direction(D4); 00010 PwmOut motor_speed(D5); 00011 00012 DigitalIn button_1(PTC6); //counterclockwise 00013 DigitalIn button_2(PTA4); //clockwise 00014 00015 const int pressed = 0; 00016 00017 00018 void move_motor_ccw (){ 00019 motor_direction = 0; 00020 motor_speed = 1; 00021 } 00022 00023 void move_motor_cw (){ 00024 motor_direction = 1; 00025 motor_speed = 0.1; 00026 } 00027 00028 int main() 00029 { 00030 scope.set(0,motor1.getPosition()); 00031 00032 while (true) { 00033 00034 if (button_1 == pressed){ 00035 move_motor_cw (); 00036 } 00037 else if (button_2 == pressed){ 00038 move_motor_ccw (); 00039 } 00040 else { 00041 motor_speed = 0; 00042 } 00043 00044 led.write(motor1.getPosition()/100.0); 00045 scope.send(); 00046 wait(0.2f); 00047 00048 } 00049 }
Generated on Tue Jul 19 2022 22:30:25 by
1.7.2
