+++ /dev/null
-const int ledPin = 12;
-int cnt = 0;
-
-void setup() {
- Serial.begin(9600);
- pinMode(ledPin, OUTPUT);
-}
-
-void loop() {
- cnt ++;
-
- int lv = analogRead(0); // Light
-
- delay(1);
-
- if(cnt % 10 == 0)
- {
- Serial.print("Light Sensor Value: ");
- Serial.println(lv);
- }
-
- if(lv < 400)
- {
- digitalWrite(ledPin, HIGH);
- }
- else
- {
- digitalWrite(ledPin, LOW);
- }
-
-}
+++ /dev/null
-const int LedPins[] = {8, 9, 10, 11, 12};
-const int cnt = 5;
-void setup() {
- int i;
- for(i=0; i<cnt; ++i)
- {
- pinMode(LedPins[i], OUTPUT);
- }
-}
-
-static int curt = 0;
-
-void loop() {
- int i;
- for(i=0; i<cnt; ++i)
- {
- int ledPin = LedPins[i];
-
- if(i == curt)
- {
- digitalWrite(ledPin, LOW);
- }
- else
- {
- digitalWrite(ledPin, HIGH);
- }
- }
-
- curt = ++curt % cnt;
- delay(200);
-}
-
+++ /dev/null
-
-const int ledPin = 12;
-int cnt = 0;
-
-void setup() {
- Serial.begin(9600);
- pinMode(ledPin, OUTPUT);
-}
-
-void loop() {
- cnt ++;
-
- int lv = analogRead(0); // Light
-
- int tv = analogRead(1); // Temperature
-
- delay(100);
-
- float temperature;
- float resistance = (float)(1023-tv)*10000/tv;
- temperature = 1/(log(resistance/10000)/3975+1/298.15) - 273.15;
- if(cnt % 10 == 0)
- {
- Serial.print("Light Sensor Value: ");
- Serial.println(lv);
-
- Serial.print("Temperature Sensor Value: ");
- Serial.println(tv);
-
- Serial.print("Temperature: ");
- Serial.println(temperature);
- }
-
- if(lv < 400)
- {
- digitalWrite(ledPin, HIGH);
- }
- else
- {
- digitalWrite(ledPin, LOW);
- }
-
-}