Could not convert from void to bool

I am getting this mistake: could not convert 'ServoRechts()' from 'void' to 'bool'

Can someone Help me?

This is my programm:

#include <HCSR04.h>


#include<Servo.h> //Bibliothek Sensor

Servo S1;

int a;

 

float distanceH;

 

const byte triggerPin = 13; //Trigger Pin - Sensor Front

const byte echoPin = 12; //Echo Pin - Sensor Front

UltraSonicDistanceSensor distanceSensor(triggerPin, echoPin); // Sensor vorne

 

const byte triggerPin2 = 44; //Trigger Pin - Sensor hinten

const byte echoPin2 = 42; //Echo Pin - Sensor hinten

UltraSonicDistanceSensor distanceSensor2(triggerPin2, echoPin2); // Sensor hinten

 

 

 

void setup() {

/*pinMode (11, INPUT_PULLOUT); // Taster Servo rechtskurve

pinMode (10, INPUT_PULLOUT); // Taster Servo linkskurve

pinMode (6, INPUT_PULLOUT); // Taster Servo gradeaus*/

pinMode(3, OUTPUT); //motor

pinMode(4, OUTPUT); //motor

pinMode(31, OUTPUT);//Lautsprecher 

pinMode(30, OUTPUT); //LED links

pinMode(32, OUTPUT); //LED rechts 

pinMode(9, OUTPUT); //Servo lenkung

S1.attach(9); //Servo

Serial.begin (9600);}

 

 

 

void loop() {

 

 

}

 

 

 

void ServoRechts(){

S1.write(15);}

 

void ServoLinks(){

S1.write(155);}

 

void Servogerade(){

S1.write(88);}

 

 

 

 

void Abstandsttone(){


}

 



/*void Bremslicht(){

  if()}*/

 

 

void SensorVorne(){ //Ultraschallsensor 1 vorne

float distance = distanceSensor.measureDistanceCm();

    Serial.println(distance);

    delay(500);}

 

void SensorHinten(){//Ultraschallsensor 2 hinten

float distanceH = distanceSensor2.measureDistanceCm();

    Serial.println(distanceH);

    delay(500);}


 




void vorfahren(){

digitalWrite (3,HIGH); //motor

digitalWrite (4,LOW);

delay (100);

digitalWrite (3,LOW);

digitalWrite (4,HIGH);

delay(5000);

digitalWrite (3,HIGH);

digitalWrite (4,HIGH);

delay(5000);}          //motor

 

void rueckfahren(){

digitalWrite (3,LOW); //motor

digitalWrite (4,HIGH);

delay(100);

digitalWrite (3,HIGH);

digitalWrite (4,LOW);

delay(5000);

digitalWrite (3,HIGH);

digitalWrite (4,HIGH);

delay(5000);}          //motor

 

 

 

 

void blinkenR(){

if(ServoRechts()){

  digitalWrite(32,HIGH);

  delay(100);

  digitalWrite(32,LOW);

  delay(100);

  digitalWrite(32,HIGH);

  delay(100);

  digitalWrite(32,LOW);}}


void blinkenL(){

  if(ServoLinks()){

  digitalWrite(30,HIGH);

  delay(100);

  digitalWrite(30,LOW);

  delay(100);

  digitalWrite(30,HIGH);

  delay(100);

  digitalWrite(30,LOW);}}


 

 



void StopV(){

Serial.println(distance);

if(distance<6){

  digitalWrite (3,LOW); //motor wird ausgemacht 

  digitalWrite (4,LOW);}}

 

void StopH(){

Serial.println(distance);

if(distance<6){

  digitalWrite (3,LOW); //motor wird ausgemacht 

  digitalWrite (4,LOW);}}

You can't test the return value a void function doesn't return.

(It would have been polite for you to post the actual error message, and its location)

it does nothing what can be used to determine what to return so it just returns true

bool ServoRechts() {
  S1.write(15);
  return true;
}

It writes to a servo.
That's not nothing.
It returns nothing

If you know it's going to return true, what's the point in testing?

it does nothing what can be used to determine what to return

your loop is empty, so not sure anything will happen...

what do you really want to test with

  if (ServoRechts()) {

or

  if (ServoLinks()) {

the function call (ServoRechts or ServoLinks) just asks the servo to go to a given position. What do you want to test?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.