Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Two Ping sensors on one Arduino on: March 18, 2011, 11:09:26 pm
thebigphish, that is an EXCELLENT suggestion!!!!!! i will try to write this code and see how it works.

Now if I can only get the LEDs to work.
2  Using Arduino / Sensors / Re: Two Ping sensors on one Arduino on: March 17, 2011, 11:13:04 pm
@robtillaart: I'm detecting people. I'm an artist, and my work is about viewer accessibility. As the viewer walks up to the artwork, an LED at the center of the work corresponds in brightness to the distance that person is from the work--the closer the person walks, the brighter the light. The farther away, the dimmer the light gets. Ultimately, the closer the person gets and the more they try to view the artwork, the more impossible that task becomes. I need the sensor to function as far as possible to affect the greatest amount of viewers.

Attached is a crude mockup of the situation.

@jraskell: thank you! that seems very logical. i checked my serial monitor instead of relying on my other output (an LED), and the distance was 370 cm at the most, but mostly 250 cm. It's a bit farther than I thought, so that's useful in some sense!

@raron: WOW! What a great find! Now if only I can build such a magical device...
3  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 13, 2011, 11:59:04 am
Also, I'm unsure if the transistor or the power regulator need anything else on the circuit in order to function properly, i.e. resistor, diode, etc.

Forgive my Newbie questions, but is there anything else I should put on my circuit boards?
4  Using Arduino / Sensors / Re: Two Ping sensors on one Arduino on: March 13, 2011, 11:56:52 am
There isn't a url of the datasheet, but under downloads and resources on this link, the datasheet is listed as a .pdf under Ping documentation v1.6:

 http://www.parallax.com/tabid/768/ProductID/92/Default.aspx

Again, I incredibly appreciate you help!!!!
5  Using Arduino / Sensors / Re: Two Ping sensors on one Arduino on: March 07, 2011, 09:42:25 pm
Quote
Check the datasheet if the sensor has a (bit) larger range when supplying a higher voltage to it.

I checked, and the optimum voltage is 5V. Considering I hook it up to the Arduino itself, I feel like this is def optimal. The datasheet also says the Ping runs from 2 cm to 3.3 m.

Why would my Ping sensor only work up to 5.5 ft? This is quite the mystery to me.
6  Using Arduino / Sensors / Re: Two Ping sensors on one Arduino on: March 07, 2011, 01:11:27 am
Thanks for the suggestions, Groove and robtillaart. I'll definitely look into tubes and into a MAX232.

I'm sure I'll have some follow-up questions, so I'll keep you posted.
7  Using Arduino / Sensors / Two Ping sensors on one Arduino on: March 04, 2011, 05:50:31 pm
Hi, Newbie here again.

I want to run two Ping sensors from one Arduino and have them both be reading pulses at the SAME time. They would both be the input to an LED whose intensity would be controlled by a person's proximity.

My reasoning for using two Ping sensors is that I would like to increase the pulse distance of the Ping sensor. Currently, I have found my Ping (with a cyperbolic reflector to already increase distance) reads only to 370 cm max. In general, mine reads only to 200 cm. I would like to double that distance.

Any ideas? Are two ping sensors possible? Is there an easier way to do this?

Your comments are SO appreciated.
8  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 04, 2011, 05:44:26 pm
Thank you, Groove! I had never heard of those (again, really new). I'll check that out.

I talked to my professor again, and he suggested to only use 3 of these LEDs, then to create a circuit with a 5V 3A power supply, an LM317 to lower the voltage, and a transistor.

Do you think that running 5V/3.0A to an Arduino would be ok? Is there anything else I should consider?
9  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 04, 2011, 02:55:25 pm
To be honest, it's because I'm really new to this and wasn't aware that the LED would need any external power.

Thanks again for your input, Groove and AWOL! I take it from your responses that I SHOULD use external power. This being said, since I need to hook up 12 of these 1 Watt LEDs, I believe I need a 12A power source. Are there other electrical implementations I should use with this--i.e. a transistor, a voltage regulator, etc.? Again, I'm really new to this, so I apologize if my questions are really elementary.
10  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 03, 2011, 06:29:41 pm
Not particularly, no. It also flickers a lot when the sensor reads past 61 cm (I set the LED to stay at 255 when the sensor reads closer than 61 cm).

