I recently wrote some code for an arduinio to read an encoder and display it via RCA. Problem is, it sometimes freezes on a blank screen when I'm turning the encoder. Any ideas why? the code is below. And yes, I know that the interrupts mess with the signal and it flickers, I want to know why it will stay off whenever the encoder is halfway through a cycle. #include float anaval = 0; float value01 = 0; int val = 1; float value; float value10; float value100; int out; int r = 0; float pos = 0; int rd = 4; float incr = 0.00078125; TVout TV; unsigned char x,y; char i = 48; void setup() { pinMode(2, INPUT); pinMode(7, INPUT); digitalWrite(7, HIGH); digitalWrite(2, HIGH); attachInterrupt(0, encoderPos, CHANGE); x=0; y=0; TV.begin(_NTSC,128,56); //for devices with only 1k sram(m168) use TV.begin(_NTSC,128,56) } void loop() { disp(); // TV.clear_screen(); // TV.print_char(4,4,char(value100)+48); // TV.print_char(10,4,char(value10)+48); // TV.print_char(16,4,char(value)+48); // TV.print_char(22,4,char(value01)+48); } void stringer(){ value01 = val; value = val / 10; value10 = val / 100; value100 = val / 1000; value = int(value);//rounds the variables value10 = int(value10); value100 = int(value100); value01 = int(value01); value01 = value01 - (value * 10);//removes all but the tenths-place digit value = value - (value10 * 10); value10 = value10 - (value100 * 10); } void encoderPos(void){ //this is a state machine to determine the direction of the encoder. //every half-cycle it counts, effectively doubling the encoder resolution. r = 1; disp(); if(digitalRead(2) == HIGH){ if(digitalRead(7) == LOW){ while(r == 1){ disp(); if(digitalRead(2) == LOW){ r = 0; } else { if(digitalRead(7) == HIGH){ pos = pos + incr; r = 0; }}} } else { while(r == 1){ disp(); if(digitalRead(2) == LOW){ r = 0; } else { if(digitalRead(7) == LOW){ pos = pos - incr; r = 0; }}} } }else{//same as the above code, but with High-Low reversed. r = 1; if(digitalRead(7) == HIGH){ while(r == 1){ disp(); if(digitalRead(2) == HIGH){ r = 0; } else { if(digitalRead(7) == LOW){ pos = pos + incr; r = 0; }}} } else { while(r == 1){ disp(); if(digitalRead(2) == HIGH){ r = 0; } else { if(digitalRead(7) == HIGH){ pos = pos - incr; r = 0; }}} } } } void disp(){ val = int(pos * 1000); TV.print_char(4,4,char(value100)+48); TV.print_char(10,4,char(value10)+48); TV.print_char(16,4,char(value)+48); TV.print_char(22,4,char(value01)+48); // TV.delay_frame(1); stringer(); }