How are INPUT, OUTPUT, and INPUT_PULLUP defined?
i'm trying send pinmode() parameters via serial using 6 bits pin , 2 bits mode. two-byte signal looks this:
c-ppppppmm
where c command byte, , 6 p's 6 bits representing desired pin, 2 'm' bits being mode.
here's how code looks particular command:
as can see, i'm using values 0, 1, , 2. figure sake consistency, use input, output, , input_pullup, cases, , define a_input, a_output, , a_input_pullup exact same way.
but also, i'm curious well. how input, output, , input_pullup defined? if looked @ #define input, value see?
c-ppppppmm
where c command byte, , 6 p's 6 bits representing desired pin, 2 'm' bits being mode.
here's how code looks particular command:
code: [select]
case digital_mode:
while(serial.available() < 1){}
instructionbyte = serial.read();
switch(instructionbyte & b00000011)
{
case o;
pinmode( ((instructionbyte >> 2) & b00111111) , output);
break;
case 1;
pinmode( ((instructionbyte >> 2) & b00111111) , input);
break;
case 2;
pinmode( ((instructionbyte >> 2) & b00111111) , input_pullup);
break;
}
break;
as can see, i'm using values 0, 1, , 2. figure sake consistency, use input, output, , input_pullup, cases, , define a_input, a_output, , a_input_pullup exact same way.
but also, i'm curious well. how input, output, , input_pullup defined? if looked @ #define input, value see?
use arduino tell answer.
code: [select]
void setup()
{
serial.begin(115200);
serial.print("input : ");
serial.println(input);
serial.print("output : ");
serial.println(output);
serial.print("input_pullup : ");
serial.println(input_pullup);
}
void loop()
{
}
Arduino Forum > Using Arduino > Programming Questions > How are INPUT, OUTPUT, and INPUT_PULLUP defined?
arduino
Comments
Post a Comment