cannot convert 'String' to 'volatile uint8_t {aka volatile unsigned char}' in initialization (too long for subject)
First off: i just started.
code snippet:
String test = "0x";
test += i;
volatile uint8_t first = test;
PORTB = first;
I dont know if this is even going to work.
Bud yeah, i want to convert the string to a volatile unsigned char bud cannot do it.
Someone can explain why this doesn't work? Or why this is bad?
Thanks in advance
trying to convert the string to a volatile unsigned character (i believe its different than an integer) so PORTB can read it. (Edit: not constant char)
Port manipulations require hex or binary integers, not strings. Typecasting from a String to an int doesn't work anyway, at least, not how you're trying to do it...
@rickert1337:
Perhaps you should take a step back and more thoroughly explain what you're trying to accomplish because just about everything you've written in your posts is incorrect.
void loop() {
int i = 1;
for (int z = 0; i <= 20; z++) {
String test = "0x";
test += i;
volatile uint8_t first = test;
PORTB = first;
delay(1000); // wait for a second
PORTB=0x0;
delay(1000); // wait for a second
if (z == 4){
z=0;
i = i+i/4;
}else{
i = i*2;
}
delay(1000); // wait for a second
PORTB=0x0;
}
}
im trying to manipulate the portb with a hexadecimal. bud i dont know if it is even possible to convert it to a character that portb takes.
void loop()
{
byte i = 1;
for (int z = 0; i <= 20; z++)
{
PORTB = i;
delay(1000); // wait for a second
PORTB = 0x0;
delay(1000); // wait for a second
if (z == 4)
{
z = 0;
i = i + i / 4;
}
else
{
i = i * 2;
}
delay(1000); // wait another second, so one second on, two seconds off
PORTB = 0x0; // Not needed since PORTB is already 0.
}
}