ARDUINO 4

PHOTO EMBED

Mon Jan 08 2024 23:16:11 GMT+0000 (Coordinated Universal Time)

Saved by @马丽

#include <LiquidCrystal.h>
#include <Servo.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Set up the LCD pins
Servo myservo; // Create a Servo object

const int led = 13; // LED connection to digital pin 13
const int led1 = 6; // LED connection to digital pin 6

byte leds = 0;

void setup() {
  lcd.begin(16, 2); // Initialize the LCD screen
  pinMode(led, OUTPUT);
  pinMode(led1, OUTPUT);
  myservo.attach(10); // Attach the servo motor to digital pin 10
}

void loop() {
  // Turn on the LED and rotate the servo and display message "on"
  digitalWrite(led, HIGH);
  digitalWrite(led1, LOW);
  lcd.setCursor(0, 0);
  lcd.print("    NOVVA ON");
  myservo.write(0); // Rotate the servo to 90 degrees

  delay(3000); // Delay for 3 seconds

  // Turn off the LED and stop the servo and display message "off"
  digitalWrite(led, LOW);
  digitalWrite(led1, HIGH);
  lcd.clear(); // Clear the LCD Display
  lcd.setCursor(0, 0);
  lcd.print("   NOVVA OFF!");
  myservo.write(90); // Stop the servo motor

  delay(3000); // Delay for 3 seconds
}
content_copyCOPY