Show Posts
Pages: 1 [2]
16  Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code? on: November 28, 2012, 01:52:58 pm
This may work
http://arduino.cc/forum/index.php/topic,39237.0.html
17  Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code? on: November 28, 2012, 11:57:36 am
How big are the wheels?
Or how many inputs per rotation of the wheel?
And are all the sensors have the same inputs per rotation including the rear?

I'll look around and see if I can find some counting sketch that could be applied to what ya have.
18  Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code? on: November 28, 2012, 10:11:29 am
It's a great application for a Arduino.  

I think if the inputs from FRS, FLS and RS are accumulated for 300ms or so and then cycled through the code and invert any negative equation result from (ReadFRS - ReadFLS) or (ReadRS - FrontAverage) it would work but I have no idea how to do it.

Code:
   if(FrontCompare >  0.2 * FrontAverage)
   {
      digitalWrite(Traction, HIGH);
      delay(3000);
      digitalWrite(Traction, LOW);
   }
  
        else if(TotalCompare > 0.2 * (ReadRS + FrontAverage)/2)
     {
        digitalWrite(Traction, HIGH);
        delay(3000);
        digitalWrite(Traction, LOW);
     }
 
19  Using Arduino / Programming Questions / Re: Help with RPM code on: November 28, 2012, 09:45:33 am
I could be wrong but I remember hearing or reading somewhere that it will sense as little as 1ua or .0001 amps. Is your RPM input pin a Digitalread or Analogread?

If ya have the time take a look at this video
20  Using Arduino / Programming Questions / Re: Help with RPM code on: November 28, 2012, 04:10:09 am
50-60K is cranking seems a bit to fast how fast does it update the rpm on the monitor?
21  Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code? on: November 28, 2012, 03:26:39 am
I know I'm new to programming but I don't see anything in the sketch to count the wheel or shaft revolutions within a given amount time.

I'm thinking that most automotive ABS cycle something like every 200ms or less. Counting the inputs pulses with in a specific amount of time doing some math like you have above. Then determining if in fact the drive wheels are slipping. I'm thinking you have everything to make it work but you missing a bit of programming.

 If your lucky maybe some programming guru will help your team pass you final for tomorrow.  smiley-wink
22  Using Arduino / Programming Questions / Re: IR Sensors Read, Compare, and Output Code? on: November 28, 2012, 01:22:43 am
I know I'm new to the site but is it possible that the code below.
Code:
int FrontCompare = abs(ReadFRS - ReadFLS)
or
int TotalCompare = abs(ReadRS - FrontAverage);
could result in a negative numbers and thus greatly changing the indifference in comparison.

I guess if you keep making left hand turns you should be ok for the FrontCompare. smiley-wink

23  Using Arduino / Programming Questions / Re: Help with Sketch on: November 27, 2012, 11:56:13 pm
Hello, there are some mistakes in your code, I will correct a few and you do the rest:
Code:
void loop()
{
  int val = analogRead(sensePin);

  Serial.println( val );
  delay (200);
  
  if (val >= 1 && val <= 100)
  {
    digitalWrite(aPin, HIGH);
    digitalWrite(bPin, HIGH);
    digitalWrite(cPin, HIGH);
    digitalWrite(dPin, HIGH);
    digitalWrite(ePin, HIGH);
    digitalWrite(fPin, HIGH);
    digitalWrite(gPin, LOW);
  }

  else if (val >= 101 && val <= 200)
  {
    digitalWrite(aPin, LOW);
    digitalWrite(bPin, HIGH);
    digitalWrite(cPin, HIGH);
    digitalWrite(dPin, LOW);
    digitalWrite(ePin, LOW);
    digitalWrite(fPin, LOW);
    digitalWrite(gPin, LOW);
  }
  //etc etc
}

Study the changes, and apply them to the rest of your code smiley

Also you will have to restore the pins to HIGH, or they will stay LOW You fixed it already smiley


Thanks a million with your help it's working now.

