Go Down

### Topic: Reading button instantly (Read 3071 times)previous topic - next topic

#### joey2point0

#15
##### Apr 25, 2012, 04:13 pm

Code: [Select]
`return(RightStrip.Color(r,g,b));  return(LeftStrip.Color(r,g,b));`
Hmm

#### AWOL

#16
##### Apr 25, 2012, 04:14 pm
Quote

That's exactly what I thought too.
"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.

#### joey2point0

#17
##### Apr 25, 2012, 04:36 pm

I am not very familiar with that.

Familiar with what? EEPROM? It's not complicated at all and there are examples you can look at that will explain it.

See i am a total noob, i understand the concept of what you are trying to say, i just am terrible at programming. i tried looking at the examples but i still do not understand.

#### PaulS

#18
##### Apr 25, 2012, 04:43 pm
Look at your Wheel() function. What happens when the first return statement is executed? How many values can you return from a function (using the return statement)?

#### joey2point0

#19
##### Apr 25, 2012, 04:51 pm

Look at your Wheel() function. What happens when the first return statement is executed? How many values can you return from a function (using the return statement)?

im sorry, i have no idea what you are talking about

#### AWOL

#20
##### Apr 25, 2012, 04:58 pm
Quote

You have a function in the code you posted called "Wheel". Look at it.

Quote
What happens when the first return statement is executed?

At the end of the function you are looking at are two statements containing the word "return".
What happens when your sketch executes the first of those "return"s?

Why doesn't it matter if there is or isn't a second "return"?
"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.

#### joey2point0

#21
##### Apr 25, 2012, 05:03 pm
I have two different LED strips hooked up to the arduino, the left one and right one. does that awnser it?

#### Arrch

#22
##### Apr 25, 2012, 05:15 pm

See i am a total noob, i understand the concept of what you are trying to say, i just am terrible at programming. i tried looking at the examples but i still do not understand.

If the examples that they provide are too difficult to understand to you, then there is nothing I could do to help short of writing the code for you.

#### PaulS

#23
##### Apr 25, 2012, 05:20 pm
Quote
I have two different LED strips hooked up to the arduino, the left one and right one. does that awnser it?

No. The return keyword says "stop executing code at this point, and return this value to the caller". The function can have multiple return statements, but that only makes sense if one of them is in a conditional block, like so:
Code: [Select]
`int dumb(int a, int b){   if(a < b)      return -1;   else      return +1;}`

Code like:
Code: [Select]
`int dumb(int a, int b){   // Do some stuff   return -1;   return +1;}`
doesn't make sense, but, that is what you have. The function is supposed to return a value, or it is declared wrong. Two unconditional returns don't make sense.

#### joey2point0

#24
##### Apr 25, 2012, 05:33 pm
I took one of the Return() functions out and it seems to work the same.

#### PaulS

#25
##### Apr 25, 2012, 05:36 pm
Quote
I took one of the Return() functions out and it seems to work the same.

Does that surprise you? The other one was never being executed, anyway. Removing it should have had no impact.

#### joey2point0

#26
##### Apr 25, 2012, 05:40 pm
lol, it makes sense now, but back to my real problem. is there an easy way for the push-button to be read consistently, even while the other cycles are running. and be able to stop them mid cycle and switch

#### PaulS

#27
##### Apr 25, 2012, 05:45 pm
Quote
is there an easy way for the push-button to be read consistently, even while the other cycles are running. and be able to stop them mid cycle and switch

Sure. Rewrite the code, first, so it does not use delay(). Then, it will be trivial to read the switch and react nearly instantaneously.

If you are having difficulty getting rid of the delay calls, think about how YOU would diddle with the LEDs, given some switches, a watch, and a pad of paper. The switches are the digital pins, the watch is the millis() function, and the pad of paper are the Arduino variables.

Go Up

Please enter a valid email to subscribe