summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi-k-s <rishikrishna.sr@gmail.com>2024-07-02 22:02:28 +0530
committerRishi-k-s <rishikrishna.sr@gmail.com>2024-07-02 22:02:28 +0530
commit1779fbe2fa6a540845b0bf676e9b1d545b8e7c9c (patch)
tree1b9d77b3fc417a1ca73cc9d23d60f795221ddb99
first commit
-rw-r--r--main/main.ino31
-rw-r--r--test/test.ino41
2 files changed, 72 insertions, 0 deletions
diff --git a/main/main.ino b/main/main.ino
new file mode 100644
index 0000000..ce314d5
--- /dev/null
+++ b/main/main.ino
@@ -0,0 +1,31 @@
+#include <Wire.h>
+#include <Adafruit_PWMServoDriver.h>
+
+Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
+
+#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
+#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
+#define USMIN 600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150
+#define USMAX 2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600
+#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates
+
+
+// our servo # counter
+uint8_t servonum = 0;
+
+void setup() {
+ // put your setup code here, to run once:
+ Serial.begin(9600);
+ Serial.println("8 channel Servo test!");
+
+ pwm.begin();
+ pwm.setOscillatorFrequency(27000000);
+ pwm.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
+
+ delay(10);
+}
+
+void loop() {
+ // put your main code here, to run repeatedly:
+ Serial.println(servonum);
+}
diff --git a/test/test.ino b/test/test.ino
new file mode 100644
index 0000000..d29c185
--- /dev/null
+++ b/test/test.ino
@@ -0,0 +1,41 @@
+#include <Wire.h>
+#include <Adafruit_PWMServoDriver.h>
+
+Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
+
+#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
+#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
+
+void setup() {
+ // put your setup code here, to run once:
+ Serial.begin(9600);
+ Serial.println("Servo Tester");
+ Serial.println("Choose Servo");
+ Serial.println("1");
+ Serial.println("2");
+ Serial.println("3");
+ Serial.println("4");
+ Serial.println("5");
+ Serial.println("6");
+
+ pwm.begin();
+ pwm.setOscillatorFrequency(27000000);
+ pwm.setPWMFreq(50);
+
+}
+
+void loop() {
+ if (Serial.available() != 0) {
+ // Read the incoming byte
+ char incomingByte = Serial.read();
+
+ // Print the incoming byte to the serial monitor
+ Serial.print("received: ");
+ Serial.println(incomingByte);
+ if (){}
+
+ pwm.setPWM(servonum, 0, pulselen);
+
+ }
+
+}