Skip to content

Input device

For this week we had to deal with input device.

I decided to test an hall effect sensor, needed for my final project.

I began by reading about the sensor. Unfortunately our SMD hall sensor wasn’t included in our last eletronic order… Probably a mistake on our side. But I manage to get a DIP version of the hall sensor.

I tested it onto an arduino board to understand how it work and how to wire it before designing the board.

I tested the board using my embed debug LED

#define LED_PIN 9
#define HALL_PIN 8

#define ENABLE_PIN 0
#define DIR_PIN 1
#define STEP_PIN 2


#include <Wire.h>

long lastBlink = 0;

void requestEvent() {
  Wire.write(byte(digitalRead(HALL_PIN))); // respond with message of 1 bytes
}

void setup(){

  //Wire.begin(8);                // join i2c bus with address #4
  //Wire.onRequest(requestEvent); // register event

  pinMode(LED_PIN, OUTPUT);

  pinMode(HALL_PIN, INPUT_PULLUP);

  pinMode(ENABLE_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);

  digitalWrite(ENABLE_PIN,1);
}


void updateLED(){
  digitalWrite(LED_PIN, digitalRead(HALL_PIN));
}


void loop(){
  updateLED();


}

It works has a charm ! But surprinsingly, the led state is inverted… The led is on when nothing is detected by the hall effect and light on when the magnet is approched.

I’m currently having trouble connecting my board using I2C.


Last update: September 23, 2021