Go Down

Topic: multiple commands in an integer (Read 960 times) previous topic - next topic

mbrown9412

I am attempting to create a simple program with integers a-h, each of which simply set a pin to HIGH, then to LOW after 500 ms.

how do I do this? is it even possible?

when I tried it this is what i did:
Code: [Select]
int a;

etc...
void loop(){
a = digitalWrite (0, HIGH);
      delay (500);
      digitalWrite (0, LOW);



it then told me "void value not ignored s it ought to be" what does that mean?

Am I just completely wrong?

Coding Badly

Quote
integers a-h

I could be mistaken but I believe those are letters of the alphabet.

I suspect you'll get more help if you provide more details.

retrolefty

Yes, [glow]a = digitalWrite (0, HIGH);[/glow] is a bogus statement. You can't assign a digitalWrite command to an int.

If you post your complete sketch we can at least see what you are trying to do.

PaulS

Quote
You can't assign a digitalWrite command to an int.

To be pedantic, you can't assign the return value from the digitalWrite function to an int, because the digitalWrite function does not return a value.

That's what the compiler was trying to tell you.

AWOL

#4
Jan 01, 2011, 02:48 pm Last Edit: Jan 01, 2011, 02:48 pm by AWOL Reason: 1
Did you perhaps mean
Code: [Select]
digitalWrite (0, a);?
(though writing anything to part of the serial interface is inadvisable)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

robtillaart

#5
Jan 01, 2011, 07:24 pm Last Edit: Jan 01, 2011, 07:25 pm by robtillaart Reason: 1
Quote
I am attempting to create a simple program with integers a-h, each of which simply set a pin to HIGH, then to LOW after 500 ms.


For this you can use functions not integers, in the code below I have defined the function Pulse() that gets a pinnumber as parameter, so it can be used for different pins.
(code not tested)
Code: [Select]

void loop()
{
 Pulse(0);
 Pulse(1);
 for (int i=0; i< 5; i++) Pulse (i);
 for (int i=5; i> 0; i--) Pulse (i);
 // etc;
}

void Pulse(byte pinNr)
{
 digitalWrite (pinNr, HIGH);
 delay (500);
 digitalWrite (pinNr, LOW);
}


PLease take some time to check the examples on - http://arduino.cc/en/Tutorial/HomePage
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up