LINA MTALKA
const int red_led_pin=3; // red led light is attached
const int yellow_led_pin=4;
const int green_led_pin=5;
void setup() {
// put your setup code here, to run once:
pinMode(red_led_pin, OUTPUT);
pinMode(yellow_led_pin, OUTPUT);
pinMode(green_led_pin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(600); // long break at the end
digitalWrite(red_led_pin, HIGH);
delay(100); //red led is turning on
digitalWrite(red_led_pin, LOW); //red led is turning off
delay(100); //red led is flickering fast - 100 milisecond
digitalWrite(yellow_led_pin, HIGH); //yellow led is turning on
delay(100);
digitalWrite(yellow_led_pin, LOW);
delay(100); //yellow led is flickering fast - 100 milisecond
digitalWrite(green_led_pin, HIGH);
delay(100);
digitalWrite(green_led_pin, LOW);
//green led is flickering fast - 100 milisecond
}
EX 20/03
//The leds are connected to pins 3,4,5;
const int Red_led = 3;
const int Yellow_led = 4;
const int Green_led = 5;
//The paremeter is connected to pin A0:
const int Poten_pin = A0;
//Define veriables to contain data:
int poten_val;
int rhythm;
void setup() {
//Put your setup code here, to run once:
Serial.begin(9600);
pinMode(Red_led, OUTPUT);
pinMode(Yellow_led, OUTPUT);
pinMode(Green_led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
poten_val = analogRead(Poten_pin);
Serial.println(poten_val);
rhythm = map(poten_val , 0, 1023, 100, 500);
//Turn on RED
digitalWrite(Red_led, HIGH);
digitalWrite(Yellow_led, LOW);
digitalWrite(Green_led, LOW);
delay(rhythm);
//Turn on YELLOW
digitalWrite(Red_led, LOW);
digitalWrite(Yellow_led, HIGH);
digitalWrite(Green_led, LOW);
delay(rhythm);
//Turn on GREEN
digitalWrite(Red_led, LOW);
digitalWrite(Yellow_led, LOW);
digitalWrite(Green_led, HIGH);
delay(rhythm);
}
//The leds are connected to pins 3,4,5;
const int Red_led = 3;
const int Yellow_led = 4;
const int Green_led = 5;
//The paremeter is connected to pin A0:
const int Poten_pin = A0;
//Define veriables to contain data:
int poten_val;
int rhythm;
void setup() {
//Put your setup code here, to run once:
Serial.begin(9600);
pinMode(Red_led, OUTPUT);
pinMode(Yellow_led, OUTPUT);
pinMode(Green_led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
poten_val = analogRead(Poten_pin);
Serial.println(poten_val);
rhythm = map(poten_val , 100, 660, 50, 500);
//Turn on RED
digitalWrite(Red_led, HIGH);
digitalWrite(Yellow_led, LOW);
digitalWrite(Green_led, LOW);
delay(rhythm);
//Turn on YELLOW
digitalWrite(Red_led, LOW);
digitalWrite(Yellow_led, HIGH);
digitalWrite(Green_led, LOW);
delay(rhythm);
//Turn on GREEN
digitalWrite(Red_led, LOW);
digitalWrite(Yellow_led, LOW);
digitalWrite(Green_led, HIGH);
delay(rhythm);
}