Hi guys, I am working on a project that lets you control lines on a CRT TV via ribbon potentiometers.
The lines on the screen are made from pulses from the output pins and synced with specific timings to work on a PAL CRT.
in my code, i want to be able to change the value of the delay that the pins are working on screen 1, however i think i need a const to use '_delay_us' and fro mthere i cant figure out any way to really change the value with the potentiometer? here is my code, hope you can help.
//Incorporate the delay library
#include <util/delay.h>
// Set and define the synchronization signal and three-color output
#define SYNC (PORTB = B00000000)
#define WHITE (PORTB = B00000011)
#define BLACK (PORTB = B00000001)
#define GRAY (PORTB = B00000010)
int readValue = 0;
volatile int value = 3025;
int potselect = A5;
void setup () {
// Set pins 8, 9 and 10 to digital output
// It is also possible to write DDRB = B00000011;
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
Serial.begin(115200);
}
void loop () {
readValue = analogRead(A5);
Serial.print("A5 = ");
Serial.print(readValue);
Serial.println();
// Sync, front and back margin settings
BLACK;
_delay_us (4);
SYNC;
_delay_us (5);
BLACK;
_delay_us (5) ;
// Screen display 1
WHITE;
_delay_us (3025); //these values must be changed via the ribbon pots
BLACK;
_delay_us (3025);
GRAY;
_delay_us (3025);
Serial.print("A5 = ");
Serial.print(readValue);
Serial.println();
}