2 Motores + Joystick
Dependencies: X_NUCLEO_IHM01A1 TextLCD
Fork of HelloWorld_IHM01A1_2Motors_mbedOS by
Revision 41:7f91e949ca88, committed 2018-05-03
- Comitter:
- leogrotti
- Date:
- Thu May 03 18:23:42 2018 +0000
- Parent:
- 40:0b517b49f70d
- Child:
- 42:a04bff02f231
- Commit message:
- 3 motores + joystick+2botoes;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 02 14:59:42 2018 +0000
+++ b/main.cpp Thu May 03 18:23:42 2018 +0000
@@ -68,7 +68,8 @@
/* Variables -----------------------------------------------------------------*/
-DigitalIn button1(D2);
+InterruptIn button1(PC_1);
+InterruptIn button2(PC_0);
/* Initialization parameters. */
//L6474_init_t init = {
@@ -150,6 +151,32 @@
/* Main ----------------------------------------------------------------------*/
+void pressed_cima() {
+
+ motor3->run(StepperMotor::FWD);
+ printf ("Ariba! \r\n");
+
+}
+void pressed_baixo() {
+
+ motor3->run(StepperMotor::BWD);
+ printf ("Abajo! \r\n");
+
+}
+void released_1()
+{
+ motor3->hard_stop();
+ printf ("parou \r\n");
+
+}
+
+void released_2()
+{
+ motor3->hard_stop();
+ printf ("parou \r\n");
+
+}
+
int main()
{
/*----- Initialization. -----*/
@@ -173,42 +200,42 @@
- /*motor1->set_acceleration(160);
- motor2->set_acceleration(160);
- motor1->set_max_speed(speed1);
- motor2->set_max_speed(speed2);*/
-
-
-
-
-//motor1->set_min_speed(1300);
-//motor2->set_min_speed(1300);
-
-//motor1->set_parameter(L6474_STEP_MODE,L6474_STEP_SEL_1_2);
-//motor2->set_parameter(L6474_STEP_MODE,L6474_STEP_SEL_1_2);
/* Attaching and enabling interrupt handlers. */
motor3->attach_flag_irq(&flag_irq_handler);
motor3->enable_flag_irq();
+
+
+ button1.rise(&pressed_cima);
+ button2.rise(&pressed_baixo);
+ button1.fall(&released_1);
+ button2.fall(&released_2);
while(true) {
u = eixo_X.read();
w = eixo_Y.read();
- if (button1.read() == 0){
+ /* if (button1.read()==0()){
- motor3->run(StepperMotor::FWD);
+ button.fall()
printf("button1 fwd \r\n\n");
}
- else {
- motor3->run(StepperMotor::BWD);
- printf("button1 bwd \r\n\n");
+ // else {
+ // motor3->run(StepperMotor::BWD);
+ // printf("button1 bwd \r\n\n");
- }
+ // }
+
+ if (button1.read()==0){
+
+ button1.rise()
+ printf("button1 bwd \r\n\n");
+
+ }*/
if (u>0.740) {
