What is open-source hardware?
Open-source hardware is hardware whose design files are shared openly: the circuit diagram, the board layout and the code. Anyone can study it, build it and improve it. Popular examples are Arduino-style boards, Raspberry Pi and many sensor modules.
A microcontroller board is a tiny computer on one chip with pins to connect the outside world.
Pins: digital, analog and power
A pin is a metal connector that joins the board to a wire or module.
- Digital pins have only two states: HIGH (ON, about 5 V or 3.3 V) and LOW (OFF, 0 V). Use them for buttons and LEDs.
- Analog input pins measure a level between 0 V and the supply and give a number, usually 0 to 1023 (10 bits). Use them for light sensors and knobs.
- PWM pins are digital pins that switch ON and OFF very fast to act like a smooth level, for dimming an LED.
- Power pins: 5V or 3.3V give power, GND (ground) is the return path. All modules must share a common GND.
Pins are set as INPUT or OUTPUT in the setup. Wrong direction is a common mistake.
Input and output modules
A module is a small ready-made board for one job.
- Input modules bring information in: push button, switch, light sensor, temperature sensor, ultrasonic distance sensor, knob.
- Output modules act on the world: LED, buzzer, display, relay, motor.
Reading and writing in code looks like digitalRead(2), analogRead(A0) and digitalWrite(13, HIGH). A button needs a pull-up or pull-down resistor so the pin never floats between HIGH and LOW. An LED needs a resistor (for example 220 Ω) so too much current does not burn it.
Communication between board and computer
Boards send data as bits. Serial communication sends bits one after another on a wire.
- UART serial uses two wires: TX (transmit) and RX (receive). TX of one device goes to RX of the other. Both must use the same speed, called the baud rate (for example 9600 bits per second).
- I²C uses two shared wires (SDA data, SCL clock) for many sensors on one bus; each has its own address.
- SPI is faster and uses four wires; good for memory cards and displays.
- Wireless: Bluetooth and Wi-Fi when wires are not suitable.
Serial printing (Serial.println) is also the easiest way to see what your program is doing while you fix mistakes.
Project workflow: setup and loop
Most programs for these boards have two parts.
setup()runs once: set pin directions, start serial.loop()runs again and again: read inputs → decide → write outputs → print.
A good project workflow is: list inputs and outputs → draw the circuit → write a small program → test one module at a time → combine → test the whole project → write down what you did.
Try it: button and light rule
In the 3D, go to the last step. Set the limit to 600. Slide the sensor value from 300 to 800 and watch when the LED turns on. Now predict: if the limit is 200 and the sensor value is 300, will the LED be ON or OFF? Check it.
At home with real parts: connect a button to pin 2 and an LED (with 220 Ω resistor) to pin 13. Write if (digitalRead(2) == HIGH) digitalWrite(13, HIGH); else digitalWrite(13, LOW); inside loop().
Key formulas and definitions
- Analog value = (input volts ÷ supply volts) × 1023
- LED resistor R = (supply V − LED V) ÷ current
- Bits per second (baud) ÷ 10 ≈ characters per second
- Key terms: pin, HIGH/LOW, ADC, TX/RX, baud, setup/loop
Worked examples
1. A board reads a sensor on an analog pin powered with 5 V. The sensor gives 2.5 V. What number does analogRead show (10-bit)?
Value = (2.5 ÷ 5) × 1023 ≈ 512.
2. An LED needs 20 mA and drops 2 V. The supply is 5 V. What resistor is needed?
R = (5 − 2) ÷ 0.020 = 150 Ω. Use the next standard value, 180 Ω or 220 Ω.
3. A serial link runs at 9600 baud with 10 bits per character (8 data + start + stop). About how many characters per second?
9600 ÷ 10 = 960 characters per second.
4. Write the rule for a night lamp: the LED must turn on when the light sensor reads below 300.
if (analogRead(A0) < 300) digitalWrite(13, HIGH); else digitalWrite(13, LOW);
5. A project needs 2 buttons, 1 sensor, 3 LEDs and 1 buzzer. How many digital and analog pins does it need if the sensor is analog?
Digital: 2 + 3 + 1 = 6. Analog: 1. Total 7 pins, plus power and ground.
Common mistakes
- Connecting TX to TX. TX of one device must go to RX of the other.
- Forgetting a resistor with an LED, which may burn the LED.
- Forgetting to join the grounds (GND) of the board and the module.
- Leaving a button pin without a pull-up or pull-down, so the reading jumps randomly.