Here is modified version of Blink example
#define D8 13
String p = "D8";
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(D8, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
byte pin[2];
p.getBytes(pin, sizeof(pin));
digitalWrite(D8, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(D8, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
D8 defined above is a byte of length 2. So LED turns on/off if I mention D8 on digitalWrite(D8, HIGH). Similarly I am getting the same byte D8 from String p = "D8"
, and converting it into byte of length 2, but assigning pin
to digitalWrite(pin, HIGH/LOW) doesn't works. Has anyone tried something similar before ? any help would be appreciated :)
digitalWrite(pin, value)
is expecting anunsigned 8 bit integer
for thepin
parameter ......... it is actually unclear what you are trying to do ....... also, ` doesn't works` does not describe what actually happens .... if you got an error, then why did you not say anything about it?