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
Diff: main.cpp
- Revision:
- 7:a59d1efdbfe1
- Parent:
- 6:e20ec9f212ea
- Child:
- 8:14c5ba6aa06d
diff -r e20ec9f212ea -r a59d1efdbfe1 main.cpp
--- a/main.cpp Thu Feb 14 14:16:10 2019 +0000
+++ b/main.cpp Fri Mar 15 21:57:22 2019 +0000
@@ -1,27 +1,48 @@
#include "mbed.h"
+
#include "Controler.h"
+#include "Stepper.h"
+
+#define VITESSE_MAX 1000
+
+#define CHARRIOT_STEP_pin D3
+#define CHARRIOT_DIR_pin D4
+#define CHARRIOT_ENABLE_pin D7
+#define MCP_TX_pin D10
+#define MCP_RX_pin D2
-Controler mcp;
+Controler mcp(128,MCP_TX_pin,MCP_RX_pin,115200);
+Stepper chariot(CHARRIOT_DIR_pin, CHARRIOT_STEP_pin, CHARRIOT_ENABLE_pin);
+
+Serial pc(SERIAL_TX, SERIAL_RX);
-int main(){
- for(int i=0; i<15; i++) {
- mcp.drive_forward(i);
- wait_ms(100);
- }
- for(int i=15; i>0; i--) {
- mcp.drive_forward(i);
- wait_ms(100);
- }
- for(int i=0; i<15; i++) {
- mcp.drive_backwards(i);
- wait_ms(100);
- }
- for(int i=15; i>0; i--) {
- mcp.drive_backwards(i);
- wait_ms(100);
- }
+InterruptIn button(USER_BUTTON);
+
+Ticker systick;
+int flag=0;
+
+void affiche(){
+ flag=1;
}
+void released()
+{
+ button.disable_irq();
+ mcp.reset_encoder_value();
+ button.enable_irq();
+}
-
+int main()
+{
+ button.fall(&released);
+ systick.attach(&affiche,0.1);
+
+ while(1){
+ if(flag==1){
+ flag=0;
+ pc.printf("%i - %i\n\r", mcp.read_encoder_value_M1(),mcp.read_encoder_value_M2() );
+ }
+ wait(0.01);
+ }
+}
\ No newline at end of file