Go Down

Topic: Digital imput via arduino to processing (Read 3 times) previous topic - next topic

AWOL

Quote
I am fed up. Please make me happy.


Two men meet in the street.
The first one says "How are you - I haven't seen you for ages"
"Oh, I'm OK, but my wife has left me. She said she was going out to buy a pint of milk and never came back", says the second.
"That's awful!", said the first, "How are you managing?"
"I'm just having to use the powdered stuff", says the second.
"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.

Msquare

Zenolin, in reply to the message you sent me
Quote
plese help me.
Here not mistake, bet do not work good.

void loop() {
 
  if (digitalRead(switchPin) == HIGH) {  // If switch is ON,
    Serial.print(1, BYTE);               // send 1 to Processing
  } else {                               // If the switch is not ON,
    Serial.print(0, BYTE);               // send 0 to Processing
  }
    delay(100);
}

if (digitalRead(ZZZZ) == HIGH) {  // If switch is ON,
    Serial.print(2, BYTE);               // send 2 to Processing
  } else {                               // If the switch is not ON,
    Serial.print(0, BYTE);               // send 0 to Processing
  }
//  delay(100);                            // Wait 100 milliseconds

Bad English is excusable, I can understand despite numerous spelling mistakes, wrong grammer and worse.

It is that you still have not said what it is that does not work. You expect me (or other Forum users), from the program and your cryptic "bet do not work good" to guess what you are expecting to happen, from what I can derive that the program actually does (and that is not always easy). In this case, is it showing the wrong colurs on your Processing or too briefly? Are your buttons something that is held down a long time or something that happens very quickly?

(1) What are you doing (2) What are wanting to happen (3) what is actually happening

I can't be bothered with so little info. Sorry.

Nick Gammon


blinkink screen with it :
void loop() {
  if ((digitalRead(switchPin) == LOW) || (digitalRead(switchPin3) == LOW)) {   // If switch is ON,
    Serial.print(0, BYTE);     
  } else if (digitalRead(switchPin) == HIGH) {
    Serial.print(1, BYTE);   
  } else if (digitalRead(switchPin3) == HIGH){   // If switch is ON,
    Serial.print(2, BYTE);
} else {   
    Serial.print(0, BYTE);
}


You want help enough to make scrolling messages in all caps, right?

Well can you answer this ...

You have two switches, switchPin and switchPin3. Now can you explain under what circumstances you conceive that his line of code will be executed?

Code: [Select]
    Serial.print(0, BYTE);

(the last one, not the first one)


Also can you explain when you think that it will execute this:

Code: [Select]
    Serial.print(2, BYTE);

Let me give you a hint. Do a truth table. There are four possible combinations:

Code: [Select]
00
01
10
11


Now look at your code and see what path will be taken for each of those.

Nick Gammon

Also, if you want help that badly, how about learning how to post your code in "code" blocks like I did above? It is part of the forum, and makes your posts more readable, and thus more likely to be answered.

AWOL

#9
May 01, 2011, 11:23 am Last Edit: May 01, 2011, 11:26 am by AWOL Reason: 1
No, he meant using the # icon on the editor's toolbar to put the code in a proper code box.

Code: [Select]
Serial.print(00, BYTE);           
Zero is zero whether you express it in octal or decimal.
"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.

Go Up