Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Close

Yoga x breathing | Electronics Lab

Yoga x breathing
Version 1 - Last update: Oct 4, 2015

Breathing lights mix Yoga

11/20 team works

int ledPin =11; // LED connected to digital pin 11 int photocellPin = 2; // 光敏電阻 (photocell) 接在 anallog pin 2 int photocellVal = 0; // photocell variable int minLight = 400; // 最小光線門檻值 int ledState = 0; int fadeAmount = 5;

void setup() { pinMode(ledPin, OUTPUT); Serial.begin(9600); }

void loop() { // 讀取光敏電阻並輸出到 Serial Port photocellVal = analogRead (photocellPin); Serial.println (photocellVal); // 光線不足時打開 LED if (photocellVal = 0; fadeValue -=5) { analogWrite (ledPin, fadeValue); // sets the value (range from 0 to 255): delay (75); // wait for 75 milliseconds to see the dimming effect } } // 光線充足時關掉 LED else (photocellVal > minLight && ledState == 1); analogWrite (ledPin, LOW); // turn off LED ledState = 0;

delay (600); }

Comments disabled