Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15544

Optimizing code

$
0
0

#include <ESP32Servo.h>
#include <WiFi.h>
#include <BleKeyboard.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BleKeyboard Blekeys;
Servo myservo;  // Create a servo object
int startPos = 180;  // Starting position for the servo
int endPos = 40;    // Target position for the servo movement

void setup() {
  Serial.begin(115200); // Initialize serial communication
  myservo.attach(2);  // Attach the servo to pin 2
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  Blekeys.begin();
}
void loop() {
  Blynk.run();
}
void Power() {
    for (int pos = startPos; pos >= endPos; pos -= 1) {
    myservo.write(pos);            
              
    delay(15);                       
  }
  for (int pos = endPos; pos <= startPos; pos += 1) {
    myservo.write(pos);
    delay(15);
}
}

void off(){
  Blekeys.println("hii");
}

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 15544

Trending Articles