xuKKLCDjl6

Bagua Lamp | Lighting Design | Lichuang Panel Printing

 
Overview

Write an introduction. I made a Bagua lamp that stops randomly. The program is very simple and can be used to learn.
The panels were printed very well at Galicon! ! !
Effect: https://www.bilibili.com/video/BV1YW4y1R7Gu/?spm_id_from=333.337.search-card.all.click
 
 
The program is as follows:
// Define the corresponding relationship between the 74HC595 chip pins and the Arduino pins #define DS 8# OE 7#define STCP 6#define SHCP 5
// Define the data to be output byte data[] = { 0b11111110, 0b01111111, 0b10111111, 0b11011111, 0b11101111, 0b11111101, 0b11111011, define 0b1111 0111,};


void setup() {randomSeed(analogRead (0)); // Initialize the 74HC595 chip pin pinMode(DS, OUTPUT); pinMode(OE, OUTPUT); pinMode(STCP, OUTPUT); pinMode(SHCP, OUTPUT); pinMode(2, INPUT_PULLUP); // Close Output enable digitalWrite(OE, LOW);

        for (int i = 0; i < 8; i++) { digitalWrite(STCP, LOW); shiftOut(DS, SHCP, MSBFIRST, 0xff); digitalWrite(STCP, HIGH); } }

void loop() { // High-speed loop for 3 seconds if (digitalRead(2) == 0) { int stop = random(8); // Define at which light to stop for (int a = 0; a < 11; a++) { for (int i = 0; i < 8; i++) { digitalWrite(STCP, LOW); shiftOut(DS, SHCP, MSBFIRST, data[i]); digitalWrite(STCP, HIGH); delay(a * 10); } if (a == 10) { for (int a = 1; a < 6; a++) { for (int i = 0; i < 8; i++) { digitalWrite(STCP, LOW); shiftOut( DS, SHCP, MSBFIRST, data[i]); digitalWrite(STCP, HIGH); delay(a * 100); } } for (int loop_end = 1; loop_end < 9; loop_end++) { if (loop_end == stop) { digitalWrite(STCP, LOW); shiftOut(DS, SHCP, MSBFIRST, data[stop - 1]); digitalWrite(STCP, HIGH); break; } else { digitalWrite(STCP, LOW); shiftOut(DS, SHCP, MSBFIRST, data[loop_end - 1]); digitalWrite(STCP, HIGH); delay(600); } } } } }}
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-14 11:18:18

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号