Tinkerkit hall sensor Project

Hello, can you please help us with our code? We are using 2 Tinkerkit hall sensors and need to covert the sensor readings to distances (mm). The closer the magnet gets to each sensor a corresponding LED increases its brightness. This is what we’ve done so far. We’ve spent hours at it and can’t figure out why the LEDs aren’t lighting up or a formula for changing the voltages to distance. Any help would be much appreciated.

const int sensorPin1 = A0;
const int sensorPin2 = A1;
const int ledPin1 = 5;
const int ledPin2 = 3;
int sensorVal1 = 0.0;
int sensorVal2 = 0.0;
int LedVal1 = 0;
int LedVal2 = 0;
float voltage1 = 0.0;
float voltage2 = 0.0;
float distance1 = 0.0;
float distance2 = 0.0;
int ledLevel = 0;

void setup() {
// put your setup code here, to run once:
pinMode (sensorPin1, INPUT);
pinMode (sensorPin2, INPUT);
pinMode (ledPin1, OUTPUT);
pinMode (ledPin2, OUTPUT);
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
sensorVal1 = analogRead(sensorPin1);
sensorVal2 = analogRead(sensorPin2);
voltage1 = (sensorVal1/1023.0)*5;
{
LedVal1=(255/1023)*sensorVal1;
analogWrite(ledPin1,LedVal1);
}
{
voltage2 = (sensorVal2/1023.0)*5;
}
{
LedVal2=((255/1023)*(sensorVal2));
analogWrite(ledPin2,LedVal2);
}
{
Serial.println(voltage1);
Serial.print("the sensor value is:");
Serial.println(voltage2);
Serial.print("the sensor value is:");

delay(1000);
}
}

_2.ino (980 Bytes)

So, you're a student.

Before you posted this, what research did you do about how you should post on the forum?

Before you posted the DUPLICATE of this topic, what research did you do about forum etiquette? (Don't waste your time looking for your duplicate - I deleted it)

I'm sorry I thought there was different forums for sensors and projects so tried to post in both. Didn't mean to offend anyone :confused: