ARDUINO VGA подсветка монитора или телевизора

AlexBAN

✩✩✩✩✩✩✩
12 Сен 2020
18
0
#define VGA_13_H 3
#define VGA_14_V 2

Применил вот этот пример
C++:
#define READ_PIN 2
void setup() {
  Serial.begin(9600);
}
bool flag = false;
uint32_t tmr;
void loop() {
  bool state =  digitalRead(READ_PIN);
  if (state && !flag) {   // фронт LOW-HIGH
    flag = true;
    tmr = micros();
  }
  if (!state && flag) {   // фронт HIGH-LOW
    flag = false;
    // выводим период
    Serial.println(micros() - tmr);
  }
}
108
112
108
112
108
112
112
112
108
108
112
108
112
112
112
112
112
112
112
112
112
112
112
108
108
112
112
112
108
112
C++:
[code]

#define READ_PIN 3
void setup() {
  Serial.begin(9600);
}
bool flag = false;
uint32_t tmr;
void loop() {
  bool state =  digitalRead(READ_PIN);
  if (state && !flag) {   // фронт LOW-HIGH
    flag = true;
    tmr = micros();
  }
  if (!state && flag) {   // фронт HIGH-LOW
    flag = false;
    // выводим период
    Serial.println(micros() - tmr);
  }
}
[/CODE]


8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
16
8
8
8
8
8
8
8
8
8
Так и не понял результатов
Для следующего примера так
C++:
[code]

#define READ_PIN 2
void setup() {
  Serial.begin(9600);
}
bool flag = false;
uint32_t tmr;
int counter = 0;
void loop() {
  bool state =  digitalRead(READ_PIN);
  if (state && !flag) {   // фронт LOW-HIGH
    flag = true;
    counter++;
  }
  if (!state && flag) {   // фронт HIGH-LOW
    flag = false;
  }
  if (millis() - tmr >= 500) {
    long prd = (millis() - tmr) / counter;
    counter = 0;
    Serial.println(prd);  // в миллисекундах
    tmr = millis();
  }
}
[/CODE]
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16

C++:
[code]

#define READ_PIN 3
void setup() {
  Serial.begin(9600);
}
bool flag = false;
uint32_t tmr;
int counter = 0;
void loop() {
  bool state =  digitalRead(READ_PIN);
  if (state && !flag) {   // фронт LOW-HIGH
    flag = true;
    counter++;
  }
  if (!state && flag) {   // фронт HIGH-LOW
    flag = false;
  }
  if (millis() - tmr >= 500) {
    long prd = (millis() - tmr) / counter;
    counter = 0;
    Serial.println(prd);  // в миллисекундах
    tmr = millis();
  }
}
[/CODE]

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
 

Старик Похабыч

★★★★★★★
14 Авг 2019
4,159
1,267
Москва
1) Отображение всего кадра идет при низком или высоком сигнал VS ?
2) Отображение всего линии идет при низком или высоком сигнал HS ?
digitalRead медленная функция, и тут не подходит , надо читать непосредственно регистры.

1-ый пример. 110 мкс. это 9 090 раз в секунду выходит. 9кгц, не понятно.Если это отрезок между кадрами, то может быть.
То, что у вас на скриншотах осциллографа и в описании ниже вроде по разному выходит.
 

AlexBAN

✩✩✩✩✩✩✩
12 Сен 2020
18
0
Осциллограммы это на входах
Широкий импульс Vs
Пачка коротких Hs
Переписал код в матрицу по строкам
C++:
[code]
#include <Adafruit_NeoPixel.h>
int R,G,B,H,V = 0;
#define PIN 6
//#define VGA_13_H 3
//#define VGA_14_V 2

#define NUMPIXELS 79
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int VGA_1_R = A0;
int VGA_2_G = A1;
int VGA_3_B = A2;

//int VGA_14_V = 2;
//int VGA_13_H = 3;





 


