Go Down

Topic: I am paying for help (Paypal) (Read 320 times) previous topic - next topic

ibra7383

So let's get immediately to it. for a school project, I have to do a presentation about detection systems.
I have three different sensors first an ultrasonic sensor (HC-SR04) that has to measure distance.
Second I have an infrared sensor(HC-51) that activates a led light when I put an obstacle in front of it.
And last I have a radar sensor(RCWL-0516) that also activates a led light when there is an obstacle in front of it but this time it has also have a  switch in between. So this is the good news I already have the codes for each sensor separately. What I want is someone who can combine them together in one sketch/code so it will be easy to represent them. I am using an Arduino Uno. English is not my native language. And I am a beginner in all of this. I have three weeks to finish the coding so whoever will make the code will get the time for it. in the added pdf document you can see a bit how I want it to look like but combined on one Arduino Uno.

 
Code: [Select]
    (ultrasonic sensor)
// Hook up HC-SR04 with Trig to Arduino Pin 10, Echo to Arduino pin 13

#define trigPin 10
#define echoPin 13

float duration, distance;

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
   
  // Write a pulse to the HC-SR04 Trigger Pin
 
 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
 
  // Measure the response from the HC-SR04 Echo Pin
 
  duration = pulseIn(echoPin, HIGH);
 
  // Determine distance from duration
  // Use 343 metres per second as speed of sound
 
  distance = (duration / 2) * 0.0343;
 
  // Send results to Serial Monitor

  Serial.print("Distance = ");
  if (distance >= 400 || distance <= 2) {
     Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
    delay(500);
  }
  delay(500);
}


Code: [Select]
        (ifrared sensor)
void setup() {
  // put your setup code here, to run once:
pinMode(A0,INPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(11,OUTPUT);
digitalWrite(A2,HIGH);
digitalWrite(A1,LOW);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
Serial.println(analogRead(A0));
delay(0);
if(analogRead(A0) < 250)
digitalWrite(11,HIGH);
else
digitalWrite(11,LOW);
}



Code: [Select]
       (radar sensor)
int Sensor = 2;     // RCWL-0516 Input Pin
int Pbut = 3;       // Push button Input Pin
int LED = 12;       // LED Output Pin

int sensorval = 0;  // RCWL-0516 Sensor Value
int pbval = 0;      // Push button value


void setup() {
  pinMode (Sensor, INPUT);  // RCWL-0516 as input
  pinMode (Pbut, INPUT);    // Push button as input
  pinMode (LED, OUTPUT);    // LED as OUTPUT
  digitalWrite(LED, LOW);   // Turn LED Off
}

void loop(){

  sensorval = digitalRead(Sensor);  // Read Sensor value
  pbval = digitalRead(Pbut);        // Read Push button value
 
  if (sensorval == HIGH) {       
    digitalWrite(LED, HIGH);  // Turn LED On
  }
 
  if (pbval == LOW) {       
    digitalWrite(LED, LOW);  // Turn LED Off
  }
}

cloxart

if this is "for a school project" what about using this three weeks to actually study and learn something? I was thinking that is what schools are for.

ibra7383

I am planning on changing my course. I just need to get true this year. and I also work part-time. so I don't have the time to study something that I know I won't use after this year.

wvmarle

Second I have an infrared sensor(HC-51) that activates a led light when I put an obstacle in front of it.
You probably have an FC-51, which is indeed a short range obstacle sensor. No HC-51.

Quote
And last I have a radar sensor(RCWL-0516) that also activates a led light when there is an obstacle in front of it
This is not radar, it's a motion detector. It does not detect stationery objects, or objects that are transparent to microwaves. It's very sensitive to power supply instability, adding a Pi filter is recommended.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Go Up