0
0
Arduinoprogramming~15 mins

Documentation and pin mapping in Arduino - Mini Project: Build & Apply

Choose your learning style9 modes available
Documentation and Pin Mapping
📖 Scenario: You are building a simple Arduino project that controls two LEDs and reads a button press. To keep your code clear and easy to understand, you will document the pin connections and create variables to map each pin.
🎯 Goal: Create variables to map the pins for two LEDs and one button. Add comments to document which pin controls which component. Then write code to set the pin modes and read the button state.
📋 What You'll Learn
Create variables named ledPin1, ledPin2, and buttonPin with exact pin numbers
Add comments explaining which pin is for which component
Use pinMode() to set the LEDs as outputs and the button as input
Read the button state into a variable named buttonState
Print the button state using Serial.println()
💡 Why This Matters
🌍 Real World
Documenting pin connections clearly helps when building or sharing Arduino projects, making it easier to understand and troubleshoot hardware wiring.
💼 Career
Clear pin mapping and documentation are essential skills for embedded systems developers and hardware engineers working with microcontrollers.
Progress0 / 4 steps
1
Set up pin mapping variables with documentation
Create three variables: ledPin1 set to 5, ledPin2 set to 6, and buttonPin set to 7. Add comments above each variable to document which component is connected to that pin.
Arduino
Need a hint?

Use int to create variables and add comments with // before each variable.

2
Configure pin modes in setup()
Inside the setup() function, use pinMode() to set ledPin1 and ledPin2 as OUTPUT, and buttonPin as INPUT. Also start serial communication with Serial.begin(9600).
Arduino
Need a hint?

Use pinMode(pin, mode) inside setup() to configure pins.

3
Read button state in loop()
Inside the loop() function, read the button state using digitalRead(buttonPin) and store it in an int variable named buttonState.
Arduino
Need a hint?

Use digitalRead() to get the button state inside loop().

4
Print the button state
Add a line inside the loop() function to print the buttonState variable using Serial.println(buttonState).
Arduino
Need a hint?

Use Serial.println(buttonState); to print the button state.