By the end of the project, I need around 12 of those LEDs to be lit in order to get the obnoxious amount of brightness required. Thus, my problem with needing a power source will be a lot larger by the end.
11  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 03, 2011, 04:53:48 pm
I'm using the Arduino itself (the 5V pin) to power the LED. I have the LED on a breadboard right now with a 220 resistor.
12  Using Arduino / Sensors / Re: Newbie using a Ping sensor to control a fade LED function on: March 03, 2011, 12:55:09 pm
Thanks for the reply, Groove.

I recently got some help in the code dept from a professor, and our collaboration yielded this.

Code:
int ledpin = 11;



int val;

const int pingPin = 7;

void setup() {
 
// initialize serial communication:
  Serial.begin(9600);
  delay(1000);
 
  pinMode(ledpin, OUTPUT);
 
}

void loop() {
 
   long duration, inches, cm;

   pinMode(pingPin, OUTPUT);
   digitalWrite(pingPin, LOW);
   delayMicroseconds(2);
   digitalWrite(pingPin, HIGH);
   delayMicroseconds(5);
   digitalWrite(pingPin, LOW);
   pinMode(pingPin, INPUT);
   duration = pulseIn(pingPin, HIGH);
   
  // convert the time into a distance
   cm = microsecondsToCentimeters(duration);

  // alberto's debugging block
Serial.print("duration = ");
Serial.print(duration);
Serial.print("\t");
Serial.print("cm = ");
Serial.println(cm);
Serial.println("----------");

if (cm > 200)
{
   analogWrite(ledpin, 0);
}
else{

  val = cm;               // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 200, 10, 0, 255);        // scale it to use it with the LED (value between 0 and 255)
 
 
  analogWrite(ledpin, val);
  delay(10);

}

if (cm > 61)
{
  analogWrite(ledpin, HIGH);
}
 





}
 
// The following functions won't compile if not used in the code so no need to comment any out.
// Your code left out the closing curly bracket, not sure how it cmpiled without it but maybe
// it was only in the version you emailed me.
long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}


long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}

The code works, which is great, but now there's another problem...The LED is not functioning correctly. It lights up when it is supposed to but has this annoying habit of flickering, especially when someone moves in front of the sensor. My professor said i should get an external power supply for it (it's an ultra-bright 1 Watt LED)...

...any ideas?
13  Using Arduino / Sensors / Newbie using a Ping sensor to control a fade LED function on: March 01, 2011, 12:32:32 pm
Hi all,

I'm really new to Arduino code and am having trouble with my current project.

I want to use a Parallax Ping sensor to control how bright or dim an LED becomes. The closer that a person approaches, the brighter the light. The farther away, the dimmer the light.

I found a simplified Ping code on the Arduino site, but don't know how to modify it for my project. Any suggestions?

Here is the code I have so far:

//working Ping project

 unsigned long echo = 0;
 int ultraSoundSignal = 7; // Ultrasound signal pin
 unsigned long ultrasoundValue = 0;

 void setup()
 {
 Serial.begin(9600);
 pinMode(ultraSoundSignal,OUTPUT);
 pinMode(11, OUTPUT);       //sets up LED as output
 }

 unsigned long ping(){
 pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
 digitalWrite(ultraSoundSignal, LOW); // Send low pulse
 delayMicroseconds(2); // Wait for 2 microseconds
 digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
 delayMicroseconds(5); // Wait for 5 microseconds
 digitalWrite(ultraSoundSignal, LOW); // Holdoff
 pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
 digitalWrite(ultraSoundSignal, HIGH); // Turn on pullup resistor
  echo = pulseIn(ultraSoundSignal, HIGH); //Listen for echo
  ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches
 return ultrasoundValue;
 }

 void loop()
 {
 int x = 0;
 x = ping();
  Serial.println(x);
  delay(250); //delay 1/4 seconds.

if (ping() > 84)
  {
    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1)
  {
   
    //sets the value (range from 0 to 255);
    analogWrite(11, fadeValue);
    //wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
   
    }
  else
  {
     for(int fadeValue = 255 ; fadeValue>= 0; fadeValue -=1)
  {
    //sets the value (range from 0 to 255):
    analogWrite(11, fadeValue);
    //wait for 30 milliseconds to see dimming effect
    delay(30);
 
}
}
 }
Pages: [1]