Hallsensor read by arduino analogread

Hi, I need some help. I try to use hall sensor that include in BLDC motor but the value of it goes crazy. I didn't know what's reason of it.

const int hallPinA = A0;
const int hallPinB = A1;
const int hallPinC = A2;
int hallA;
int hallB;
int hallC;

void setup() {
//pinMode(hallPinA,INPUT);
//pinMode(hallPinB,INPUT);
//pinMode(hallPinC,INPUT);
Serial.begin(9600);
}

void loop() {
hallA = analogRead(hallPinA);
hallB = analogRead(hallPinB);
hallC = analogRead(hallPinC);

Serial.print("A : ");
Serial.print(hallA);
Serial.print(" B : ");
Serial.print(hallB);
Serial.print(" C : ");
Serial.println(hallC);
delay(100);
}

-result of monitor

Welcome. Please read:

I, and many others likely, would like to be able to grab your code from your first post and paste it in the IDE. Unfortunately, pasting that screen capture won't work, so please try code tags.
Since there's a good chance you have something miswired, a schematic would also be helpful; also, please see what the How To... has to say about that.

Do you have a model number for the sensor, or for the motor they're included in? I'm wondering about the sensor output type. Without that, I don't really know if your "wiring" makes sense, nor what your expectations should be for the signal on A0/A1/A2.
Also, since your code isn't controlling the motor, what is? Was it turning fast, slow, ???
Clearly we need to know a bit more to help you.

now, I already just fixed it. the main reason is the 50 hz of power from my charging adapter and another reason is I forgot to do an external pull-up for the Hall sensor signal. I am very glad that you are coming and helping me.

const int hallPinA = A0;
const int hallPinB = A1;
const int hallPinC = A2;
int hallA;
int hallB;
int hallC;

void setup() {
  pinMode(hallPinA,INPUT_PULLUP);
  pinMode(hallPinB,INPUT_PULLUP);
  pinMode(hallPinC,INPUT_PULLUP);
  
  Serial.begin(9600);
}

void loop() {
  hallA = digitalRead(hallPinA);
  hallB = digitalRead(hallPinB);
  hallC = digitalRead(hallPinC);

//  Serial.print("A : ");
  Serial.print(hallA);
//  Serial.print(" B : ");
  Serial.print(hallB);
  Serial.println(hallC);
  delay(100);
}

this code for checking state in 3 digit of hall sensor and this is the motor.
Chihai Motor Chb-bldc3650 Dc 24v 8000rpm 36mm High Speed Long Life Dc Brushless Motor For Electrical Tools And Robots - Buy 36mm High Speed Dc Brushless Motor,High Precision Long Life Brushless Motor,Dc Brushless Motor 24v With Built-in Hall Drive Product on Alibaba.com

So this topic is solved, then?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.