I want to scan 5 different qr code to activate the servo

image

<#include <SoftwareSerial.h>
#define LED_G 8
#define LED_R 9
#define BUZZER 2
#include <Servo.h>
SoftwareSerial mySerial(3, 4); // RX, TX
Servo myServo;

void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
myServo.attach(11); //servo pin
myServo.write(0); //servo start position
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(BUZZER, OUTPUT);
noTone(BUZZER);
myServo.write(180);

}

void loop()
{
digitalWrite(LED_R, LOW);
digitalWrite(LED_G, HIGH);
myServo.write(0);
if (mySerial.available()) // Check if there is Incoming Data in the Serial Buffer.
{
while (mySerial.available()) // Keep reading Byte by Byte from the Buffer till the Buffer is empty
{
char input = mySerial.read(); // Read 1 Byte of data and store it in a character variable

  Serial.print(input); // Print the Byte
  delay(5); // A small delay
}

  delay(300); 
  digitalWrite(LED_R, HIGH);
  digitalWrite(LED_G, LOW);
  tone(BUZZER, 6000);
  delay(500);
  noTone(BUZZER);

myServo.write(90);
delay(7000);
myServo.write(0);
delay(500);

}
}
/>

Put all your formatted code within the code tag (</>):

#include <SoftwareSerial.h>
#define LED_G 8
#define LED_R 9
#define BUZZER 2
#include <Servo.h>
SoftwareSerial mySerial(3, 4);  // RX, TX
Servo myServo;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  myServo.attach(11);  // servo pin
  myServo.write(0);    // servo start position
  pinMode(LED_G, OUTPUT);
  pinMode(LED_R, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  noTone(BUZZER);
  myServo.write(180);
}

void loop() {
  digitalWrite(LED_R, LOW);
  digitalWrite(LED_G, HIGH);
  myServo.write(0);
  if (mySerial.available())  // Check if there is Incoming Data in the Serial
                             // Buffer.
  {
    while (mySerial.available())  // Keep reading Byte by Byte from the Buffer
                                  // till the Buffer is empty
    {
      char input = mySerial.read();  // Read 1 Byte of data and store it in a
                                     // character variable

      Serial.print(input);  // Print the Byte
      delay(5);             // A small delay
    }

    delay(300);
    digitalWrite(LED_R, HIGH);
    digitalWrite(LED_G, LOW);
    tone(BUZZER, 6000);
    delay(500);
    noTone(BUZZER);

    myServo.write(90);
    delay(7000);
    myServo.write(0);
    delay(500);
  }
}

Hello charxs

Post a schematic and a link to the hardware used.

  1. In your other topic I have asked about a complete description of your project; the same applies here.
  2. Please use code tags.
  3. Please explain what you are stuck with?

Your topic has been moved to a more suitable location on the forum as this has nothing to do with Avrdude, stk500 or Bootloader

Hi, @charxs
Welcome to the forum.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

#include <SoftwareSerial.h>
#define LED_G 8
#define LED_R 9
#define BUZZER 2
#include <Servo.h>
SoftwareSerial mySerial(3, 4); // RX, TX
Servo myServo;

void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
myServo.attach(11); //servo pin
myServo.write(0); //servo start position
pinMode(LED_G, OUTPUT);
pinMode(LED_R, OUTPUT);
pinMode(BUZZER, OUTPUT);
noTone(BUZZER);
myServo.write(0);

}

void loop()
{
digitalWrite(LED_R, LOW);
digitalWrite(LED_G, HIGH);
myServo.write(0);
if (mySerial.available()) // Check if there is Incoming Data in the Serial Buffer.
{
while (mySerial.available()) // Keep reading Byte by Byte from the Buffer till the Buffer is empty
{
char input = mySerial.read(); // Read 1 Byte of data and store it in a character variable

  Serial.print(input); // Print the Byte
  delay(5); // A small delay
}

  delay(300); 
  digitalWrite(LED_R, HIGH);
  digitalWrite(LED_G, LOW);
  tone(BUZZER, 6000);
  delay(500);

myServo.write(90);
delay(7000);
myServo.write(0);
noTone(BUZZER);
delay(500);

}
}

Please edit your post, select all code and click the </> button to apply so-called code tags and next save your post. It makes it easier to read, easier to copy and the forum software will display it correctly.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project :wink: See About the Installation & Troubleshooting category.

Show us what you tried; I don't see anything related to XAMPP in your code.

What is SoftwareSerial used for in your code? Where does it get its data from? In short, please give a complete description of your project.

Which Arduino are you using?

@charxs, please do not cross-post. Threads merged.

Hi, @charxs

What do you want your code to do?
What does your code do?

Can you please post links to specs/data of your hardware?
Can you please post a schematic of your project?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.