void setup() {
 pinMode(A0,INPUT);
 pinMode(A1,INPUT);
 pinMode(A2,INPUT);

 pinMode(3, INPUT);
 pinMode(2, INPUT);



 Serial.begin(9600);
 strip.begin();
 
 strip.show();
}
void loop() {
 
R  = map( analogRead(A0), 0, 820, 0, 255);
G  = map(analogRead(A1), 0, 820, 0, 255);
B  = map( analogRead(A2), 0, 820, 0, 255);
//H  = digitalRead(3);                                                                           
//V  = digitalRead(2);



 //Serial.print("r= ");
 //Serial.println( R);
// Serial.print("g= ");
// Serial.println(G);
// Serial.print("b= ");
// Serial.println( B);
// Serial.println(H );
// Serial.println(V );
 
 
 
 for (int i =0 ; i < 25 ; i++ ) {

int Matrix0[25] =         {27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
    
    strip.setPixelColor( Matrix0[i], R,G,B);
  
 } 
  
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix1[2] =         {26,52};
  
    strip.setPixelColor( Matrix1[i], R,G,B);
    
 }   
    strip.show();
 
                            

 for (int i =0 ; i < 2; i++ ) {
int Matrix2[2] =         {25,53};
  
    strip.setPixelColor( Matrix2[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix3[2] =         {24,54};
  
    strip.setPixelColor( Matrix3[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix4[2] =         {23,55};
  
    strip.setPixelColor( Matrix4[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix5[2] =         {22,56};
  
    strip.setPixelColor( Matrix5[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix6[2] =         {21,57};
  
    strip.setPixelColor( Matrix6[i], R,G,B);
 }   
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix7[2] =         {20,58};
  
    strip.setPixelColor( Matrix7[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix8[2] =         {19,59};
  
    strip.setPixelColor( Matrix8[i], R,G,B);
 }   
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix9[2] =         {18,60};
  
    strip.setPixelColor( Matrix9[i], R,G,B);
 }   
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix10[2] =         {17,61};
  
    strip.setPixelColor( Matrix10[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix11[2] =         {16,62};
  
    strip.setPixelColor( Matrix11[i], R,G,B);
 }   
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix12[2] =         {15,63};
  
    strip.setPixelColor( Matrix12[i], R,G,B);
 }     
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix13[2] =         {14,64};
  
    strip.setPixelColor( Matrix13[i], R,G,B);
 }     
    strip.show();                         

  for (int i =0 ; i < 2; i++ ) {
int Matrix14[2] =         {13,65};
  
    strip.setPixelColor( Matrix14[i], R,G,B);
  }   
    strip.show();                         

 for (int i =0 ; i < 2; i++ ) {
int Matrix15[2] =         {12,66};
  
    strip.setPixelColor( Matrix15[i], R,G,B);
 }     
    strip.show();                         

 
for (int i = 0  ; i < 24 ; i++ ) {
 
int Matrix16[24] =         {11,10,9,8,7,6,5,4,3,2,1,0,78,77,76,75,74,73,72,71,70,69,68,67};
  
    strip.setPixelColor( Matrix16[i], R,G,B);
   }   
                          

 strip.show();
  
 
 
}
[/CODE]
 

AlexBAN

✩✩✩✩✩✩✩
12 Сен 2020
18
0
Прошу помочь с кодом VGA подсветки
Код работает но вся лента реагирует на изменение сигналов RGB
Нужно чтобы сигнал H (горизонтальная синхронизация )сдвигал светодиод на один шаг(каждый импульс)по строчно а сигнал V(вертикальная синхронизация)
возвращал в начало
Сигналы H и V уровня TTL с LOW на HIGH частота V - 60 Гц частота H - 45 кГц
V 20200921_104832.jpg20200921_105005.jpg
C++:
[code]
#include <Adafruit_NeoPixel.h>
float R,G,B,H,V = 0;
#define PIN 6
#define NUMPIXELS 79
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(A2,INPUT);

pinMode(3, INPUT);
pinMode(2, INPUT);



// Serial.begin(9600);
strip.begin();
strip.show();
}
void loop() {

R  = map( analogRead(A0), 0, 1023, 0, 255);
G  = map( analogRead(A1), 0, 1023, 0, 255);
B  = map( analogRead(A2), 0, 1023, 0, 255);
H  = digitalRead(3);                                                                          
V  = digitalRead(2);





for (int i = 0; i < 79 ;  i++) {
 
int Matrix[79] =         {27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
                          26,                                                                     52,
                          25,                                                                     53,
                          24,                                                                     54,
                          23,                                                                     55,
                          22,                                                                     56,
                          21,                                                                     57,
                          20,                                                                     58,
                          19,                                                                     59,
                          18,                                                                     60,
                          17,                                                                     61,
                          16,                                                                     62,
                          15,                                                                     63,
                          14,                                                                     64,
                          13,                                                                     65,
                          12,                                                                     66,
                          11,10,9,8,7,6,5,4,3,2,      1,      0, 78,77,76,75,74,73,72,71,70,69,68,67} ;
                 
     
  strip.setPixelColor( Matrix[i], R,G,B);

}

  strip.show();
}
[/CODE]
 
Изменено: