error: void value not ignored as it ought to be

I have checked other places yet could not figure out what the error was. Any help would be appreciated.

ERROR LOG:

sketch_aug23a:7: error: void value not ignored as it ought to be
sketch_aug23a:8: error: void value not ignored as it ought to be
sketch_aug23a:9: error: void value not ignored as it ought to be
sketch_aug23a:10: error: void value not ignored as it ought to be
sketch_aug23a:12: error: void value not ignored as it ought to be
sketch_aug23a:13: error: void value not ignored as it ought to be
sketch_aug23a:14: error: void value not ignored as it ought to be

CODE:

  //////////////////////////SHORCTCUTS//////////////////

  //Pin Id
int redPIN=9;
int bluePIN=8;
  //Led Commands
int redON=digitalWrite(redPIN,HIGH);
int blueON=digitalWrite(bluePIN,HIGH);
int redOFF=digitalWrite(bluePIN,LOW);
int blueOFF=digitalWrite(bluePIN,LOW);
  //Time delay commands
int sec=delay(1000);
int hsec=delay(500);
int qsec=delay(250);
  //End
  ///////////////////////Subroutine//////////////////////
  //Start of BLINK

void setup() {
    pinMode(redPIN,OUTPUT);
    pinMode(bluePIN,OUTPUT);
 }

void loop() {
  blueOFF;
  redON;
  qsec;
  redOFF;
  blueON;
  qsec;

 }
int redON=digitalWrite(redPIN,HIGH);

digitalWrite doesn’t return any value. So you can’t assign it to a variable. What were you hoping this redON variable would contain after such a line?

Same story with delay

Put these in to a function:

int redON=digitalWrite(redPIN,HIGH);
int blueON=digitalWrite(bluePIN,HIGH);
int redOFF=digitalWrite(bluePIN,LOW);
int blueOFF=digitalWrite(bluePIN,LOW);
  //Time delay commands
int sec=delay(1000);
int hsec=delay(500);
int qsec=delay(250);

Oh. Now I see your loop. You can't do it like that. You could define functions and call them. But you can't use a variable like that. You should probably take a little while and look through some example codes at how things really work instead of trying to make it up on your own.

Sorry I am new to C. Prior to this I have done some assembly. I couldn't find an example of how i could fix my error so could anyone be able to explain how this would be done.

You need to walk before you run, do some reading on Arduino programming.

Take a look at the examples that are included in the he IDE.
You should be able see what you are doing wrong when you compare your sketch with ones that work.

Review these:

https://www.arduino.cc/en/Reference/HomePage

https://www.arduino.cc/en/Reference/FunctionDeclaration

.

somename() is an immediate call to a function, and this function will return a value at that time.

e.g.

 unsigned long time1 = millis();
 delay(1000);
 unsigned long time2 = millis();

The time variables will differ by 1000.


You want to create aliases for code - these are functions.

void redON() {digitalWrite(redPIN,HIGH);}
void blueON() {digitalWrite(bluePIN,HIGH);}
void redOFF() {digitalWrite(bluePIN,LOW);}
void blueOFF() {digitalWrite(bluePIN,LOW);}

  //Time delay commands
void sec() {delay(1000);}
void hsec() {delay(500);}
void qsec() {delay(250);}
...

void loop()
{
  redON();
  sec();
  blueON();
  hsec();
  redOFF();
  ...
}

void means “no result from a function, side effects only”. E.g. you know that delay() delayed.


If you’d write “redOFF;” instead of “redOFF();”, the compiler would not execute the function, but read the place of the function, then ignore it (just like you may ignore status codes from certain functions).


PS, normaly you’d write:

functionName()
{
   // your code goes here
}

NOT:
functionName() { /* your code goes here */ }

I wrote these functions into one line because IMO it’s OK for that kind of one-liners, and having everything on one screen is a good thing, better than having a long and therefore unreadable heap of readable code. Don’t do one-liners if they are more than an alias.