Skip to content

Commit

Permalink
Merge pull request #1 from UlmerMan/dev
Browse files Browse the repository at this point in the history
Added IR Support
  • Loading branch information
UlmerMan authored Feb 6, 2023
2 parents ebdf0c7 + 79d6284 commit 8e54d77
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 44 deletions.
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name=Elegoo
version=1.0.2
author=AUTHORS
version=1.1.0
author=Manuel Ulmer
url=https://git.aerospace-lab.de/manuel.ulmer/ELEGOO-Smart-Robot-Car-Kit
maintainer=Manuel Ulmer
sentence=This is a library to use the ELEGOO Smart Robot Car Kit.
paragraph=You can use Funstions to drive and to read out Sensors.
paragraph=You can use Functions to drive and to read out Sensors.
category=Device Control
architectures=*
includes=Elegoo.h
Expand Down
8 changes: 4 additions & 4 deletions src/Elegoo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define car_H
#include <Arduino.h>
#include <Servo.h>
//#include <IRremote.h>


//--------Ultrasonic Sensor---------//
Expand Down Expand Up @@ -66,9 +65,9 @@ class elegoo
void leftT(int speed, float time);
void rightT(int speed, float time);
unsigned long getIR();
//char getIRdec();
//void remoteIR();
//void remoteIRT(int time);
char getIRdec();
void remoteIR();
void remoteIRT(int time);
int getLightR();
int getLightM();
int getLightL();
Expand All @@ -78,6 +77,7 @@ class elegoo
void delay(unsigned long time);
void remote();
float regler(float ist, float soll, int p_faktor);
void IRbegin();
private:
Servo *libServo;
int in1 = 0;
Expand Down
66 changes: 29 additions & 37 deletions src/Infrared.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#include "Infrared.h"
#include <IRremote.hpp>

//unsigned long elegoo::getIR(){
// if (irrecv->decode()) {
// irrecv->resume();
//unsigned long var = IrReceiver.decodedIRData.decodedRawData;
//return var;
// }
//}

//char elegoo::getIRdec(){
// switch(getIR()){
// case FORWARD: return 1; break;
// case BACK: return 2; break;
// case LEFT: return 3; break;
// case RIGHT: return 4; break;
// case STOP: return 5; break;
// case KEY1: return 6; break;
// case KEY2: return 7; break;
// default: break;
// }
//}
unsigned long elegoo::getIR(){
if (IrReceiver.decode()) {
unsigned long int val = IrReceiver.decodedIRData.decodedRawData;
IrReceiver.resume();
return val;
}
else {
return 0;
}
}

void elegoo::IRbegin(){
IrReceiver.begin(RECV_PIN, LED);
}

char elegoo::getIRdec(){
switch(getIR()){
case FORWARD: return 1; break;
case BACK: return 2; break;
case LEFT: return 3; break;
case RIGHT: return 4; break;
case STOP: return 5; break;
case KEY1: return 6; break;
case KEY2: return 7; break;
default: break;
}
}

/*
void elegoo::remoteIR(){
int preMillis;
switch(getIRdec()){
Expand Down Expand Up @@ -59,20 +67,4 @@ void elegoo::remoteIRT(int time){
remote();
delay(1);
}
}
int elegoo::getLightR(){
int r = !digitalRead(10);
return r;
}
int elegoo::getLightM(){
int m = !digitalRead(4);
return m;
}
int elegoo::getLightL(){
int l = !digitalRead(2);
return l;
}
*/
}

0 comments on commit 8e54d77

Please sign in to comment.