I think he wants to see the effect of the hall sensor on the led pin. It wil blink faster or slower depending on the measured value. And only if the value is below 950. For some reason.
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 11; // note onlly 5,6, 9,10,11 are PWM
int wait = 0; // variable to store the value coming from the sensor
void setup() {
// Serial.begin(9600);
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
}
void loop() {
wait = analogRead(potPin) - 28; // read the value from the sensor
if(wait > 950){
digitalWrite(ledPin, LOW);
}else{
digitalWrite(ledPin, HIGH); // turn the ledPin on
delayMicroseconds(1023 - wait); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delayMicroseconds( wait); // stop the program for some time
}
// Serial.println( wait );
}
I think he wants to see the effect of the hall sensor on the led pin. It wil blink faster or slower depending on the measured value. And only if the value is below 950. For some reason.Actually your code doesn't make too much sense. Are you trying to actually create PWM square wave with variable on/off times? You don't need to do this at all. Arduino lets you write a value to PWM output and it will automatically generate appropriate PWM signal based on the value.
I haven't looked at datasheet for your LEM sensor, is it bidirectional? i.e. does it have a zero point somewhere in the middle? If so, you need to calibrate it at first, by reading the input while there is no current and then use that value where you have ( -28 ) now.