Skip to content

Instantly share code, notes, and snippets.

@du19901c
du19901c / adc_example.c
Created October 14, 2024 02:55 — forked from Wollw/adc_example.c
ATmega328P ADC conversion example
/* A simple ADC example that checks the analog reading on ADC0 and turns
* an LED on if the reading is higher than a threshold value and turns if
* off if it is under that value. */
#include <avr/io.h>
#include <stdint.h>
/* Which analog pin we want to read from. The pins are labeled "ADC0"
* "ADC1" etc on the pinout in the data sheet. In this case ADC_PIN
* being 0 means we want to use ADC0. On the ATmega328P this is also
* the same as pin PC0 */
@du19901c
du19901c / arduino-modbus-rtu.ino
Created January 29, 2025 04:04 — forked from LosantGists/arduino-modbus-rtu.ino
Example sketch that reads Modbus RTU data with an Arduino
#include <ArduinoModbus.h>
// How often (in milliseconds) the sensors will be read.
const unsigned long REPORT_INTERVAL = 1000;
void setup() {
Serial.begin(9600);
while(!Serial);
if (!ModbusRTUClient.begin(9600)) {