hello, I'm trying to make a LED POV, I try to draw a circle, but this
never closes. that I can be doing wrong?
Thank you!
volatile long timeold;
volatile unsigned long new_time = 0;
volatile float refreshEnd = 0;
volatile float Refresh = 0;
volatile float milliperrevolution = 0;
volatile uint8_t revolutions=0;
volatile boolean interruptHit = false;
void setup() {
pinMode(2, INPUT); //
attachInterrupt(0, rpm, FALLING);// attachInterrupt(0, rpm, FALLING) pin 2 Arduino---- : hall sensor
pinMode(13, OUTPUT);
digitalWrite(13, 0); // set the LED off
}
void loop() {
if( interruptHit ==true){
digitalWrite(13, HIGH); // set the LED
new_time = millis();
refreshEnd=new_time;
while((millis() - refreshEnd)<= (Refresh ) ) {;}
interruptHit =false;
}else{
digitalWrite(13, LOW); // set the LED
}
}
void rpm(){
revolutions++;
interruptHit=true;
if (revolutions == 2) // RPM gets updated for every two complete rotations
{
new_time=millis();
milliperrevolution = (( new_time - timeold)/2);
timeold = new_time;
revolutions = 0;
Refresh = milliperrevolution/1;
}
}