Data such as
À
à
7
4
P
8
•
L
Those 8 x 8 bit can be increased to more like 50 x 50 bit
The data comes through a serial port. It enters the Arduino. How is it powered using a line-by-line shift register with 0.25 millisecond time slots between them?
I don't understand the question.
I want to send an 8 character string, "ABCDEFGH" or something, with each letter corresponding to the on position of an LED
J-M-L
April 18, 2022, 9:12am
5
I would suggest to study Serial Input Basics to handle this
kolaha
April 18, 2022, 9:15am
6
give your sketch. i take a look.
Do you have a spec of what the code should do?
kolaha
April 18, 2022, 10:22am
11
here is your solution
#define SRCLK 13 //clk
#define RCLK 6 //latch
#define SER 11
void setup() {
Serial.begin(115200);
pinMode(SER, OUTPUT);
pinMode(RCLK, OUTPUT);
pinMode(SRCLK, OUTPUT);
}
void loop() {
if (Serial.available() >= 8) {
for (byte i = 0; i < 8; i++)shiftOut(SER, SRCLK, Serial.read());
digitalWrite(RCLK, HIGH);
digitalWrite(RCLK, LOW);
while(Serial.available() > 0) Serial.read();
}
}
kolaha
April 18, 2022, 11:15am
14
anon73444976:
Oops
J-M-L:
Oops3
is it mean I missed something?
You check to see if there's at least one character in the serial buffer, then you go ahead and read all eight of them.
kolaha
April 18, 2022, 11:24am
16
he said 8 symbols should be read. so it is not my problem how he implement it, but after 8 symbols i read out remain charackters (CR&NL)
kolaha:
here is your solution
It's your implementation.
J-M-L
April 18, 2022, 11:35am
18
but you don't know if they are all available....
and you ignore the rest, so may be some of the symbols
kolaha
April 18, 2022, 11:41am
19
yes, it may be CR symbol or NL, but important are only first 8, they can contain char(13) or char(10) and schould be count not as line terminator but as symbol to shift out.
J-M-L
April 18, 2022, 11:43am
20
but you are not guaranteed that 8 bytes were in the buffer with that code
testing with 8 instead of 0 would help
void loop() {
if (Serial.available() >= 8) {
for (byte i = 0; i < 8; i++)shiftOut(SER, SRCLK, Serial.read());
digitalWrite(RCLK, HIGH);
digitalWrite(RCLK, LOW);
while(Serial.read() != -1)); // empty the buffer
}
}
1 Like