Конструкты библиотек в цыкле...неполучается.

Нет ответов
m_veidemanis
Offline
Зарегистрирован: 22.10.2018

Спаял 16 штук 7474HC595 по четире на четире dataPin вихода...всё прекрасно паботает изпользуя <Shift595.h> ..идеально так как хотелось...НО..

Ненравитса дубовый подход типа...



#include <Shift595.h>



#define dataPin0 A0 

#define dataPin1 A3 

#define dataPin2 3 

#define dataPin3 6 



#define latchPin0 A1 

#define latchPin1 A4 

#define latchPin2 4 

#define latchPin3 7 



#define clockPin0 A2 

#define clockPin1 A5 

#define clockPin2 5 

#define clockPin3 8 

#define Sh_R_line 4

int numOfRegisters[]= {4,4,4,4} ; //здесь цыкл возможен был 



Shift595 Sh_R0(dataPin0, latchPin0, clockPin0, numOfRegisters[0]);

Shift595 Sh_R1(dataPin1, latchPin1, clockPin1, numOfRegisters[1]);

Shift595 Sh_R2(dataPin0, latchPin2, clockPin2, numOfRegisters[2]);

Shift595 Sh_R3(dataPin1, latchPin3, clockPin3, numOfRegisters[3]);



void Sh_R0_stop_pin(int i){Sh_R0.setRegisterPin(i-1, LOW);Sh_R0.setRegisterPin(i+7, LOW);}

void Sh_R0_forward(int i){Sh_R0.setRegisterPin(i-1, HIGH);Sh_R0.setRegisterPin(i+7, LOW);}

void Sh_R0_reverse(int i){Sh_R0.setRegisterPin(i-1, LOW);Sh_R0.setRegisterPin(i+7, HIGH);}



void Sh_R1_stop_pin(int i){Sh_R1.setRegisterPin(i-1, LOW);Sh_R1.setRegisterPin(i+7, LOW);}

void Sh_R1_forward(int i){Sh_R1.setRegisterPin(i-1, HIGH);Sh_R1.setRegisterPin(i+7, LOW);}

void Sh_R1_reverse(int i){Sh_R1.setRegisterPin(i-1, LOW);Sh_R1.setRegisterPin(i+7, HIGH);}



void Sh_R2_stop_pin(int i){Sh_R2.setRegisterPin(i-1, LOW);Sh_R2.setRegisterPin(i+7, LOW);}

void Sh_R2_forward(int i){Sh_R2.setRegisterPin(i-1, HIGH);Sh_R2.setRegisterPin(i+7, LOW);}

void Sh_R2_reverse(int i){Sh_R2.setRegisterPin(i-1, LOW);Sh_R2.setRegisterPin(i+7, HIGH);}



void Sh_R3_stop_pin(int i){Sh_R0.setRegisterPin(i-1, LOW);Sh_R3.setRegisterPin(i+7, LOW);}

void Sh_R3_forward(int i){Sh_R0.setRegisterPin(i-1, HIGH);Sh_R3.setRegisterPin(i+7, LOW);}

void Sh_R3_reverse(int i){Sh_R0.setRegisterPin(i-1, LOW);Sh_R3.setRegisterPin(i+7, HIGH);}





а дальше только так...



наверно есть лучще способ?