Browse Source

Temperature is now shown on the lcd! Amazing! Wow, very cool.

master
nickg 5 years ago
parent
commit
ebed7f2188
  1. 17
      Code/miniRobot/miniRobot.ino
  2. 6
      Code/miniRobotRC/JoystickSteuerung.ino
  3. 4
      Code/miniRobotRC/_main.ino
  4. 25
      Code/miniRobotRC/fahrsteuerung_old.ino
  5. 2
      Code/miniRobotRC/funkInit.ino
  6. 3
      Code/miniRobotRC/miniRobotRC.ino

17
Code/miniRobot/miniRobot.ino

@ -23,6 +23,7 @@ void inline clearCommands() {
}
const byte address[6] = "00001";
const byte address2[6] = "00002";
//Kommandos
#define nothing 9 //reset/nichts tun
#define speedA 1 // set speed A + speed
@ -60,7 +61,7 @@ bool forwardA = true;
bool forwardB = true;
volatile bool driveOn = false;
int temperatur = 0;
int16_t temperatur = 0;
volatile long driveTimeout = 0;
@ -71,6 +72,7 @@ void setup() {
// motorA.setPWM16(2,RESOLUTION);
// motorB.setPWM16(2,RESOLUTION);
radio.begin();
radio.openWritingPipe(address2);
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_MAX);
radio.startListening();
@ -83,6 +85,7 @@ void setup() {
}
void loop() {
Serial.println(temperature);
if (radio.available()) {
radio.read(&commands, sizeof(commands));
commandInterpretation();
@ -92,16 +95,18 @@ void loop() {
pwmA = 0;
pwmB = 0;
}
drive.setPWM_A(pwmA);
drive.setPWM_B(pwmB);
//Temperatur- und Abstandsmessung
temperature = dallas(4, 0);
if(millis() - timer >= 100){
measureDistance();
timer = millis();
measureDistance();
timer = millis();
}
distance = calculateDistance();
@ -150,8 +155,10 @@ void commandInterpretation() {
break;
}
case getTemp : {
radio.write(&temperature, sizeof(temperature));
Serial.println("Senden!");
radio.stopListening();
radio.write(&temperature, sizeof(int16_t));
radio.startListening();
break;
}
case timeToDrive : {

6
Code/miniRobotRC/JoystickSteuerung.ino

@ -64,11 +64,5 @@ void joystickInit() {
commands[7] = highByte(driveTimeout);
commands[8] = lowByte(driveTimeout);
commands[9] = goDrive;
commands[10] = getTemp;
commands[11] = highByte(temperature);
commands[12] = lowByte(temperature);
commands[13] = getTemp;
commands[14] = highByte(distance);
commands[15] = lowByte(distance);
radio.write(&commands, sizeof(commands));
}

4
Code/miniRobotRC/_main.ino

@ -20,11 +20,12 @@ void setup() {
void loop() {
//lcdMenu();
while(!tasten.getButtonCycle(buttonStart)) {
manualDigitalDrive();
}
tasten.clearButton(buttonStart);
while(!tasten.getButtonCycle(buttonStart)){
while(!tasten.getButtonCycle(buttonStart)){
motorMapping();
}
tasten.clearButton(buttonStart);
@ -32,6 +33,7 @@ void loop() {
joystickSteuerung(); //TODO ()
}
tasten.clearButton(buttonStart);
}
void lcdMenu() {

25
Code/miniRobotRC/fahrsteuerung_old.ino

@ -1,4 +1,5 @@
void manualDigitalDrive() {
bool goOn = false;
String temp_str = "T: " + String(temperature) + " Grad C";
lcdLines[5] = temp_str;
@ -48,6 +49,30 @@ void manualDigitalDrive() {
radio.write(&commands, sizeof(commands));
goOn = false;
}
//Temperatur <3
if((millis() - temp_time) >= 5000){ // jede Sekunden
temp_time = millis();
bool err = false;
clearCommands();
commands[0] = getTemp;
radio.write(&commands, sizeof(commands) && !err);
long start = micros();
radio.startListening();
while(!radio.available()){
//Serial.println("nix");
if((micros()- start) >= 1){
err = true;
}
}
if(!err){
radio.read(&temperature, sizeof(int16_t));
}
radio.stopListening();
}
// }
// tasten.clearAllButtons();
}

2
Code/miniRobotRC/funkInit.ino

@ -1,6 +1,8 @@
void funkInit() {
radio.begin();
radio.openWritingPipe(address);
radio.openReadingPipe(0, address2);
radio.setPALevel(RF24_PA_MAX);
radio.stopListening();
}

3
Code/miniRobotRC/miniRobotRC.ino

@ -42,6 +42,8 @@ uint16_t driveTimeout = 0;
int16_t distance;
int16_t temperature = 0;
int16_t temp_time = millis();
//Funk
#include <SPI.h>
#include <nRF24L01.h>
@ -50,5 +52,6 @@ int16_t temperature = 0;
RF24 radio(A2, A3); // CE, CSN
const byte address[6] = "00001";
const byte address2[6] = "00002";
uint8_t commands[32];
Loading…
Cancel
Save