Help! Error message; invalid conversion from int to uint8_t

Hello,
I am currently having an issue with my code i wrote for a Mega2560.
On my mac mini (2014) my code works perfectly fine but on my older macbook pro(2010) i get this error message; invalid conversion from (int*) to (uint8_t) [-fpermissive] (aka unsigned char)

*On the older mac I also had to go from avr board 1.6.13 to 1.6.11 for it to be able to compile for mega2560.

This is my code, thanks in advance!

#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

#define MIDI_CHANNEL 1
#define NOTE_ON_THRESHOLD 150
#define MAX_PRESSURE 500
#define NOTE_OFF 1
#define RISE_WAIT 2
#define NOTE_ON 3
#define AT_INTERVAL 70
#define RISE_TIME 3

int noteSounding;
int sensorValue;
int state;
unsigned long breath_on_time = 0L;
int initial_breath_value;
int atVal;
unsigned long atSendTime = 0L;

int swiPin [] = {22,23,24,25,26,27,28,29};
int swiPin2 [] = {30,31,32,33,34,35,36,37};
int swiPin3 [] = {38,39,40,41,42};

int groupA = 0;
int groupB = 0;
int groupC = 0;

void setup() {
  for(int x = 0; x<7; x++)
  state = NOTE_OFF; 
  for(int x = 0; x<7; x++){ 
pinMode(swiPin, INPUT_PULLUP);
  pinMode(swiPin2, INPUT_PULLUP);
  }
  for(int x = 0; x<4; x++){
  pinMode(swiPin3, INPUT_PULLUP);
}
MIDI.begin(4);
  Serial.begin(115200);
}

int get_note() {
  groupA = 1*(digitalRead(swiPin[0])) + 2*(digitalRead(swiPin[1])) + 4*(digitalRead(swiPin[2])) + 8*(digitalRead(swiPin[3])) + 16*(digitalRead(swiPin[4])) + 32*(digitalRead(swiPin[5])) + 64*(digitalRead(swiPin[6])) + 128*(digitalRead(swiPin[7])); //22-29
  groupB = 1*(digitalRead(swiPin2[0])) + 2*(digitalRead(swiPin2[1])) + 4*(digitalRead(swiPin2[2])) + 8*(digitalRead(swiPin2[3])) + 16*(digitalRead(swiPin2[4])) + 32*(digitalRead(swiPin2[5])) + 64*(digitalRead(swiPin2[6])) + 128*(digitalRead(swiPin2[7])); //30-37
  groupC = 1*(digitalRead(swiPin3[0])) + 2*(digitalRead(swiPin3[1])) + 4*(digitalRead(swiPin3[2])) + 8*(digitalRead(swiPin3[3])) + 16*(digitalRead(swiPin3[4]));//38-42

 #define BASE 64
if (groupA == 0b00000000 && groupB == 0b00000000 && groupC == 0b00000)
return BASE; //C#    

else if (groupA == 0b10000000 && groupB == 0b00000001 && groupC == 0b00000)
return BASE -1; //C

//Deleted the rest of the binary to save space

return noteSounding;}

int get_velocity(int initial, int final, unsigned long time_delta) {
  return map(final, NOTE_ON_THRESHOLD, MAX_PRESSURE, 0, 127);}

void loop() {
  sensorValue = analogRead(A0);
  if (state == NOTE_OFF) {
    if (sensorValue > NOTE_ON_THRESHOLD) {
      breath_on_time = millis();
      initial_breath_value = sensorValue;
      state = RISE_WAIT; 
    }
  } else if (state == RISE_WAIT) {
    if (sensorValue > NOTE_ON_THRESHOLD) {
      if (millis() - breath_on_time > RISE_TIME) {
        noteSounding = get_note();
        int velocity = get_velocity(initial_breath_value, sensorValue, RISE_TIME);
        MIDI.sendNoteOn(noteSounding, velocity, MIDI_CHANNEL);
        state = NOTE_ON;}
    } else {
      state = NOTE_OFF;}
  } else if (state == NOTE_ON) {
    if (sensorValue < NOTE_ON_THRESHOLD) {
      MIDI.sendNoteOff(noteSounding, 100, MIDI_CHANNEL);  
      state = NOTE_OFF;
    } else {
      if (millis() - atSendTime > AT_INTERVAL) {
        atVal = map(sensorValue, NOTE_ON_THRESHOLD, 1023, 0, 127);
        MIDI.sendAfterTouch(atVal, MIDI_CHANNEL);
        atSendTime = millis();}
    }
    int newNote = get_note();
    if (newNote != noteSounding) {
      MIDI.sendNoteOff(noteSounding, 100, MIDI_CHANNEL);
      noteSounding = newNote;
      int velocity = get_velocity(initial_breath_value, sensorValue, RISE_TIME);
      MIDI.sendNoteOn(noteSounding, velocity, MIDI_CHANNEL);}}}

What line is the error.

This is the full error message that shows up.

The part it highlights as an error it is in this part in the void setup
for(int x = 0; x<4; x++){
pinMode(swiPin3, INPUT_PULLUP);
}

