Hello,
So I'm fairly new to this Arudino programming and I feel like my professor hasn't explained to us properly in terms of how to put various codes together.
I'm trying to put a sensor code (my sensor is a distance sensor) and sweep or knob? code. And then after that I was told that I need to incorporate the smoothing code as well.
I have three mini-servos that I want it to work by the trigger of the distance sensor. I'm so confused!!
// Controlling a servo using a distance sensor
// by Michal Rinott ,http:/people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int distancesensor = 0; // analog pin used to connect the distance sensor
int sensorValue; // variable to read the value from the analog pin
void setup()
{
myservo. attach(8); // attaches the servo on pin 9 to the servo object
}
void loop()
{
//this part i added
while(sensorValue >330)
myservo.write(0);
delay(1);
myservo.write(180);
delay(1);
//val = analogRead(distancesensor); //reads the value of the distance sensor (value between 0 + 1023)
// myservo.write(val); // sets the servo position according to the scaled value
//delay(1); //waits for the servo to get reach the position
}
the code above is what i was trying to make my thing work with but it didnt work. the sensor was running super slow. i am sitting here waving my yellow flag here. somebody please help!
sincerely,
joanne