/*
Practical 1
modified 16/7/2025
by azhan@psp
Write your Group info bellow:-
Name :
Matrik:
*/
//output pin
// constants won't change. They're used here to set pin numbers:
const int LED_1_RED = 10 ;// the number of the LED pin 10
const int LED_2_GREEN = 9 ;// the number of the LED pin 9
const int LED_3_YELLOW = 8 ;// the number of the LED pin 8
const int relay1 = 7 ;// the number of the LED pin 8
//input pin
// constants won't change. They're used here to set pin numbers:
const int sw1_green = 3; // the number of the pushbutton pin 3
const int sw2_red = 4; // the number of the pushbutton pin 4
//int for bit register
int system_status = 0 ; // flag status
int status_sw1=0;
int status_sw2=0;
void setup() {
// put your setup code here, to run once:
// initialize the LED pin as an output:
pinMode(LED_1_RED, OUTPUT);
pinMode(LED_2_GREEN, OUTPUT);
pinMode(LED_3_YELLOW, OUTPUT);
pinMode(relay1, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(sw1_green, INPUT);
pinMode(sw2_red, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//blinker codes
digitalWrite(LED_3_YELLOW, HIGH);
delay(250);
digitalWrite(LED_3_YELLOW, LOW);
delay(250);
//control codes
status_sw1 = digitalRead(sw1_green);
status_sw2 = digitalRead(sw2_red);
if ( status_sw1==HIGH ){
system_status=1;
}
if ( status_sw2==HIGH ){
system_status=0;
}
if ( system_status==1){
digitalWrite(LED_2_GREEN, HIGH);
digitalWrite(LED_1_RED, LOW);
digitalWrite(relay1, HIGH);
}
if ( system_status==0){
digitalWrite(LED_2_GREEN, LOW);
digitalWrite(LED_1_RED, HIGH);
digitalWrite(relay1, LOW);
}
}