To Create An Ar
To Create An Ar
use the following sample code. This code assumes you have a motor controlled using a relay module or
an H-bridge, and a button connected to a digital pin.
```cpp
// Pin definitions
void setup() {
void loop() {
if (buttonState == LOW) {
Serial.println(pressCount);
Serial.println("Counter reset.");
```
### Explanation:
- **Pin Definitions**: The `buttonPin` is set to 2 (you can change this according to your wiring). The
`motorPin` is set to 9.
- **Setup Function**: Initializes the button pin as an input with an internal pull-up resistor and the
motor pin as an output.
- **Loop Function**:
- The motor turns on for 1 second each time the button is pressed until the count reaches 10.
- Make sure to provide adequate power supply for the motor as required based on your setup.