Skip navigation
2012

I am trying to use a hall effect sensor to activate a servo. I want the servo to move to a specific position when the hall effect sensor is activated and then move back when the sensor is deactivated. When I go to the analog read and look at the values I get from the hall effect sensor, the values are 0 when deactivated, but they range from 195-215 when acivated. I think this is why the servo twitches, but im not certain. I think I should have the input read 0 or 1. When he input is 1 the servo should move to this position and move back for values of 0.  Can you help me out? Heres the code I have so far

 

 

 

 

 

 

#include <Servo.h>

 

Servo myservo;  // create servo object to control a servo

 

int inPin = 0;    // select the input pin for the Hall Effect Sensorr

int val;    // variable to read the value from the analog pin

 

void setup()

{

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

}

 

void loop()

{

  val = analogRead(inPin);            // reads the value of the Hall Effect Sensorr (value between 0 and 300)

  val = map(val, 0, 300, 0, 20);     // scale it to use it with the servo (value between 0 and 20)

  myservo.write(val);                  // sets the servo position according to the scaled value

  delay(15);                           // waits for the servo to get there

A new project came out on kickstarter.com that is based on Arduino called Ard-Vark. It is ready to go wifi controlled solution, in a nice case.  You can plug in sensors for inputs and/or servos or DC motors for outputs and control them easily using a mobile app for iPhone or iPad or Android device. With the Ard-Vark you don't have buy an Arduino then a shield for wifi then get the software loaded and then write your own software.  You just set it up on your network and then connect to your smart phone and control it easily.  You can also control it from a web site if you want.

 

Link to the project on kickstarter is http://www.kickstarter.com/projects/694850905/the-ard-vark

 

basedOn05.png

Filter Blog

By date: By tag: