Pages: [1]   Go Down
Author Topic: Servo and Ping  (Read 784 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I'm new to arduino and am currently working with a ping sensor and servo. I can get the ping to work and the servo to work with a potentiometer separately but am having a hard time getting them to work together. I just want an if statement that when there's an object within a certain distance then the servo moves. Does anyone have a base code for this that I can get started with. I already have know about the ones that come with the software, but anything that combines the two that I can edit to fit my needs.

Thanks so much!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25861
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I just want an if statement that when there's an object within a certain distance then the servo moves
Code:
if (pingRange () < THRESHOLD_DISTANCE) {
  servo.write (POSITION_ONE);
}
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1]   Go Up
Jump to: