Show Posts
Pages: [1] 2
1  Topics / Product Design / Re: Advice on starting out with Eagle on: August 18, 2012, 10:58:17 pm
You tube, rpc electronics. Very good how to vids from 1-12
2  Using Arduino / Project Guidance / Re: code issues on: August 09, 2012, 10:47:03 pm
Cut and paste into bottom of void loop. Let me know?
3  Using Arduino / Project Guidance / Re: code issues on: August 08, 2012, 08:59:30 pm
I just had a question. Does it not have to be in the void loop part of the sketch to run over and over again or will it do that command anywhere with in the sketch. For my own curiosity.

Thanks
4  Using Arduino / Programming Questions / Re: millis() One pin. Two different delays Help? on: August 06, 2012, 10:57:13 pm
Wow! I appreciate all the help. Didn't realize there are so many ways to do it. Google was not my friend on this one. I have been trying for days to figure it out on my own.
5  Using Arduino / Programming Questions / Re: millis() One pin. Two different delays Help? on: August 06, 2012, 10:31:47 pm
Huh!!! I knew it was that easy I was so close. It works beautifully. Im not sure about the flag statement. Could you tell me how that works?

Thanks
Matt 
6  Using Arduino / Programming Questions / millis() One pin. Two different delays Help? on: August 06, 2012, 09:05:24 pm
Hi
Does Anyone have an example of using  Millis() with two delays on the same pin.

I would like a pin to high for 10 sec and low for 2 sec. delay statement won't work for my application.
Any examples that work will be useful I would just like to see how it would be done .

Thanks
Matt
7  Using Arduino / Programming Questions / Re: Is there a manual for the Arduino? on: July 29, 2012, 08:20:35 am
If you have an Android or i phone  you can download the arduino reference or arduino companion. I find them both very useful.
8  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 28, 2012, 05:18:08 pm
Yes it is set for 1000. Can you use two variables with millis().1000 on 500 off. like the code but with millis(). I have fixed the led problem. Cant have sucess without some sacrifice.

 
Code:
digitalWrite ledPin, HIGH);
          delay(1000);
          digitalWrite ledPin, LOW);
          delay(500)
9  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 28, 2012, 04:32:02 pm
what ever i did its dead. Good thing I stock up for these frequent occasions smiley-mr-green
10  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 28, 2012, 02:47:27 pm
Ok this is part of my main sketch. millis() works well. the jist of the code is when I turn on switches on my remote 5 and 6. everything works like its suppose to unless voltage divider is reading between 24 and 25 volts then mowerpin will shut off and on to tell me the battery is getting low. when channel 5 reads to voltage is under 24 volts the diconnectpin will shut off Question is? Is there a way to adjust the delay times? its set for 1000 what if I wanted to have 2 secs off 10 sec on? Also when the millis() is working my test led on disconnectpin was fantly flashing when the ch5 switch is off. Any thoughts as to why it would do that. I tried to trouble shoot and fried my 328 when i turn on the internal pull up (not wise to do if you already have a external pull down doh).

Thanks

Code:
const int voltPin = 0;  //Analog volt read pin

float denominator;      //Variables for voltage divider
int resistor1 = 10000;  //Check resistors with ohm meter and adjust according
int resistor2 = 1870;

int disconnectpin = 4;  // Main disconnect
int mowerpin = 7;       // Mower motor
int mowerstate= LOW;
long previousMillis = 0;// will store last time mowerpin was updated
long interval = 1000;   // interval at which to delay (milliseconds)

int servo5 = 11;        // r/c channel 5
int servo6 = 12;        // r/c channel 6
int(ch5);
int(ch6);
void setup(){

Serial.begin(9600);
  
  //Convert resistor values to division value
  //  R2 / (R1 + R2)
  denominator = (float)resistor2 / (resistor1 + resistor2);
  
  pinMode(servo5, INPUT);      //Pin 5 as input
  pinMode(servo6, INPUT);      //Pin 6 as input
 
  pinMode(disconnectpin, OUTPUT); //Pin 4 as output
  pinMode(mowerpin, OUTPUT);      //Pin 7 as output
  analogWrite(disconnectpin, 0);  
  analogWrite(mowerpin, 0);
}
  void loop() {

  float voltage;
  //Obtain RAW voltage data
  voltage = analogRead(voltPin);

  //Convert to actual voltage (0 - 5 Vdc)
  voltage = (voltage / 1024) * 5.0;

  //Convert to voltage before divider
  //  Divide by divider = multiply
  //  Divide by 1/5 = multiply by 5
  voltage = voltage / denominator;
  
                      
  ch5 = pulseIn(servo5, HIGH, 20000); // Read the pulse width of each channel
  ch6 = pulseIn(servo6, HIGH, 20000);
 
  // Channel 6 mower switch. If voltage is between 24 and 25 volts mowerpin will turn off and on.  
  
unsigned long currentMillis = millis();

if(currentMillis - previousMillis > interval && voltage >= 24 && voltage <= 25) {
  // save the last time checked state
    previousMillis = currentMillis;  

  if  (mowerstate == LOW)
      (mowerstate = HIGH);
  if
      (mowerstate = LOW);{
      digitalWrite(mowerpin, mowerstate);
  
   }    
 }
  else if (ch6 >= 1900 && ch6 <= 2200){
    digitalWrite(mowerpin, HIGH);                 //Also if voltage is above 24 volts
  }
  
  else  {
    digitalWrite(mowerpin, LOW);                  //If channel 5 is below 1900 or voltage is below 24 volts. disconnectpin will be on
  }
  


  
    // channel 5 disconnect switch with shut off if voltage falls below 24 volts
    
    if(ch5 >= 1900 && ch5 <= 2200 && voltage > 24){    //If channel 5 is between 1900 and 2200 disconnectpin will be off
    digitalWrite(disconnectpin, HIGH);                 //Also if voltage is above 24 volts
  }
  
  else  {
    digitalWrite(disconnectpin, LOW);                  //If channel 5 is below 1900 or voltage is below 24 volts. disconnectpin will be on
  }
}
11  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 27, 2012, 11:43:05 pm
Thanks CrossRoads that what i was looking for. I will change my code and see if I can get it to work. Appreciate your replies.
12  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 27, 2012, 11:04:43 pm
It wasn't complicated till i had to learn millis() LOL. I understand how the BlinkWithoutDelay sketch works just don't how to include my between statements. Where would I put my
 if(voltage >= 24 && voltage <=25); statement that would be the push I need.
13  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 27, 2012, 10:45:31 pm
Honestly it would be easier for me to use a buffer but I am trying to learn also teach my self and kids some code. I have read the BlinkWithoutDelay. I don't understand how i would include it with my application. Not looking for the answer as i learn by doing. Just looking for a push in the right direction. Thanks CrossRoads for pushing it just wasn't hard enough.
14  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 27, 2012, 09:53:59 pm
I was just reading about millis(). I will try and see if i can implement it for my application. If delay stops the program would that mean if im delay(100) for serial monitor will that affect my sketch as well?
15  Using Arduino / Programming Questions / Re: Aduino pin. 2 things at once??????? on: July 27, 2012, 09:34:34 pm
Ok so I just read that delay can't do two things at once. Is there a way around this or should i just digitalWrite pin LOW when it gets to say 24.5 volts
Pages: [1] 2