步驟1:您需要的內(nèi)容。
您將需要:
6個LED(可能還有更多)。
跳線
面包板和/或原型板
第2步:編程。
使用以下代碼對Arduino進(jìn)行編程。
//feel free to make changes
//do not connect led‘s in sequential order
//make sure all led’s are connected to a resistor if applicable
//this project was made and tested using only one wire and arduino‘s pin 13 resistor and LED
//note: pin 5 and 6 act weird in the beginning - an arduino bug
byte led1 = 3;
byte led2 = 5;
byte led3 = 6;
byte led4 = 9;
byte led5 = 10;
byte led6 = 11;
int x = 0;
int y = 0;
int steps = 1; //change if needed, defines the steps between 0 and 255, a lower number is smoother
//make sure the variable “steps” is a factor of 255; any of the below numbers
//factors of 255 are : 1,3,5,15,17,51,85,255
//sorry for a lot of notes, but remember to change variable “delaytime” according to variable “steps”
//delay is in milliseconds for below
int delaytime = 10; //change if needed, delay between increments of PWM
//850 milliseconds is on-off/off-on time, in 17 step increments of brightness
int delaytime2 = 1000; //change if needed, delay between switching of leds
void setup (){
pinMode (led1, OUTPUT);
pinMode (led2, OUTPUT);
pinMode (led3, OUTPUT);
pinMode (led4, OUTPUT);
pinMode (led5, OUTPUT);
pinMode (led6, OUTPUT);
do {
x = x + steps;
analogWrite (led1, x);
analogWrite (led2, x);
delay (delaytime);
}
while (x != 255);
}
void loop (){
y = 0;
x = 255;
delay (delaytime);
do{
y = y + steps;
x = x - steps;
analogWrite (led3, y);
analogWrite (led1, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
y = 0;
x = 255;
do{
y = y + steps;
x = x - steps;
analogWrite (led4, y);
analogWrite (led2, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
y = 0;
x = 255;
do{
y = y + steps;
x = x - steps;
analogWrite (led5, y);
analogWrite (led3, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
y = 0;
x = 255;
do{
y = y + steps;
x = x - steps;
analogWrite (led6, y);
analogWrite (led4, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
y = 0;
x = 255;
do{
y = y + steps;
x = x - steps;
analogWrite (led1, y);
analogWrite (led5, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
y = 0;
x = 255;
do{
y = y + steps;
x = x - steps;
analogWrite (led2, y);
analogWrite (led6, x);
delay (delaytime);
}
while (y != 255 && x != 0);
delay (delaytime2);
}
第3步:電路。
每個LED并將其連接到面包板的接地導(dǎo)軌。將正極引線連接到Arduino的引腳3、5、6、9、10、11。
步驟4:漸隱!
現(xiàn)在,LED應(yīng)該以偽隨機(jī)的方式褪色。您已完成,但對于印象深刻的人,請單擊“下一步”。
步驟5:下沉和采購。
這是我如何教授下沉和源的方法。
下沉是指從輸出引腳到地。所謂采購,是指從正極到輸出引腳。
這樣想。電源可以從LED流向源極。在下沉?xí)r,電源來自引腳。電源始終由引腳提供,因此,當(dāng)引腳變?yōu)楦唠娖綍r,電流會“通過” LED到達(dá)引腳,從而將其關(guān)閉。
對于大多數(shù)人來說,他們應(yīng)該說:“這有什么區(qū)別? “
對一個隨機(jī)的人moi來說,它的意思是:“我可以反轉(zhuǎn)信號,從而產(chǎn)生更大的隨機(jī)性!”
請記住,避免使用電阻器(有生命危險)從3.3伏特為其供電。 p》
第6步:這樣做。..
現(xiàn)在取第3針作為源。
取第6針作為源。
取第9針作為源。
然后取第11針作為源。
將其余的留在原處。
第7步:確實完成。
現(xiàn)在,可以實現(xiàn)隨機(jī)效果(讓我惡作劇的時間)(借口) -moi 。.. BWA-HA-HAHA-HA!)點擊完成。
-
led
+關(guān)注
關(guān)注
242文章
23362瀏覽量
663236 -
Arduino
+關(guān)注
關(guān)注
188文章
6477瀏覽量
187837
發(fā)布評論請先 登錄
相關(guān)推薦
如何使用Arduino實現(xiàn)CAN總線通信呢
ADC12DJ3200采樣數(shù)據(jù)在FPGA端隨機(jī)性出現(xiàn)錯點,是什么原因?
如何使用Arduino實現(xiàn)CAN總線通信
淺談分布式電源和電動汽車的配電網(wǎng)可靠性評估
![淺談分布式電源和電動汽車的配電網(wǎng)可靠<b class='flag-5'>性</b>評估](https://file1.elecfans.com/web2/M00/EB/95/wKgZomZevfiAZTUiAAAYyNC3ogI340.png)
閃存隨機(jī)讀寫與連續(xù)讀寫哪個重要
快速啟停!AEM在新能源制綠氫應(yīng)用中的適配性。
![快速啟停!AEM在新能源制綠氫應(yīng)用中的適配<b class='flag-5'>性</b>。](https://file1.elecfans.com/web1/M00/F2/B6/wKgZoWcIz2mAC2ABAAS11_H534Y024.png)
arduino(1)--ESP8266配置
如何在FPGA中實現(xiàn)隨機(jī)數(shù)發(fā)生器
![如何在FPGA中<b class='flag-5'>實現(xiàn)</b><b class='flag-5'>隨機(jī)</b>數(shù)發(fā)生器](https://file1.elecfans.com/web2/M00/00/BC/wKgZomaxl4GARcE_AABd2Ri4k-Q825.png)
【Vision Board創(chuàng)客營連載體驗】利用 OpenMV 實現(xiàn) AprilTag 跟蹤以及通過串口通訊控制 Arduino 驅(qū)動 LED 燈帶
STM32H750 LTDC顯存開辟在外部SDRAM里面,會出現(xiàn)隨機(jī)性閃屏為什么?
什么是隨機(jī)森林?隨機(jī)森林的工作原理
![什么是<b class='flag-5'>隨機(jī)</b>森林?<b class='flag-5'>隨機(jī)</b>森林的工作原理](https://file1.elecfans.com/web2/M00/C4/C5/wKgZomX332iAL6VsAAAj4bOxHOI608.png)
用于Arduino的BLDC-SHIELD_IFX007T,主LED發(fā)出耀眼的白色是什么意思?
如何使用Arduino控制RGB LED
![如何使用<b class='flag-5'>Arduino</b>控制RGB <b class='flag-5'>LED</b>](https://file1.elecfans.com/web2/M00/BD/9A/wKgZomWsgJSADUYTAACUfhOkAto400.png)
如何連接Arduino聲音傳感器以控制帶有聲音的LED
![如何連接<b class='flag-5'>Arduino</b>聲音傳感器以控制帶有聲音的<b class='flag-5'>LED</b>](https://file1.elecfans.com/web2/M00/BD/9A/wKgZomWsf1eAAO8pAACHNmz4jUE646.png)
評論