Commit 9f2e747c authored by Daniel STAN's avatar Daniel STAN

màj lotus

parent c096c40c
......@@ -5,15 +5,15 @@ avec programme python coté port série*/
//#define RECV_PIN 13
#define RECV_PIN A2
// Pin du moteur
#define RF_M_CONT 10
#define RF_M_DRV1 11
#define RF_M_DRV2 12
#define RF_M_CONT 12 //EN 3,4, ex 10
#define RF_M_DRV1 11 //3A
#define RF_M_DRV2 10 //4A, ex 12
#define PIN_POS A0
#define POS_HIGH 262
#define POS_LOW 105
#define BOUNCE 20
#define POS_HIGH 280
#define POS_LOW 107
#define BOUNCE 3
#include <IRLib.h>
#include "remote.h"
......@@ -42,24 +42,50 @@ void setup()
}
void move(bool going_up) {
int target;
int comp;
int val;
if(going_up) {
comp=1;
target = POS_HIGH;
Serial.println("Going up");
digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_DRV2, LOW);
} else {
comp=-1;
target = POS_LOW;
Serial.println("Going down");
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, HIGH);
}
digitalWrite(RF_M_CONT, HIGH);
delay(300);
if(!going_up)
delay(200);
delay(1);
while((val = analogRead(PIN_POS)*comp) < target*comp) {
if(My_Receiver.GetResults(&My_Decoder)) {
My_Receiver.resume();
if( My_Decoder.decode() == BTN_STOP ) {
Serial.println("Manual stop");
break;
}
}
delay(1);
}
Serial.print("Stopping because");
Serial.println(val);
report_pos();
/*delay(300);
if(going_up)
delay(200);*/
digitalWrite(RF_M_CONT, LOW);
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, LOW);
}
void report_pos() {
Serial.println("Report");
Serial.println(analogRead(PIN_POS));
}
void loop() {
int val;
......@@ -95,7 +121,7 @@ void loop() {
digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_DRV2, LOW);
} else if(incomingByte == 'r') {
Serial.println(analogRead(PIN_POS));
report_pos();
}
}
if (My_Receiver.GetResults(&My_Decoder)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment