embedded systems
embedded systems
SECTION A
void setup() {
pinMode(LEDpin, OUTPUT); // Set LED pin
as output
}
void loop() {
digitalWrite(LEDpin, HIGH); // Turn LED ON
delay(DelayT); // Wait for DelayT
milliseconds
digitalWrite(LEDpin, LOW); // Turn LED
OFF
delay(DelayT); // Wait for DelayT
milliseconds
}
Code Process Explanation:
• Variable Declaration:
• LEDpin = 23 assigns pin 23 to control
the LED.
• DelayT = 1000 sets a delay of
1000ms (1 second) for ON and OFF
states.
• Setup Function:
• pinMode(LEDpin, OUTPUT)
configures pin 23 as an output to
control the LED.
• Loop Function:
• digitalWrite(LEDpin, HIGH) sets pin
23 to HIGH, turning the LED ON.
• delay(DelayT) pauses for 1000ms
with the LED ON.
• digitalWrite(LEDpin, LOW) sets pin
23 to LOW, turning the LED OFF.
• delay(DelayT) pauses for 1000ms
with the LED OFF.
• The loop repeats, causing the LED to
blink ON and OFF every 1 second.
Effect of Changing DelayT to 2000:
• When DelayT = 2000 (2000ms or 2
seconds):
• The LED stays ON for 2 seconds
(instead of 1 second).
• The LED stays OFF for 2 seconds
(instead of 1 second).
• The total blink cycle time doubles
from 2 seconds (1s ON + 1s OFF) to
4 seconds (2s ON + 2s OFF).
• The blinking frequency decreases,
making the LED blink slower and
more noticeable.