Go Down

Topic: Arduino and HALL sensors problem (Read 935 times) previous topic - next topic

jocoj100

Jan 26, 2013, 12:37 am Last Edit: Jan 26, 2013, 12:08 pm by jocoj100 Reason: 1
Hi!

I'm doing this gear indicator for my motorcyle, but I want to do it using the Arduino.
http://www.electronics-lab.com/projects/automotive/006/index.html

This is my code:
Code: [Select]
int topGear=6;

int upSensor=3;
int downSensor=4;
int nSensor=2;

//These are outputs to 4026
int clk=1;
int reset=0;

//This is the current gear
int gear=0;

void setup()
{
  pinMode(upSensor, INPUT);
  pinMode(downSensor, INPUT); 
  pinMode(nSensor, INPUT);
 
  pinMode(clk, OUTPUT);
  pinMode(reset, OUTPUT);
 
}
int GearUP=0;
int GearDOWN=0;

void loop()
{
  delay(50);
 
  GearUP=digitalRead(upSensor);
  GearDOWN=digitalRead(downSensor);
 
  if(GearUP==LOW)
  {
    if(gear < topGear)
    {
      gear++;     
    }
    else
    {
      gear=0;     
    }
    delay(250);   
  }
  delay(50);
  if(GearDOWN=LOW)
  {
    if(gear>0)
    {
      gear--;     
    }   
   
  }
ShowDigit(gear);
 
}
void ShowDigit(int digit)
{
  if(gear < topGear)
  {
    digitalWrite(reset,HIGH);
   
      for(int i=0;i<digit;i++)
      {
        digitalWrite(clk, HIGH);
        delay(100);
        digitalWrite(clk,LOW);
        delay(100);   
    }
  }
  else
  {
    digitalWrite(reset,HIGH);
  }
 
}


I think that is problem in my reading of Hall effect sensor state, I'm using Attiny85 and A3144 Hall sensors.

I tried basic example of blinking led every second, and everything work's fine, so it isn't problem in micro controller.

Thanks!

Grumpy_Mike

As you have not said what problems you are having with that code is is hard to say what is wrong with it.

jocoj100

Simply, something doesn't work, and I can't realize where is problem. Is my logic of getting state of the hall sensors well written?


PeterH

Write a sketch that does nothing but read from one of the sensors and print the value it gets. Does it display the correct values? If so, do the same for the other sensor. Don't bother worrying about what else might be happening in the sketch until you know that it's reading the sensors correctly.
I only provide help via the forum - please do not contact me for private consultancy.

jocoj100

Problem is that I have Tiny85, on my breadboard and I'm programming it using USBAsp, and I don't know can I establish serial communication between computer and arduino.

But when I connect this hall sensor to 1 pin to 5V, 2 pin to GND, and 3 pin to one probe of my multimeter, and other probe I connect to GND. On my meter it shows about 3 V, and when I put the magnet it shows about 1mV.

Go Up