Circuit Documentation
Summary of the Circuit
This circuit consists of a SparkFun Pro Micro microcontroller board and a micro switch. The micro switch is used as an input device to the SparkFun Pro Micro. When the switch is in the normally open (NO) position, it does not conduct; when the switch is actuated, it closes the circuit between the NO and common (COM) terminals, allowing current to flow. This change in state can be detected by the microcontroller, which can then perform actions based on the switch input.
Component List
SparkFun Pro Micro
- Description: The SparkFun Pro Micro is a microcontroller board based on the ATmega32U4. It has 18 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16 MHz crystal oscillator, a micro USB connection, an ICSP header, and a reset button.
- Pins: RAW, GND, RESET, VCC, A3, A2, A1, A0, SCK, MISO, MOSI, D10, D9, D8, D7, D6, D5, D4, D3, D2, RXI, TXO
Micro Switch
- Description: A micro switch is a small, fast-acting switch used for detecting on/off states. It typically has three terminals: common (COM), normally open (NO), and normally closed (NC).
- Pins: COM, NO, NC
Wiring Details
SparkFun Pro Micro
- GND: Connected to the common (COM) terminal of the Micro Switch.
- D10: Connected to the normally open (NO) terminal of the Micro Switch.
Micro Switch
- COM: Connected to the GND pin on the SparkFun Pro Micro.
- NO: Connected to the D10 pin on the SparkFun Pro Micro.
- NC: Not connected in this circuit.
Documented Code
There is no code provided for the microcontroller in this circuit. If code were provided, it would typically be used to initialize the microcontroller's digital pin connected to the micro switch as an input and to read the state of the switch in a loop. When the switch state changes from open to closed, the microcontroller could execute a programmed response, such as sending a signal, lighting an LED, or transmitting data.
// Example code for the SparkFun Pro Micro to read the micro switch state
void setup() {
pinMode(10, INPUT_PULLUP); // Initialize D10 as an input with an internal pull-up resistor
}
void loop() {
int switchState = digitalRead(10); // Read the state of the switch
if (switchState == LOW) {
// The switch is pressed; perform an action
} else {
// The switch is not pressed; perform another action or do nothing
}
// Add a small delay to debounce the switch
delay(50);
}
Please note that the above code is a hypothetical example and should be adapted to the specific requirements of the application.
