Thursday, June 9, 2011

Hello hall sensor

Got the Hall Effect Sensor working. This is the code it's using. The other gotcha for me was wiring it up right -- took awhile to see the teeny tiny notations in the specs that tell you the wires are V, Ground and Signal read from left to right with the printing facing up. Feed signal wire into input 2 on the arduino (one of the two available interrupt pins). Also the Arduino sketch wasn't compiling until I put the pin information inside the (setup) section, but I think that's just me not understanding rules for declaring variables and such.

Here's what worked:
void setup()
{
pinMode(2, INPUT); //set the interrupt0 pin2 to input
digitalWrite(2, HIGH); // and enable it's internal pull-up resistor
Serial.begin(9600);
and so on.

This adds some useful options for position control on an otherwise simple gear motor.

No comments:

Post a Comment