hello
i need to read all Read all Digital input in arduino once time; example:
Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13));
to recive state of all digital pin in one times from my app build with delphi
hello
i need to read all Read all Digital input in arduino once time; example:
Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13));
to recive state of all digital pin in one times from my app build with delphi
then you need to go through the tutorial section, there are examples that do just that.
Serial.write(digitalRead(0),digitalRead(1),...,digitalRead(13));
Looks like a candidate for a for loop to me.
Mind you, involving pins 0 and 1 and using serial at the same time could cause problems however you do it.
robtillaart:
then you need to go through the tutorial section, there are examples that do just that.
plz can you help me what's the exact tutorial.
You need to learn about using FOR loops which are a very fundamental part of programming. Google should be able to find lots of examples.
The demo planning and implementing a program may be helpful.
Also look at the many examples that come with the Arduino IDE.
...R
this is my arduino program
void setup() {
Serial.begin(9600);
pinMode(0,INPUT);
pinMode(1,INPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(13,INPUT);
}
void loop() {
Serial.println(PINB,BIN);
delay(200);
}
this is the result
111111
111111
111111
111111
111111
111111
111111
111101
111111
100101
111111
100100
100101
100100
100100
100100
100100
100100
100100
100100
100100
why ?
i want to recieve the three registry BIND and BINC and BINB with binnary format ?
kadrisoft2006:
i want to recieve the three registry BIND and BINC and BINB with binnary format ?
I don't know what you mean.
Your code is printing the values from Port B which, on an Uno, is pins C,C, 13, 12, 11, 10, 9, 8. The C pins are the crystal oscillator. What have you connected to the pins?
Serial.println(PINB,BIN); does not print leading zeros
...R
ihave arduino uno and i want to read the state (0 or 1) of all digital Pin (0 to 13) with my app with delphi ;
any one can help me ?
Do you want your PC application to request the data or for the Uno to send it repeatedly or at intvervals ?
UKHeliBob:
Do you want your PC application to request the data or for the Uno to send it repeatedly or at intvervals ?
uno send it repeatedly.
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.print("<");
for (int p = 0; p < 14; p++)
{
Serial.print(digitalRead(p));
}
Serial.println(">");
}
The angle brackets are there to enable the PC application to know where the data stream starts and ends but you can leave them out if you don't need them.
very thanks ,
iam test the code but iam not connect any things and the result is deferent
<10010000111111>
<10010000101111>
<10000000101111>
<10010000111111>
<10000000100111>
<10000000000001>
<10000000100001>
<10000000000001>
why ?????
What do you expect? If nothing is connected the pins are floating and may return any value. If you need particular behavior when nothing is connected use the internal pull-ups.
KeithRB:
What do you expect? If nothing is connected the pins are floating and may return any value. If you need particular behavior when nothing is connected use the internal pull-ups.
how to use pull-ups ?
sorry for my bad qustion iam beginner with arduino
Use INPUT_PULLUP instead of INPUT in your pinMode() commands.
KeithRB:
Use INPUT_PULLUP instead of INPUT in your pinMode() commands.
thanks bro,