Joseph Ogbonna
Joseph Ogbonna
DIIDevHeads IoT Integration Server
Created by Enthernet Code on 6/11/2024 in #firmware-and-baremetal
utilize a microcontroller's GPIO pins to control peripheral devices in an IoT embedded software in C
This example is for Arduino, Connect the LED: - Connect the LED's anode (long leg) to Arduino Uno's digital pin 13 - Connect the LED's cathode (short leg) to the ground (GND) pin on the Arduino Arduino Code:
void setup() {
pinMode(13, OUTPUT); // Initialize pin 13 as output
}

void loop() {
digitalWrite(13, HIGH); // Turn on the LED
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn off the LED
delay(1000); // Wait 1 second
}
void setup() {
pinMode(13, OUTPUT); // Initialize pin 13 as output
}

void loop() {
digitalWrite(13, HIGH); // Turn on the LED
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn off the LED
delay(1000); // Wait 1 second
}
- Pin 13 is set as output using pinMode() - digitalWrite() is used to set the pin high (turn on the LED) or low (turn off the LED) - delay() is used to create a 1-second interval between on and off states You can also use any digital pin of your choice
5 replies