user3800750
user3800750

Reputation: 5

error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]

I've been working on a project with my arduino that display a knock knock joke on an LCD but I ran in to a problem while coding.

This is what I have so far

#include<LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);
int buttonPin = 13;
int menu = 0;
int joke(int line1, int line2){
  lcd.setCursor(0, 0); 
  lcd.print(line1);
  lcd.setCursor(0, 1);
  lcd.print(line2);
  lcd.setCursor(0, 0);
}

void setup(){
  pinMode(buttonPin, INPUT);
  lcd.begin(16,2);
}

void loop() {
  lcd.setCursor(15, 0);
  lcd.print(menu);
  int buttonValue = digitalRead(buttonPin);
  if(buttonValue = HIGH){
    menu = menu + 1;
  }
  if(menu == 0){
    joke("Knock!", "Knock!");
  } 

But when I run it I get the errors

LCD_HelloWorld.ino: In function ‘void loop()’:
LCD_HelloWorld.ino:28:28: error: invalid conversion from ‘const char*’ to 'int’          [-fpermissive]
LCD_HelloWorld.ino:7:5: error:   initializing argument 1 of ‘int joke(int, int)’ [-fpermissive]
LCD_HelloWorld.ino:28:28: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]
LCD_HelloWorld.ino:7:5: error:   initializing argument 2 of ‘int joke(int, int)’    [-fpermissive]

After scouring the internet I've found nothing, so does any body have a solution? BTW: I'm new to arduino and C/C++

Upvotes: 0

Views: 27286

Answers (1)

Begelfor
Begelfor

Reputation: 358

change

int joke(int line1, int line2)

to

int joke(const char * line1, const char * line2)

Upvotes: 2

Related Questions