IOT Experiment -2
LED INTENSITY VARIATION
SORCE CODE:
void Setup()
{
// initialize digital pin 5,6,7 & 8 as an output.
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
}
void Loop()
{
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(500);
int red_light_pin= 7;
int green_light_pin = 6;
int blue_light_pin = 5;
int count = 0;
void setup() {
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);
}
void loop()
{
if (count >= 0 && count<=100)
{
RGB_color(255, 0, 255); // Yellow
delay(50);
count++;
}
else if (count >= 101 && count<=200)
{
RGB_color(0, 0, 255); // Green
delay(50);
count++;
}
else
{
RGB_color(255,0 , 0); // Red
delay(50);
count++;
}
}
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
digitalWrite(red_light_pin, red_light_value);
digitalWrite(green_light_pin, green_light_value);
digitalWrite(blue_light_pin, blue_light_value);
}
{
// initialize digital pin 5,6,7 & 8 as an output.
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
}
void Loop()
{
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(500);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
delay(500);
int red_light_pin= 7;
int green_light_pin = 6;
int blue_light_pin = 5;
int count = 0;
void setup() {
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);
}
void loop()
{
if (count >= 0 && count<=100)
{
RGB_color(255, 0, 255); // Yellow
delay(50);
count++;
}
else if (count >= 101 && count<=200)
{
RGB_color(0, 0, 255); // Green
delay(50);
count++;
}
else
{
RGB_color(255,0 , 0); // Red
delay(50);
count++;
}
}
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)
{
digitalWrite(red_light_pin, red_light_value);
digitalWrite(green_light_pin, green_light_value);
digitalWrite(blue_light_pin, blue_light_value);
}
Comments
Post a Comment