Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mlynch/arduino-snippets
Helpful snippets for Arudino C++ projects
https://github.com/mlynch/arduino-snippets
Last synced: 2 months ago
JSON representation
Helpful snippets for Arudino C++ projects
- Host: GitHub
- URL: https://github.com/mlynch/arduino-snippets
- Owner: mlynch
- License: mit
- Created: 2021-06-05T20:55:54.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-19T14:43:57.000Z (over 3 years ago)
- Last Synced: 2024-10-04T18:47:55.893Z (3 months ago)
- Language: C++
- Size: 8.79 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arduino Snippets
Library of useful C++ snippets and reusable classes I've created as I build out Arduino Uno and ESP32 projects.
## Button
A simple button utility that debounces and is meant to be triggered on `LOW` from a pin set to `INPUT_PULLUP`.
```cpp
// some data to send to action on press
int bData = ...
void handleButton(void *data) {
// Handle the button press
}
Button b(PIN, &bData, handleButton)
void loop() {
b->test();
}
```## Seven Segment
A utility for 4-digit seven segment displays using the TM1637 Drive Chip like [these](https://www.amazon.com/HiLetgo-Digital-Segment-Display-Arduino/dp/B01DKISMXK/ref=sr_1_1_sspa?dchild=1&keywords=tm1637&qid=1622991533&sr=8-1-spons&psc=1&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUExWUI0VUQ3OUFEMTUyJmVuY3J5cHRlZElkPUEwNTg2MzU4MTFQVjZCU0tTWTVVMiZlbmNyeXB0ZWRBZElkPUEwNTU2NTE3MjZJU042TldKOTM2RCZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU=)
```cpp
#include "SevenSegment.h"#define CLK 2
#define DIO 3SevenSegment segment(CLK, DIO);
void onHalfSecond() {
segment.clockPoint();
// Set the hours and minutes from a clock source
segment.setHours(clock.getHours());
segment.setMinutes(clock.getMinutes());
segment.update();
}void setup() {
segment.init();
// Some kind of trigger on ever half-second
// to flash the segment clock point
// Timer1.initialize(500000); //timing for 500ms
// Timer1.attachInterrupt(onHalfSecond);
}void loop() {
segment.loop();
}
```