DigitalWrite to one object

hi is there any way how to put this code : DigitalWrite(pin1, B1); DigitalWrite(pin2, B0); DigitalWrite(pin3, B1); DigitalWrite(pin4, B0); DigitalWrite(pin5, B1); DigitalWrite(pin6, B0);

under one object (letter,number, something) ?

What do letter, number and something relate to in the code above ?

i want to work with it like with numbers +- etc

You could put the code in a function like this

void myDigitalWriteFunction() {
   DigitalWrite(pin1, B1);
   DigitalWrite(pin2, B0);
   DigitalWrite(pin3, B1);
   DigitalWrite(pin4, B0);
   DigitalWrite(pin5, B1);
   DigitalWrite(pin6, B0);
}

and call it with myDigitalWriteFunction()

And, obviously, give it a more sensible name

See Planning and Implementing a Program

...R

I'm not sure if this helps or hinders, but... B0 is equivalent to 0 and B1 is equivalent to 1. You asked for numbers, so are those closer to numbers? :)

Normally you would use LOW for B0 and HIGH for B1. Someone got "creative". Here is an example of symbolism that got out of control. They (B0 and B1) read like variables, but they are actually predefined constants.

void myDigitalWriteFunction() {
   digitalWrite(pin1, HIGH);
   digitalWrite(pin2, LOW);
   digitalWrite(pin3, HIGH);
   digitalWrite(pin4, LOW);
   digitalWrite(pin5, HIGH);
   digitalWrite(pin6, LOW);
}

Also, DigitalWrite() doesn't exist, it's not capitalized. Did you not try to compile this?

gama9: i want to work with it like with numbers +- etc

Sorry, but I am still not getting it. Please can you provide an example of how you would like it to work ?

Which parts of DigitalWrite(pin1, B1);, for instance, do you want to replace and what with ?

gama9: i want to work with it like with numbers +- etc

I second the sentiment, I'm not sure what you're trying to accomplish. I'm sure it can be done, if we understand what you want to do.

Can you rephrase it? Assume we have no idea what you're talking about (because we don't!) and try to explain what you want to do.

As aarg is explaining, all of the symbols are really numbers beneath the surface. Perhaps you want to store the pin numbers or output states as variables? Or you want to hard code the numbers?

Try to explain WHAT you want to do, without worrying about HOW to do it. Once we are all on the same page and understand what it is you want to do, we can figure out how to do it. What is your final goal here?

Hi,

I think you had better explain what you are trying to do, the whole explanation of you application.

Can you please post a copy of your COMPLETE sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Thanks… Tom… :slight_smile:

It's digitalWrite, guys. Not DigitalWrite.

gama9: under one object (letter,number, something) ?

What's an object, in this context? A function?