Arduino: 1.8.0 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

/Users/Leo/Desktop/coding/Leo26/Leo26.ino: In function 'void setup()':
Leo26:34: error: invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]
 pinMode(swiPin, INPUT_PULLUP);
                             ^
In file included from sketch/Leo26.ino.cpp:1:0:
/Users/Leo/Library/Arduino15/packages/arduino/hardware/avr/1.6.11/cores/arduino/Arduino.h:125:6: error:   initializing argument 1 of 'void pinMode(uint8_t, uint8_t)' [-fpermissive]
 void pinMode(uint8_t, uint8_t);
      ^
Leo26:35: error: invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]
   pinMode(swiPin2, INPUT_PULLUP);
                                ^
In file included from sketch/Leo26.ino.cpp:1:0:
/Users/Leo/Library/Arduino15/packages/arduino/hardware/avr/1.6.11/cores/arduino/Arduino.h:125:6: error:   initializing argument 1 of 'void pinMode(uint8_t, uint8_t)' [-fpermissive]
 void pinMode(uint8_t, uint8_t);
      ^
Leo26:38: error: invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]
   pinMode(swiPin3, INPUT_PULLUP);
                                ^
In file included from sketch/Leo26.ino.cpp:1:0:
/Users/Leo/Library/Arduino15/packages/arduino/hardware/avr/1.6.11/cores/arduino/Arduino.h:125:6: error:   initializing argument 1 of 'void pinMode(uint8_t, uint8_t)' [-fpermissive]
 void pinMode(uint8_t, uint8_t);
      ^
exit status 1
invalid conversion from 'int*' to 'uint8_t {aka unsigned char}' [-fpermissive]

why don’t you move to the latest tools on both macs?

On the older mac it somehow doesn't recognize the megaboard and I made me move down to avr 1.6.11 for it to be able to compile.

this code is absurd… pinMode does not take a pointer to an array as first parameter but a pin number

for(int x = 0; x<7; x++){ 
  pinMode(swiPin, INPUT_PULLUP);
  pinMode(swiPin2, INPUT_PULLUP);
}

1/ why would you repeat 7 time the pinModes anyway??
2/ this is an array so you need to access the array elements with an index…

for(int x = 0; x<7; x++){ 
  pinMode(swiPin[x], INPUT_PULLUP);
  pinMode(swiPin2[x], INPUT_PULLUP);
}

but you should double check how many items are in the array… I think you are missing one.

(also press cmd-T in the IDE before copying to indent your code properly)

The code works perfectly on my mac mini but have to use it on my macbook pro. I used swipin[x] in an older code without a sensor on A0 and it works however with my sensor on A0 pin it only seems to work without swipin[x] after.

Leomitrandir:
The code works perfectly on my mac mini but have to use it on my macbook pro. I used swipin[x] in an older code without a sensor on A0 and it works however with my sensor on A0 pin it only seems to work without swipin[x] after.

I don't understand what you mean but doing the below is nonsense.

int swiPin [] = {22,23,24,25,26,27,28,29};
...
pinMode(swiPin, INPUT_PULLUP);

you are passing the address of the array swiPin to the function pinMode to set it as INPUT_PULL... this address does not represent a pin number, it's a pointer in memory... just don't do that at all. it does not set up your pins as INPUT_PULLUP. it's bad.

First of thanks for helping me with this!
I tried what you said and it works, the only problem i now have is that my sensor on the A0 pin is working but my port changes are not being detected anymore.
*Im using the sensor threshold as a way to start musical notes and the ports for fingering to different notes from the base note. Is it possible that the A0 pin overrides the messages coming from the ports?
Thanks again for your time

but my port changes are not being detected anymore

what do you mean by "port changes" ? I don't see any PORT manipulation in your code

have you upgraded to recent MIDI library?

Urg sorry about that still very new to all of this.
I meant this by ports

 #define BASE 64
if (groupA == 0b00000000 && groupB == 0b00000000 && groupC == 0b00000)
return BASE; //C#    

else if (groupA == 0b10000000 && groupB == 0b00000001 && groupC == 0b00000)
return BASE -1; //C

It now doesnt detect the changes i make for theae groupings

may be that's because the PULLUP work now? so how is this wired on all your pins from

int swiPin [] = {22,23,24,25,26,27,28,29};
int swiPin2 [] = {30,31,32,33,34,35,36,37};

are they connected to ground through "buttons" ?

Yes theres buttons connected to ground and to 5v.
The buttons in my case should be used to control midi notes and because my instrument has so many buttons i had to make three groups and used a decimal system to be able to make different button combinations. And then i decided to use binary for to write all the combinations down. I defenitly would not be suprised if theres a lot of unnecessary steps in my code but dont really know how to clean it up.

Hi J_M_L,
Followed your advice and also removed the Pullup statement, ended up changing my serial to 9600 and it works on both machines!
Thanks so much for your help and happy new years!!

happy new year too :slight_smile:

but wait - if you don't have pull-ups, how are things wired between those pins and whatever is on the other side?