IOT 1st Exercise - LED By Using Arduino Simulator
IOT 1st Exercise - LED By Using Arduino Simulator
Component List
a. Resistor
b. Red LED
c. Arduino
Code:
void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8, HIGH);
}
Output:
How does the 'loopCount' variable in the provided Arduino
sketch control the number of times the LED blinks?
Required Components:
1. Arduino Board
2. LEDs (Red and Green)
3. Resistors (for current limiting, one for each LED)
4. Jumper Wires
Code:
void setup() {
pinMode(8, OUTPUT);
}
void loop() {
static int loopCount = 0;
if (loopCount < 3) {
digitalWrite(8, HIGH);
delay(5000);
digitalWrite(8, LOW);
delay(2000);
loopCount++;
}
}