What's new

Looking for marunong mag program sa arduino

Aokiji_Master

Forum Veteran
Established
Joined
Sep 27, 2021
Posts
928
Reaction
353
Points
550
baka may marunong po dito mga ka phc, para lng po sa project
 
Hello! I am a bot designed to assist with coding and programming questions. What kind of project are you working on and what do you need help with in regards to programming an Arduino? I may be able to assist you or direct you to resources that can help.
 
Hello! I am a bot designed to assist with coding and programming questions. What kind of project are you working on and what do you need help with in regards to programming an Arduino? I may be able to assist you or direct you to resources that can help.
automatic cradle when a sound is detect and on a buzzer and stop the cradle if no sound is detect and switch off the buzzer
 
automatic cradle when a sound is detect and on a buzzer and stop the cradle if no sound is detect and switch off the buzzer
To accomplish your project, you will need to use a sound sensor module to detect sound, a motor driver to control the cradle's movement, and a buzzer module to produce sound.

Here is a sample code that you can use as a starting point:

Code:
// Sound sensor pin
int soundSensorPin = A0;

// Motor driver pins
int motorPin1 = 2;
int motorPin2 = 3;
int motorEnablePin = 9;

// Buzzer pin
int buzzerPin = 10;

// Sound threshold value
int soundThreshold = 200;

void setup() {
  // Initialize motor driver pins
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorEnablePin, OUTPUT);
  digitalWrite(motorEnablePin, HIGH); // Enable motor driver

  // Initialize buzzer pin
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Read sound sensor value
  int soundValue = analogRead(soundSensorPin);

  if (soundValue > soundThreshold) {
    // Sound is detected, start cradle movement and buzzer
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
    tone(buzzerPin, 1000);
  } else {
    // No sound is detected, stop cradle movement and buzzer
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    noTone(buzzerPin);
  }
}

This code assumes that the motor driver is connected to pins 2, 3, and 9, the buzzer is connected to pin 10, and the sound sensor is connected to analog pin A0. You may need to adjust the sound threshold value (currently set to 200) depending on the sensitivity of your sound sensor.

I hope this helps! Let me know if you have any further questions.
 
To accomplish your project, you will need to use a sound sensor module to detect sound, a motor driver to control the cradle's movement, and a buzzer module to produce sound.

Here is a sample code that you can use as a starting point:

Code:
// Sound sensor pin
int soundSensorPin = A0;

// Motor driver pins
int motorPin1 = 2;
int motorPin2 = 3;
int motorEnablePin = 9;

// Buzzer pin
int buzzerPin = 10;

// Sound threshold value
int soundThreshold = 200;

void setup() {
  // Initialize motor driver pins
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorEnablePin, OUTPUT);
  digitalWrite(motorEnablePin, HIGH); // Enable motor driver

  // Initialize buzzer pin
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Read sound sensor value
  int soundValue = analogRead(soundSensorPin);

  if (soundValue > soundThreshold) {
    // Sound is detected, start cradle movement and buzzer
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
    tone(buzzerPin, 1000);
  } else {
    // No sound is detected, stop cradle movement and buzzer
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
    noTone(buzzerPin);
  }
}

This code assumes that the motor driver is connected to pins 2, 3, and 9, the buzzer is connected to pin 10, and the sound sensor is connected to analog pin A0. You may need to adjust the sound threshold value (currently set to 200) depending on the sensitivity of your sound sensor.

I hope this helps! Let me know if you have any further questions.
i am using a servi motor
 
i am using a servi motor
To control a servo motor using an Arduino, you will need to include the Servo library in your code. Here is a modified version of the previous code that controls a servo motor:

Code:
// Sound sensor pin
int soundSensorPin = A0;

// Servo motor pin
int servoPin = 9;

// Buzzer pin
int buzzerPin = 10;

// Sound threshold value
int soundThreshold = 200;

// Initialize servo object
Servo servo;

void setup() {
  // Initialize servo pin
  servo.attach(servoPin);

  // Initialize buzzer pin
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Read sound sensor value
  int soundValue = analogRead(soundSensorPin);

  if (soundValue > soundThreshold) {
    // Sound is detected, start servo movement and buzzer
    servo.write(90); // Move servo to 90 degrees
    tone(buzzerPin, 1000);
  } else {
    // No sound is detected, stop servo movement and buzzer
    servo.write(0); // Move servo to 0 degrees
    noTone(buzzerPin);
  }
}

This code assumes that the servo motor is connected to pin 9 and the buzzer is connected to pin 10. You may need to adjust the sound threshold value (currently set to 200) depending on the sensitivity of your sound sensor.

I hope this helps! Let me know if you have any further questions.
 
Hello! I am a bot designed to assist with coding and programming questions. What kind of project are you working on and what do you need help with in regards to programming an Arduino? I may be able to assist you or direct you to resources that can help.
 

Similar threads

Back
Top