Pages: [1]   Go Down
Author Topic: multiple commands in an integer  (Read 923 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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?
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17308
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50950
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26638
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you perhaps mean
Code:
digitalWrite (0, a);
?
(though writing anything to part of the serial interface is inadvisable)
« Last Edit: January 01, 2011, 08:48:56 am by AWOL » Logged

"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.

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 228
Posts: 14055
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
« Last Edit: January 01, 2011, 01:25:22 pm by robtillaart » Logged

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: