Merge DIYglenn

This commit is contained in:
Gunnar Skjold
2019-02-14 07:48:46 +01:00
parent a954b838f3
commit 3cb433b27e
273 changed files with 84 additions and 11488 deletions

View File

@@ -0,0 +1,7 @@
This is a simple Arduino sketch that can be used to generate a
serial test pattern (input to the m-bus master for instance).
It will send one byte at the time, changing one bit compared
to previous at a fixed interval.

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -0,0 +1,36 @@
#include <SoftwareSerial.h>
#define RX_PIN 10
#define TX_PIN 11
SoftwareSerial mySerial(RX_PIN, TX_PIN);
// https://en.wikipedia.org/wiki/Binary_Gray_sequence
static unsigned int binary_to_gray(unsigned int num)
{
return num ^ (num >> 1);
}
void setup() {
mySerial.begin(9600);
}
void loop() {
static unsigned int i = 0;
static unsigned int ch = 0;
// Change the character more seldom than each loop entry.
if (i++ > 20) {
i = 0;
// 127 => leave the last bit sent always zero.
if (++ch > 127) {
ch = 0;
}
}
mySerial.write(binary_to_gray(ch));
// 9600 bps => 8 bit = 8/9600s ~ 0.8ms
delay(50);
}