summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi-k-s <rishikrishna.sr@gmail.com>2024-07-02 22:48:58 +0530
committerRishi-k-s <rishikrishna.sr@gmail.com>2024-07-02 22:48:58 +0530
commit7bcf5e86b3771cc37c7284e891fc6120c64e99ad (patch)
treedee80266ecfa5244dbe5c57bde3ce5cd0df05ca2
parent1779fbe2fa6a540845b0bf676e9b1d545b8e7c9c (diff)
first nice stuff
-rw-r--r--test/test.ino43
1 files changed, 33 insertions, 10 deletions
diff --git a/test/test.ino b/test/test.ino
index d29c185..c567101 100644
--- a/test/test.ino
+++ b/test/test.ino
@@ -2,6 +2,8 @@
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
+uint8_t value = 0;
+uint8_t counter =0;
#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)
@@ -9,19 +11,20 @@ Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
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");
+ Serial.println("Servo Tester v1.0a");
+ Serial.println("Enter Servo Value");
+ // 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() {
@@ -32,10 +35,30 @@ void loop() {
// Print the incoming byte to the serial monitor
Serial.print("received: ");
Serial.println(incomingByte);
- if (){}
- pwm.setPWM(servonum, 0, pulselen);
+ //Assuming that i only give 3 digit values
+ if(counter == 0){
+ value = (incomingByte - '0') * 100;
+ }
+ else if(counter == 1){
+ value += (incomingByte - '0')*10;
+ }
+ else if(counter == 2){
+ value += (incomingByte - '0')*1;
+ };
+ Serial.println("value");
+ Serial.println(value);
+
+ counter++ ;
+ }
+ if(counter ==3){
+ Serial.println(value);
+ pwm.setPWM(1, 0, value);
+ counter =0;
+ value =0;
}
}
+
+