Show Posts
Pages: 1 ... 7 8 [9] 10 11 ... 73
121  Using Arduino / Programming Questions / Re: Problem with serial read and swiches? on: March 20, 2014, 11:40:29 pm
If you want blocking code, that should do it.
Yep, but it's only blocking whilst someone is leaning on the button.   smiley-razz
122  Using Arduino / Project Guidance / Re: Monitoring Solution With arduino on: March 20, 2014, 11:04:56 pm
Dear all.

I am running My project on arduino UNo  Board.I am looking for Monitoring solution for my project.Initially i am Using Serial monitor for verifying data. Now this product is going to sit remote place with 2000 meter from Actual site. I wanted to monitor parameter whatever printed on Serial Monitor via PC. SUggest me  Best the protocol which can fill my requirement  like zigbee network, wireless network, MODBUS protocol. Ethernet SHield .In above which or any protocol which work fine with Arduino UNo board with least no pins.
If particular protocol chosen . let me know why it has been suggested.
For 2Km, your best bet would be to send the data via a telephone. Landline, if there's one available at the distant end, mobile [cell] phone if not. Have the distant Arduino 'dial' home periodically to pass the data.
123  Using Arduino / Programming Questions / Re: Using Millis! HELP!!! on: March 20, 2014, 12:33:25 am
I'm still confused. If your sensor senses fast, then the blue ball comes in, and it gets sensed many times. How can you then tell there are 2 blue balls, not a whole bunch?
He's reading the sensor once a second, presumably the balls come in at that rate. I get that he wants the balls to roll as far as the appropriate solenoid before operating it. Different (colour) solenoids will be at different distances from the sensor, so he needs a different delay for each colour.
124  Using Arduino / Programming Questions / Re: Specifying state of digital pin, but state fluctuates on: March 20, 2014, 12:22:08 am

Thank you both for the great suggestions.

Henry_Best:

Is there a way to simply add 3:35 hrs to 23:00 and get 26:35? Or do I have to convert each time to an integer number, similar to how I converted all time values into minutes by multiplying the hours by 60 and then adding the minutes? It certainly would be simpler to have the code look something like this

Code:
startTime = 23:00;
duration = 6:00;
endTime = (startTime + duration) % 24;
Not quite. You'll have to add the hours separately from the minutes and check if the minutes are over 60
Code:
Hours =Hours + (minutes/60)  // will add zero if minutes are less than 60
minutes = minutes %60
Use hour(endTime) %24 to avoid mucking up the minutes. You can also do:
Code:
day = hours(endTime) %24
to also set a flag if the result goes over midnight into the next day. That may or may not be useful to you.
Alternately you could use your previous method of converting hours to minutes and using modulo 1440 (= 24 * 60) on the end result.
Whichever floats your boat smiley-grin
125  Using Arduino / Programming Questions / Re: Problem with serial read and swiches? on: March 19, 2014, 11:48:48 pm
Try:
Code:
if (Byte1 == 1 || digitalRead (3) == HIGH){ //Or condition
   digitalWrite(13, !ledState);
   ledState = !ledState;  //flip the value of ledState
   while (digitalRead (3) == HIGH); 
      //sit here and do nothing until button released
}

126  Using Arduino / Programming Questions / Re: Variable Declaration Error? on: March 19, 2014, 11:33:10 pm
Oh... i feel dumb smiley-confuse,  thank you smiley

I'm sure everyone's done that at least once. I certainly have.
127  Using Arduino / Programming Questions / Re: sorting conveyor on: March 19, 2014, 11:29:40 pm
Look up both the Blink without Delay example in the IDE and Functional State Machine. You'll need both methods.
128  Using Arduino / Programming Questions / Re: Using Millis! HELP!!! on: March 19, 2014, 11:19:38 pm
Take a look at both the Blink Without Delay example in the IDE and Functional State Machine. You'll need both of those methods.
129  Using Arduino / Programming Questions / Re: Specifying state of digital pin, but state fluctuates on: March 18, 2014, 11:32:47 pm
Additionally, I'm not really happy with the way the timing of the tides is set currently because it  restricts timing of low tides so that they cannot extend from one day to the next (over midnight).
End = start + length. The end hour, modulo 24, will give the correct time, even if it's the next day. E.g. start is at 23:00 and length is 3:25hrs so end will be 26:25. 26 modulo 24 = 2 gives you 02:25.
130  Using Arduino / Programming Questions / Re: Problem with serial read and swiches? on: March 18, 2014, 11:02:44 pm
Hi there,

