Measuring speed using phototransistors in Arduino

In summary, the individual is working on a project using two photo-transistors to detect the speed of a projectile. However, they are getting mixed results when measuring the speed of a fast-moving object like a paintball. They are looking for ways to make their setup more efficient and are open to any suggestions.
  • #1
HHOboy
32
0
Hey guys, I am working on a project where I am using two photo-transistors to detect the speed of a projectile. I am trying to measure the speed of a paintball but I am getting mixed results. When a slow moving object passes through the sensors the correct speed is displayed but extremely fast objects can sometimes trick it.

Here is the sketch... It works but if you know any ways to make it more efficient please let me know, Thanks for your help!

FYI: The two sensors are 4 inches apart that is where the constant "333333" comes from the distance between the sensors in the FPS calculation

C:
int firstsens = 4;
int secondsens = 5;
unsigned long time, time2;
float fps, elap;
int val;
int val2;

void setup()
{
Serial.begin(9600);
pinMode (firstsens, INPUT);
pinMode (secondsens, INPUT);
}
void loop()
{
Serial.println("Waiting for projectile...");
val = analogRead(firstsens);
val2 = analogRead(secondsens);
while (val > 1)
{
  val = analogRead(firstsens);
}

while (val <= 1)
{
time = micros();
val = analogRead(firstsens);
}

while (val2 > 1)
{
  val2 = analogRead(secondsens);
}

while (val2 <= 1)
{
time2 = micros();
val2 = analogRead(secondsens);
}
elap = time2 - time;

fps = 333333/elap;
Serial.println(fps );
}
 
Last edited by a moderator:
Technology news on Phys.org
  • #2


Hello there! It sounds like you have a very interesting project on your hands. Using photo-transistors to detect the speed of a projectile is definitely a creative approach. However, it is not surprising that you are getting mixed results when trying to measure the speed of a fast-moving object like a paintball.

One way to potentially improve the efficiency of your setup is to use a higher sampling rate for your analogRead() function. This will allow you to capture more data points and potentially get a more accurate reading for the speed of the projectile. Additionally, you may want to consider using a more precise timing mechanism, such as a timer interrupt, to accurately measure the time between the two sensors being triggered.

Another potential issue could be the sensitivity of your photo-transistors. If they are not sensitive enough, they may not be able to accurately detect the fast-moving paintball. You may want to experiment with different types of sensors or adjust the sensitivity settings to see if that improves the accuracy of your readings.

Overall, it seems like you have a good starting point for your project and with some fine-tuning and adjustments, you should be able to get more consistent and accurate results. Keep up the good work and don't hesitate to reach out if you have any further questions or need more assistance. Good luck with your project!
 

1. How does a phototransistor measure speed in Arduino?

A phototransistor is a type of light-sensitive resistor that converts light into electrical signals. When placed in a circuit connected to an Arduino, it can detect the change in light intensity caused by a moving object and convert it into a voltage signal, which can be measured and used to calculate speed.

2. What is the accuracy of measuring speed using phototransistors in Arduino?

The accuracy of measuring speed using phototransistors in Arduino depends on several factors such as the quality of the phototransistor, the distance between the phototransistor and the object, and the speed of the object being measured. With proper calibration and setup, it is possible to achieve an accuracy of up to 99%.

3. Can phototransistors be used to measure the speed of any object?

Phototransistors can be used to measure the speed of any object as long as it reflects or emits enough light for the phototransistor to detect. For example, it can be used to measure the speed of a moving vehicle, a rotating fan, or even a person walking past it.

4. How do you calibrate the phototransistor for speed measurement?

To calibrate the phototransistor for speed measurement, you need to establish a baseline voltage reading when there is no movement in front of the phototransistor. Then, you can use this baseline reading to calculate the change in voltage caused by the moving object, which can be converted into speed using a simple formula.

5. Can I use multiple phototransistors to improve speed measurement accuracy?

Yes, using multiple phototransistors can improve the accuracy of speed measurement. By placing them at different points along the path of the moving object, you can get a more accurate reading of the speed at different stages of the object's movement. This can be especially useful when measuring the speed of a rapidly accelerating or decelerating object.

Similar threads

Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Computing and Technology
Replies
1
Views
6K
Replies
22
Views
2K
  • Electrical Engineering
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
14K
Back
Top