Hi,
I want to read the digital pins from a given number of connections. Since the name of those numbers does not follow a consecutive order, I had to define an array. Those names start with PR and a the number. I've achieved to print on the screen the names correctly like PR5, PR6, PR7.... using the sprintof command. However, I cannot use the char buffer (where the names are located) to read the digital pin value. I got the following error:
C:\Users\ In function 'void loop()':
C:\Users\:100:36: warning: invalid conversion from 'char*' to 'uint8_t {aka unsigned char}' [-fpermissive]
read = digitalRead(buffer);
^
In file included from sketch\Master_Tester_TX.ino.cpp:1:0:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:135:5: note: initializing argument 1 of 'int digitalRead(uint8_t)'
int digitalRead(uint8_t);
^
Find the code below. Note that those digitalRead functions inside a For loop are placed inside a Switch case.
int read;
x_arr = new int[15] {5, 6, 7, 9, 10, 11, 15, 16, 17, 21, 22, 23, 25, 26, 27};
x = 15;
if (digitalRead(buttonStart) == HIGH)
{
char buffer[32];
for (int i = 0; i < 15; i++) {
int s = x_arr[i];
sprintf(buffer, "PR%d", s);
read = digitalRead(buffer);
delay(delay_);
}
}
I've also tried to convert the buffer (char) into uint8, but it does not work.
How can I solve this?
Thanks