I remember twenty years ago when to school for electronics the coolest new chip that just came out could store 7 seconds of audio. So thing have changed a bit  smiley thanks for the help guys
24  Using Arduino / Programming Questions / Re: Help with Sketch on: November 27, 2012, 11:34:30 pm
Hello, there are some mistakes in your code, I will correct a few and you do the rest:
Code:
void loop()
{
  int val = analogRead(sensePin);

  Serial.println( val );
  delay (200);
  
  if (val >= 1 && val <= 100)
  {
    digitalWrite(aPin, HIGH);
    digitalWrite(bPin, HIGH);
    digitalWrite(cPin, HIGH);
    digitalWrite(dPin, HIGH);
    digitalWrite(ePin, HIGH);
    digitalWrite(fPin, HIGH);
    digitalWrite(gPin, LOW);
  }

  else if (val >= 101 && val <= 200)
  {
    digitalWrite(aPin, LOW);
    digitalWrite(bPin, HIGH);
    digitalWrite(cPin, HIGH);
    digitalWrite(dPin, LOW);
    digitalWrite(ePin, LOW);
    digitalWrite(fPin, LOW);
    digitalWrite(gPin, LOW);
  }
  //etc etc
}

Study the changes, and apply them to the rest of your code smiley

Also you will have to restore the pins to HIGH, or they will stay LOW You fixed it already smiley


I will do that Thanks for looking at it
Man I cant believe how many people are on this site so late at night.
25  Using Arduino / Programming Questions / Re: Help with Sketch on: November 27, 2012, 11:30:21 pm
Hi SAButter, and welcome to the forums.

Before we can help, you'll need to explain what the sketch does that is incorrect.  What's it doing wrong?

The leds on the output pins to the segment are all high and not changing with the input state.
26  Using Arduino / Programming Questions / Re: Help with Sketch on: November 27, 2012, 11:26:47 pm
OOOooo
Sorry guys I didn't think that I would have a response that fast. I noticed that I posted a newer sketch of what I am working on so I edited my original post and changed the code.
Sorry
27  Using Arduino / Programming Questions / Help with Sketch on: November 27, 2012, 11:15:00 pm
I just started playing with microcontrollers and I am learning.

I'm working on a water tank level indicator and I'm having some trouble figuring it out whats wrong with the sketch. What I am trying to do is have a pot activate pins that correspond to a 7 seg common anode display. Hopefully someone has some time to look at this that would be a big help thanks.


Code:
int aPin = 13;                // Red LED connected to digital pin 13
int bPin = 12;               
int cPin = 11;               
int dPin = 10;                 
int ePin = 9;               
int fPin = 8;
int gPin = 7;   
int hPin = 6; //BI Blanking input LOW turns off segments HIGH normal op.

int sensePin = 0;    // select the input pin for the Map

void setup()                      // run once, when the sketch starts
{
  Serial.begin(9600);
  analogReference (DEFAULT);
  pinMode(aPin, OUTPUT);        // sets the digital pin as output
  pinMode(bPin, OUTPUT);   
  pinMode(cPin, OUTPUT);
  pinMode(dPin, OUTPUT);
  pinMode(ePin, OUTPUT);
  pinMode(fPin, OUTPUT);
  pinMode(gPin, OUTPUT);
  pinMode(hPin, OUTPUT); //BI Blanking input LOW turns off segments HIGH normal op if used on 7447 driver.
}

void loop()
{
  Serial.println(analogRead(sensePin));
  delay (200);
 
  int val = analogRead(sensePin);
  if (val >= 1 && val <= 100)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, LOW);
 
  if (val >= 101 && val <= 200)
  digitalWrite(aPin, LOW);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, LOW);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, LOW);
  digitalWrite(gPin, LOW);
 
  if (val >= 201 && val <= 300)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, LOW);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, LOW);
  digitalWrite(gPin, HIGH);
 
  if (val >= 301 && val <= 400)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, LOW);
  digitalWrite(gPin, HIGH);
 
  if (val >= 401 && val <= 500)
  digitalWrite(aPin, LOW);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, LOW);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
 
  if (val >= 501 && val <= 600)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, LOW);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
 
  if (val >= 601 && val <= 700)
  digitalWrite(aPin, LOW);
  digitalWrite(bPin, LOW);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
 
  if (val >= 701 && val <= 800)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, LOW);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, LOW);
  digitalWrite(gPin, LOW);
 
  if (val >= 801 && val <= 900)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, HIGH);
  digitalWrite(ePin, HIGH);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
 
  if (val >= 901 && val <= 1023)
  digitalWrite(aPin, HIGH);
  digitalWrite(bPin, HIGH);
  digitalWrite(cPin, HIGH);
  digitalWrite(dPin, LOW);
  digitalWrite(ePin, LOW);
  digitalWrite(fPin, HIGH);
  digitalWrite(gPin, HIGH);
 
 
}
 
Pages: 1 [2]