I am working on some code that reads incoming bytes from the serial RX pin on the arduino.
once it receives the correct byte it toggles a led on or off, however the problem i have is that i have a mom switch
hooked up (with a debounce schmitt trigger circuit etc) that i want it to do the same job of toggling the same led, yet they are clashing with each other and not sure how to get around it.
Keep a record of the state of pin 13 in a boolean variable so that you don't have to read the state of an output.
Code:
boolean ledState = 1;
void loop()...
if (Byte1 == 1){
       if (ledState ==0) // led on pin 13 is on
           digitalWrite(13, HIGH);
      else
           digitalWrite(13,LOW); // latches led high or low
      ledState = !ledState;  //flip the value of ledState
}

 //Then i have a switch on pin 3

if (digitalRead (3) == HIGH){ // Read mom switch debounce circuit on pin 3
      if (ledState == LOW)      //read led state
          digitalWrite(13, HIGH);
      else
          digitalWrite(13,LOW);
      ledState = !ledState; //flip the value of ledState
}
But that contracts to:
Code:
if (Byte1 == 1){
      digitalWrite(13, !ledState);
      ledState = !ledState;  //flip the value of ledState
}
 //Then i have a switch on pin 3

if (digitalRead (3) == HIGH){ // Read mom switch debounce circuit on pin 3
      digitalWrite(13, !ledstate);
      ledState = !ledState; //flip the value of ledState
}
and further contracts to:
Code:
if (Byte1 == 1 || digitalRead (3) == HIGH){ //Or condition
      digitalWrite(13, !ledState);
      ledState = !ledState;  //flip the value of ledState
}
131  Using Arduino / Programming Questions / Re: Variable Declaration Error? on: March 18, 2014, 10:12:27 pm
I have this problems figuring out the error that has come up in the variable declaration. I am modifying a program i found online but when i hit 'Verify' the error keeps on showing up. The error is 'expected initializer before int'
Here is the error:
Code:
//variables for tuning
int correctFrequency; //the correct frequency for the string being played
int Up //FOR THE OCTAVE INDICATORS
int Up2
int Up3
int Up4
int Down1
int Down2
int Down3
int Down4
Each of those lines needs a semicolon at the end.
132  Using Arduino / Programming Questions / Re: How to run a function for a specific interval, i.e. 10s? on: March 18, 2014, 12:31:57 am
I am working on code to ON the LED for 10 seconds after certain condition (x=false), but the code below runs infinitely. How should correct it? Thanks. I don't want to use delay() function as it stop the other functions running inside the loop.

Code:
void loop()
{
   if(x=false){
    TimerLighting = millis();
    if(millis()-TimerLighting <=10000){
      digitalWrite(LED,HIGH); 
      }
     else{
      digitalWrite(LED,LOW);   
     }
   }
}
You're setting TimerLighting = millis() each time through loop() and then immediately checking  if(millis()-TimerLighting <=10000). This will always be true! Just as looking at a clock every 5 minutes to see if an hour has passed since you last looked at the clock will always be false. TimerLighting = millis(); should be in setup() so that it only gets set once.
133  Using Arduino / Project Guidance / Re: First Arduino Project. Is it Possible and a good first build? Chicken Coop on: March 17, 2014, 11:07:08 pm
Certainly possible, but you should approach it in stages. Get the RTC and door opening/closing working first, then add the other parts, one at a time.
Quote
It seems pretty basic.  How do i learn how to code all this stuff.  Where do i begin to learn how to get this all up and going from a completely new perspective?
I suggest you start with a kit. These usually include a book for the beginner with some examples to work through. Working through all the examples will give you a basic understanding of the electronics and coding involved. Once you've done that, you're not on your own, as this forum is here to help you.
134  Community / Bar Sport / Re: Normal English phrase embarrassing in the US on: March 16, 2014, 11:02:49 pm
I know, as a tourist in England, never to refer to my utility belt as a "fanny pack"
And a bathroom does not always have a toilet in it.
135  Using Arduino / Programming Questions / Re: Simple Switching Sequences on: March 16, 2014, 08:16:36 pm
What UKHeliBob said, and make sure you debounce your button.
Pages: 1 ... 7 8 [9] 10 11 ... 73