Answer the question
In order to leave comments, you need to log in
How does this Arduino code work?
There is the following scheme:
The code was not written by me, I do not understand and do not plan to use Arduino. Please help me just to understand how the following code works, because it is very important:
const int data = 2;
const int store = 3;
const int shift = 4;
int potiValue;
// column counter
int j = 0;
// showDuration counter
int k;
int row[8] = {127, 191, 223, 239, 247, 251, 253, 254};
// Smiley Happy
int columnH[8] = {60, 66, 165, 129, 165, 153, 66, 60};
// Smiley Normal
int columnN[8] = {60, 66, 165, 129, 129, 189, 66, 60};
// Smiley Sad
int columnS[8] = {60, 66, 165, 129, 153, 165, 66, 60};
void setup()
{
Serial.begin(9600);
// 74HC595
pinMode(data, OUTPUT); // data
pinMode(store, OUTPUT); // store
pinMode(shift, OUTPUT); // shift
pinMode(13, OUTPUT);
}
void poti()
{
potiValue = analogRead(0);
}
void happy()
{
for(k = 0; k<100; k++)
{
for(int i=0; i<8; i++)
{
digitalWrite(store, LOW);
shiftOut(data, shift, LSBFIRST, columnH[j]);
shiftOut(data, shift, LSBFIRST, row[i]);
digitalWrite(store, HIGH);
j++;
poti();
delay(potiValue);
}
j = 0;
}
}
void normal()
{
for(k = 0; k<100; k++)
{
for(int i=0; i<8; i++)
{
digitalWrite(store, LOW);
shiftOut(data, shift, LSBFIRST, columnN[j]);
shiftOut(data, shift, LSBFIRST, row[i]);
digitalWrite(store, HIGH);
j++;
poti();
delay(potiValue);
}
j = 0;
}
}
void sad()
{
for(k = 0; k<100; k++)
{
for(int i=0; i<8; i++)
{
digitalWrite(store, LOW);
shiftOut(data, shift, LSBFIRST, columnS[j]);
shiftOut(data, shift, LSBFIRST, row[i]);
digitalWrite(store, HIGH);
j++;
poti();
delay(potiValue);
}
j = 0;
}
}
void loop()
{
happy();
normal();
sad();
}
Answer the question
In order to leave comments, you need to log in
As it is written in the code, it works :)
It would be easier to explain to you what you are interested in if your ultimate goal was known.
And then I want to understand how it works, but I don’t want to understand how it works and I don’t plan to :)
The code was not written by me, I do not understand and do not plan to use Arduino.You follow the link in the header: https://freelansim.ru/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question