Example Code for Arduino-Digital IO Control
Last revision 2026/01/24
This article provides step-by-step instructions and example code for controlling digital IO pins on Arduino, including hardware and software setup, and pin level toggling.
Hardware Preparation
- Bluno M0 Mainboard(SKU: DFR0416) ×1
- Micro USB Cable ×1
Software Preparation
- Download Arduino IDE: Click to download Arduino IDE
- Install Bluno M0 board URL: https://raw.githubusercontent.com/DFRobot/DFRobotDuinoBoard/master/package_dfrobot_index.json
Sample Code
Set D24-D31 as output, cycle to set their levels high and low.
int pin;
void setup() { // put your setup code here, to run once:
for(pin=24;pin<32;pin++){
pinMode(pin,OUTPUT);
}
}
void loop() { // put your main code here, to run repeatedly:
for(pin=24;pin<32;pin++){
digitalWrite(pin,HIGH);
}
delay(500);
for(pin=24;pin<32;pin++){
digitalWrite(pin,LOW);
}
delay(500);
}
Result
Digital pins D24~D31 will turn on (HIGH) for 500ms and then turn off (LOW) for 500ms repeatedly.
Was this article helpful?
