Arduino Night Light

by fangying2003 in Circuits > Arduino

206 Views, 0 Favorites, 0 Comments

Arduino Night Light

P_20191222_183051.jpg

this is a very thing to do. You can use it as a tool to help you lights up at night.

Material

P_20191222_102022.jpg

材料:

盒子

led燈

傳輸線

220歐姆

連接線

麵包版

用具:

繪畫用具

剪刀

黏貼用具

Circuit

FB43UTDJZJ0UNCL.LARGE.jpg
P_20191222_102031.jpg

just use three LED and three ome and also three lines to connect.

Program

int yellow = 9;

int green = 8;

void setup() {

pinMode(red, OUTPUT);

pinMode(yellow, OUTPUT);

pinMode(green, OUTPUT);

}

void loop(){

changeLights();

delay(5000);

}

void changeLights(){

// green off, yellow on for 3 seconds //

digitalWrite(green, LOW);

digitalWrite(yellow, HIGH);

delay(3000);

// turn off yellow, then turn red on for 5 seconds //

digitalWrite(yellow, LOW);

digitalWrite(red, HIGH);

delay(5000);

// red and yellow on for 5 seconds (red is already on though)

digitalWrite(yellow, HIGH);

delay(2000);

// turn off red and yellow, then turn on all digitalWrite(yellow, HIGH);

digitalWrite(red, HIGH);

digitalWrite(green, HIGH);

delay(3000); }

外觀

P_20191222_182530.jpg
P_20191222_182536.jpg

分別有兩個重點

一個是要開洞給燈

第二是要開洞讓傳輸線可以穿過去

美化

P_20191222_182552.jpg

可以再箱子上用你喜歡的繪畫用具幫你的箱子做裝飾,畫上你喜歡的圖案,使他看起來更美觀一點

成品

P_20191222_183051.jpg

這樣就完成了,這個作品是很簡單的,就算你是初學者也可以試著做做看