Простая звезда (используются обычные не адресные светодиоды) с различными эффектами. Может быть кому-то пригодится.
Результат можно посмотреть здесь: NY_star - Wokwi ESP32, STM32, Arduino Simulator
Делал давным-давно, в момент, когда до праздника оставалось пол дня, а под рукой были только провода, светодиоды, палата ардуины и 3d ручка (корпус был сделан ручкой).
int BigPins[]={7,8,9,10,11};
int SmallPins[]={2,3,4,5,6};
void setup() {
// Инициализируем цифровой вход/выход в режиме выхода.
// Выход 13 на большинстве плат Arduino подключен к светодиоду на плате.
pinMode(BigPins[0], OUTPUT);
pinMode(BigPins[1], OUTPUT);
pinMode(BigPins[2], OUTPUT);
pinMode(BigPins[3], OUTPUT);
pinMode(BigPins[4], OUTPUT);
pinMode(SmallPins[0], OUTPUT);
pinMode(SmallPins[1], OUTPUT);
pinMode(SmallPins[2], OUTPUT);
pinMode(SmallPins[3], OUTPUT);
pinMode(SmallPins[4], OUTPUT);
}
void loop() {
while (true) {
programm1();
programm2();
programm3();
programm4();
programm5();
programm6();
//programm7();
//programm8();
}
}
void programm1() {
int j;
for (j = 0; j < 10; j = j + 1) {
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
delay (200);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
delay (200);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], HIGH);
delay (500);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
delay (200);
}
}
void programm2() {
int j;
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], LOW);
digitalWrite(SmallPins[i], LOW);
delay (200-15*j-3*i);
digitalWrite(BigPins[i], HIGH);
digitalWrite(SmallPins[i], HIGH);
//digitalWrite(SmallPins[i], LOW);
}
}
}
void programm3() {
int j;
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], HIGH);
digitalWrite(SmallPins[i], HIGH);
delay (43+15*j+3*i);
digitalWrite(BigPins[i], LOW);
digitalWrite(SmallPins[i], LOW);
//digitalWrite(SmallPins[i], LOW);
}
}
}
void programm4() {
int j;
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], HIGH);
digitalWrite(SmallPins[i], HIGH);
delay (200);
}
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], LOW);
digitalWrite(SmallPins[i], LOW);
delay (200);
}
}
}
//спираль
void programm5() {
int j;
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(SmallPins[i], HIGH);
delay (200);
}
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], HIGH);
delay (200);
}
for (i = 0; i < 5; i = i + 1) {
digitalWrite(SmallPins[i], LOW);
delay (200);
}
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[i], LOW);
delay (200);
}
}
}
// путешествие
void programm6() {
int j;
int PaintPins[]={BigPins[0],SmallPins[0],SmallPins[3],BigPins[3],SmallPins[3],SmallPins[1],BigPins[1],SmallPins[1],SmallPins[4],BigPins[4],SmallPins[4],SmallPins[2],BigPins[2],SmallPins[2],SmallPins[0],BigPins[0]};
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 15; i = i + 1) {
int my_case=digitalRead(PaintPins[i]);
switch (my_case){
case HIGH:
digitalWrite(PaintPins[i], LOW);
delay (200);
digitalWrite(PaintPins[i], HIGH);
case LOW:
digitalWrite(PaintPins[i], HIGH);
delay (200);
digitalWrite(PaintPins[i], LOW);
}
}
//delay (200);
}
}
// как бы вращение всей звезды
void programm7() {
int j;
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], LOW);
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], LOW);
delay (200);
digitalWrite(BigPins[i], HIGH);
digitalWrite(SmallPins[i], HIGH);
delay (200);
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
delay (200);
}
}
}
// угол
void programm8() {
int j;
for (j = 0; j < 10; j = j + 1) {
int i;
for (i = 0; i < 5; i = i + 1) {
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], LOW);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], LOW);
delay (500);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], HIGH);
delay (500);
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], LOW);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], LOW);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], HIGH);
delay (500);
digitalWrite(BigPins[0], HIGH);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], LOW);
digitalWrite(BigPins[3], HIGH);
digitalWrite(BigPins[4], LOW);
digitalWrite(SmallPins[0], HIGH);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], LOW);
digitalWrite(SmallPins[3], HIGH);
digitalWrite(SmallPins[4], LOW);
delay (500);
digitalWrite(BigPins[0], LOW);
digitalWrite(BigPins[1], HIGH);
digitalWrite(BigPins[2], HIGH);
digitalWrite(BigPins[3], LOW);
digitalWrite(BigPins[4], HIGH);
digitalWrite(SmallPins[0], LOW);
digitalWrite(SmallPins[1], HIGH);
digitalWrite(SmallPins[2], HIGH);
digitalWrite(SmallPins[3], LOW);
digitalWrite(SmallPins[4], HIGH);
delay (500);
}
}
}