Commit 68b128e2 authored by Daniel Stan's avatar Daniel Stan

update lotus

parent 8346abe0
......@@ -2,7 +2,8 @@
avec programme python coté port série*/
// Pin du recepteur Infrarouge
#define RECV_PIN 13
//#define RECV_PIN 13
#define RECV_PIN A2
// Pin du moteur
#define RF_M_CONT 10
#define RF_M_DRV1 11
......@@ -16,6 +17,22 @@ avec programme python coté port série*/
#include <IRLib.h>
// Définition des codes boutons de ma télécommande, so far
#define BTN_UP 0xFDA05F
#define BTN_DOWN 0xFDB04F
#define BTN_PAUSE 0xFD807F
#define BTN_VOL_DOWN 0xFD00FF
#define BTN_VOL_UP 0xFD40BF
#define BTN_4 0xFD28D7
#define BTN_3 0xFD48B7
#define BTN_2 0xFD8877
#define BTN_1 0xFD08F7
#define BTN_LEFT 0xFD10EF
#define BTN_RIGHT 0xFD50AF
#define BTN_RETURN 0xFD708F
#define BTN_ENTER 0xFD906F
#define BTN_STOP 0xFD609F
#define BTN_SETUP 0xFD20DF
IRrecv My_Receiver(RECV_PIN);
......@@ -35,11 +52,29 @@ void setup()
pinMode(RF_M_CONT, OUTPUT);
pinMode(RF_M_DRV1, OUTPUT);
pinMode(RF_M_DRV2, OUTPUT);
digitalWrite(RF_M_CONT, HIGH);
digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_CONT, LOW);
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, LOW);
}
void move(bool going_up) {
if(going_up) {
Serial.println("Going up");
digitalWrite(RF_M_DRV1, HIGH);
digitalWrite(RF_M_DRV2, LOW);
} else {
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);
digitalWrite(RF_M_CONT, LOW);
digitalWrite(RF_M_DRV1, LOW);
digitalWrite(RF_M_DRV2, LOW);
}
void loop() {
......@@ -80,48 +115,55 @@ void loop() {
}
}
if (My_Receiver.GetResults(&My_Decoder)) {
Serial.println("Reading");
//Restart the receiver so it can be capturing another code
//while we are working on decoding this one.
My_Receiver.resume();
if ( My_Decoder.decode() )
switch (My_Decoder.value) {
case 0xFD807F:
case BTN_UP:
move(true);
break;
case BTN_DOWN:
move(false);
break;
case BTN_PAUSE:
Serial.println("Control: PPause");
break;
case 0xFD00FF:
case BTN_VOL_DOWN:
Serial.println("Control: Vol-");
break;
case 0xFD40BF:
case BTN_VOL_UP:
Serial.println("Control: Vol+");
break;
case 0xFD08F7:
case BTN_1:
Serial.println("Control: 1");
break;
case 0xFD8877:
case BTN_2:
Serial.println("Control: 2");
break;
case 0xFD48B7:
case BTN_3:
Serial.println("Control: 3");
break;
case 0xFD28D7:
case BTN_4:
Serial.println("Control: 4");
break;
case 0xfd10ef:
case BTN_LEFT:
Serial.println("Control: Prev");
break;
case 0xfd50af:
case BTN_RIGHT:
Serial.println("Control: Next");
break;
case 0xfd20df:
case BTN_SETUP:
Serial.println("Control: Setup");
break;
case 0xfd609f:
case BTN_STOP:
Serial.println("Control: Stop");
break;
case 0xfd906f:
case BTN_ENTER:
Serial.println("Control: Enter");
break;
case 0xfd708f:
case BTN_RETURN:
Serial.println("Control: Return");
break;
default:
......
......@@ -10,7 +10,7 @@ import sys
import os
import time
SERIALPORT = "/dev/ttyUSB0"
SERIALPORT = "/dev/ttyUSB1"
BAUDRATE = 9600
CONTROL=b'Control:'
SOCK_P='/var/run/user/%d/remote' % os.getuid()
......
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