user2137452
user2137452

Reputation: 145

invalid conversion from ‘char*’ to ‘uint8_t’ Arduino

I'm trying to set the pin mode for all Analogue input pins at once on my Mega. So I made an array before set-up:

char* Analog_Input_List[16] = {"A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13","A14","A15"};

Then I tried to run this:

 //analogue input pin set-up
 for (int i =0;i<8;i++){
 pinMode(Analog_Input_List[i], OUTPUT);   
 }

But I'm getting this error:

sketch_jul24a.cpp: In function ‘void setup()’:
sketch_jul24a.cpp:54:40: error: invalid conversion from ‘char*’ to ‘uint8_t’
sketch_jul24a.cpp:54:40: error:   initializing argument 1 of ‘void pinMode(uint8_t, uint8_t)’

I'm new to arduino programming and the declaring and manipulation of types keeps confusing me I'm aware its something simple but not sure how to go about fixing it.

Thanks

Upvotes: 0

Views: 3347

Answers (1)

user529758
user529758

Reputation:

The pins you are trying to initialize are described by preprocessor macros expanding to integer constants. They are not strings. What you want instead is

int inputPins[] = { A0, A1, /* etc. */ };

instead.

Upvotes: 2

Related Questions