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);
}
}
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 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.