tap_flow_controller/flow_controller.ino

34 lines
899 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <Servo.h>
Servo myServo; // Create a Servo object
const int servoPin = 10; // D10 is OC1B on Pro Mini
const int ledPin = 13;
const int analogPin = A0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200); // Initialize Serial
myServo.attach(servoPin); // Attach servo to pin 10
}
void loop() {
int analogValue = analogRead(analogPin); // Read from A0 (01023)
int angle = map(analogValue, 0, 1023, 0, 180); // Map to 0180 degrees
myServo.write(angle); // Set servo angle
digitalWrite(ledPin, HIGH);
// Serial.print("LED ON - Analog: ");
// Serial.print(analogValue);
// Serial.print(" | Angle: ");
// Serial.println(angle);
delay(10);
digitalWrite(ledPin, LOW);
// Serial.print("LED OFF - Analog: ");
// Serial.print(analogValue);
// Serial.print(" | Angle: ");
// Serial.println(angle);
delay(10);
}