Card Lighting

Introduction: Card Lighting

改自:http://media.nbcmontana.com/Card-Lighting/

這是一個用來裝飾卡片的盒子

Supplies

電線

電阻

LED燈泡

光敏感測器

Arduino

麵包版

Step 1: 上傳程式碼

Arduino cc : https://create.arduino.cc/editor/howard6666/9afbd883-cb18-4347-9286-c015205c5ca9/preview

void setup(){ // put your setup code here, to run once:
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps pinMode( 10 , OUTPUT); // sets the digital pin as output pinMode( 9 , OUTPUT); // sets the digital pin as output pinMode( 8 , OUTPUT); // sets the digital pin as output pinMode( 7 , OUTPUT); // sets the digital pin as output pinMode( 6 , OUTPUT); // sets the digital pin as output pinMode( 5 , OUTPUT); // sets the digital pin as output }

void loop(){ // put your main code here, to run repeatedly: Serial.print(analogRead( A0 )); //print message Serial.print(" "); //print a blank Serial.println(); delay( 20 ); // waits a few milliseconds if ( analogRead( A0 ) > 600 ) { digitalWrite( 10 , LOW ); // sets the digital pin on/off digitalWrite( 9 , LOW ); // sets the digital pin on/off digitalWrite( 8 , LOW ); // sets the digital pin on/off digitalWrite( 7 , LOW ); // sets the digital pin on/off digitalWrite( 6 , LOW ); // sets the digital pin on/off digitalWrite( 5 , LOW ); // sets the digital pin on/off } if ( analogRead( A0 ) < 600 ) { digitalWrite( 10 , HIGH ); // sets the digital pin on/off delay( 500); // waits a few milliseconds 改 digitalWrite( 5 , HIGH ); // sets the digital pin on/off 改 delay( 500 ); // waits a few milliseconds 改 digitalWrite( 9 , HIGH ); // sets the digital pin on/off delay( 500 ); // waits a few milliseconds 改 digitalWrite( 6 , HIGH ); // sets the digital pin on/offe 改 delay( 500 ); // waits a few milliseconds 改 digitalWrite( 8 , HIGH ); // sets the digital pin on/off 改 delay( 500 ); // waits a few milliseconds 改 digitalWrite( 7 , HIGH ); // sets the digital pin on/off 改 delay( 500 ); // waits a few milliseconds 改 digitalWrite( 5 , LOW ); // sets the digital pin on/off digitalWrite( 6 , LOW ); // sets the digital pin on/off digitalWrite( 7 , LOW ); // sets the digital pin on/off digitalWrite( 8 , LOW ); // sets the digital pin on/off digitalWrite( 9 , LOW ); // sets the digital pin on/off digitalWrite( 10 , LOW ); // sets the digital pin on/off delay( 1000 ); // waits a few milliseconds digitalWrite( 5 , HIGH ); // sets the digital pin on/off digitalWrite( 10 , HIGH ); // sets the digital pin on/off 改 delay( 1000 ); // waits a few milliseconds digitalWrite( 6 , HIGH ); // sets the digital pin on/off digitalWrite( 9 , HIGH ); // sets the digital pin on/off 改 delay( 1000 ); // waits a few milliseconds digitalWrite( 7 , HIGH ); // sets the digital pin on/off 改 digitalWrite( 8 , HIGH ); // sets the digital pin on/off 改 delay( 1000 ); // waits a few milliseconds digitalWrite( 7 , LOW ); // sets the digital pin on/off 改 digitalWrite( 8 , LOW ); // sets the digital pin on/off 改 delay( 1000 ); // waits a few milliseconds digitalWrite( 6 , LOW ); // sets the digital pin on/off 改 digitalWrite( 9 , LOW ); // sets the digital pin on/off 改 digitalWrite( 5 , LOW ); // sets the digital pin on/off 改 digitalWrite( 10 , LOW ); // sets the digital pin on/off 改 delay( 1000 ); // waits a few milliseconds digitalWrite( 5 , HIGH ); // sets the digital pin on/off digitalWrite( 6 , HIGH ); // sets the digital pin on/off digitalWrite( 7 , HIGH ); // sets the digital pin on/off digitalWrite( 8 , HIGH ); // sets the digital pin on/off digitalWrite( 10 , HIGH ); // sets the digital pin on/off delay( 1000 ); digitalWrite( 10 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 8 , LOW ); digitalWrite( 7 , LOW ); digitalWrite( 6 , LOW ); digitalWrite( 5 , LOW ); delay( 1000 ); digitalWrite( 10 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 8 , HIGH ); digitalWrite( 7 , HIGH ); digitalWrite( 6 , HIGH ); digitalWrite( 5 , HIGH ); delay( 1000 ); digitalWrite( 10 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 8 , LOW ); digitalWrite( 7 , LOW ); digitalWrite( 6 , LOW ); digitalWrite( 5 , LOW ); delay( 1000 ); digitalWrite( 10 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 8 , HIGH ); digitalWrite( 7 , HIGH ); digitalWrite( 6 , HIGH ); digitalWrite( 5 , HIGH ); delay( 1000 ); digitalWrite( 10 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 8 , LOW ); digitalWrite( 7 , LOW ); digitalWrite( 6 , LOW ); digitalWrite( 5 , LOW ); delay( 1000 ); digitalWrite( 10 , HIGH ); digitalWrite( 5 , LOW ); delay( 500 ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , LOW ); delay( 500 ); digitalWrite( 9 , LOW ); digitalWrite( 8 , HIGH ); delay( 500 ); digitalWrite( 8 , LOW ); digitalWrite( 7 , HIGH ); delay( 500 ); digitalWrite( 7 , LOW ); digitalWrite( 6 , HIGH ); delay( 500 ); digitalWrite( 6 , LOW ); digitalWrite( 5 , HIGH ); delay( 500 ); digitalWrite( 10 , HIGH ); digitalWrite( 5 , LOW ); delay( 500 ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , LOW ); delay( 500 ); digitalWrite( 9 , LOW ); digitalWrite( 8 , HIGH ); delay( 500 ); digitalWrite( 8 , LOW ); digitalWrite( 7 , HIGH ); delay( 500 ); digitalWrite( 7 , LOW ); digitalWrite( 6 , HIGH ); delay( 500 ); digitalWrite( 6 , LOW ); digitalWrite( 5 , HIGH ); delay( 500 ); digitalWrite( 10 , HIGH ); digitalWrite( 5 , LOW ); delay( 200 ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , LOW ); delay( 200 ); digitalWrite( 9 , LOW ); digitalWrite( 8 , HIGH ); delay( 200 ); digitalWrite( 8 , LOW ); digitalWrite( 7 , HIGH ); delay( 200 ); digitalWrite( 7 , LOW ); digitalWrite( 6 , HIGH ); delay( 200 ); digitalWrite( 6 , LOW ); digitalWrite( 5 , HIGH ); delay( 1000 ); digitalWrite( 10 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 8 , HIGH ); digitalWrite( 7 , HIGH ); digitalWrite( 6 , HIGH ); digitalWrite( 5 , HIGH ); delay( 1000 ); digitalWrite( 10 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 8 , LOW ); digitalWrite( 7 , LOW ); digitalWrite( 6 , LOW ); digitalWrite( 5 , LOW ); delay( 1000 ); } else { digitalWrite( 10 , LOW ); // sets the digital pin on/off digitalWrite( 9 , LOW ); // sets the digital pin on/off digitalWrite( 8 , LOW ); // sets the digital pin on/off digitalWrite( 7 , LOW ); // sets the digital pin on/off digitalWrite( 6 , LOW ); // sets the digital pin on/off digitalWrite( 5 , LOW ); // sets the digital pin on/off } }

Step 2: 連接電路

Be the First to Share

    Recommendations

    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Puzzles Challenge

      Puzzles Challenge
    • Lamps Challenge

      Lamps Challenge

    Comments