You are on page 1of 4

1

Led encedido------------------------

// Pin 13 has an LED connected on most Arduino boards.

// give it a name:

int ledred = 13;

int ledgreen = 12;

int ledblue = 11;

int switchPin = 0;

int switchState = LOW;

int delayTime =500;

// the setup routine runs once when you press reset:

void setup() {

// initialize the digital pin as an output.

pinMode(ledred, OUTPUT);

pinMode(ledgreen, OUTPUT);

pinMode(ledblue, OUTPUT);

pinMode (switchPin, INPUT);

// the loop routine runs over and over again forever:

void loop()

switchState = digitalRead(switchPin);

if (switchState == LOW)

delayTime = 500;

}
else

delayTime =250;

digitalWrite(ledred, HIGH); // turn the LED on (HIGH is the voltage level)

delay(delayTime); // wait for a second

digitalWrite(ledred, LOW); // turn the LED off by making the voltage LOW

delay(delayTime); // wait for a second

digitalWrite(ledgreen, HIGH); // turn the LED on (HIGH is the voltage level)

delay(delayTime); // wait for a second

digitalWrite(ledgreen, LOW); // turn the LED off by making the voltage LOW

delay(delayTime);

digitalWrite(ledblue, HIGH); // turn the LED on (HIGH is the voltage level)

delay(delayTime); // wait for a second

digitalWrite(ledblue, LOW); // turn the LED off by making the voltage LOW

delay(delayTime);

int pwmPin =11;

int pwm =0;

void setup()

pinMode(pwmPin, OUTPUT);

void loop()

pwm = analogRead(A0) / 4;
analogWrite(pwmPin,pwm);

delay(500);

#include <SoftwareSerial.h>

#define sensorLight = analogRead(A0);

#define sensorTemp = analogRead(A1);

int light;

int celsius;

void setup()

Serial.begin(9600);

void loop()

light = (analogRead(A0) - 46) / 9.1;

celsius = analogRead(A1) * 0.14 - 23;

Serial.print("Light = ");

Serial.print(light);

Serial.print(", Temp = ");

Serial.print(celsius);

Serial.println(" C");

if (light < 21) Serial.print("Stormy");

else if (light < 41) Serial.print("Cloudy");

else if (light < 61) Serial.print("Partly cloudy");


else if (light < 81) Serial.print("Partly sunny");

else Serial.print("Sunny");

Serial.print(" and ");

if (celsius < 5) Serial.println("cold");

else if (celsius < 17) Serial.println("cool");

else if (celsius < 27) Serial.println("mild");

else if (celsius < 38) Serial.println("warm");

else Serial.println("hot");

delay(1000);

You might also like