system
January 1, 2011, 5:58am
1
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:
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?
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.
Yes, a = digitalWrite (0, HIGH); 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.
system
January 1, 2011, 12:36pm
4
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.
system
January 1, 2011, 1:48pm
5
Did you perhaps mean
digitalWrite (0, a);
?
(though writing anything to part of the serial interface is inadvisable)
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)
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