Skip to content

Instantly share code, notes, and snippets.

Lukelectro / randomgepruts.ino
Created November 5, 2017 20:01
Attempt at random number generation with noise from last bit of ADC read, for seeding pseudorandom generator. For STM32F103 board.
#define debug
void setup() {
// put your setup code here, to run once:
//analogReadResolution(12); // STM32F103, 12 bits adc resolution // Allwrong, this should work but doesn't. Fortunately, in contrast to documentation, a 12 bit result turns out te be the default on this board.
void loop() {
// put your main code here, to run repeatedly:
#define STEPSPERROT (200)
#define MICROSTEPS (16)
#define INTERVALS (512)
#define MAGNETIZETIME (200) // miliseconds the magnet is powered. Hint from Aart: short, high current pulses (dump a capacitor) work best.
#define LEDPIN 17 // not 13 on pro micro, but 17
//#define DEBUG
Basic ESP8266 MQTT example, editted for "Grote Schakelaar". REMINDER: PAS DE NETWERKINSTELLINGEN AAN! En zet de topics goed. (En soldeer even een bordje maar dat is minder vergeetbaar)
It connects to an MQTT server then:
- subscribes to the topic "inTopic", printing out any messages
it receives. NB - it assumes the received payloads are strings not binary
- If the first character of the topic "inTopic" is an 1, switch ON the ESP Led,
else switch it off
- Publishes to a topic set below a value set below (hardcoded)
#include <ctype.h>
const int sp = 0; // speaker pin
char tekst[] = "pas wijze lynx bezag vroom het fikse aquaduct 1234567890"; // test tekst
const int mlen = 80; // morse length
void setup() {
// put your setup code here, to run once:
Lukelectro / mainsspy_main.c
Created December 31, 2018 13:28
work in progress. Sensor that monitors mains voltage / wheter a appliance is turned off or not, sends ID every nn s and/or goodbye at powerdown.
// MainsSensor.
// doel: op zuinige attiny (attiny10? attiny45?) bij opstarten en elke paar minuten op 433Mhz eigen ID zenden, en bij wegvallen van de voeding een afmeldbericht sturen (Met de energie uit een elco) met datzelfde ID.
// PORTB1 data output
// PORTB2 = INT0 watch powerloss (same pin on both t45 and t10)
#define t45
//#define t10
// TODO: Please note: do not forget to edit the makefile as well when changing MCU between attiny45 and attiny10 (in 2 places), and when using t45, set its fuses correctly.
Lukelectro /
Created June 6, 2019 17:56 — forked from marians/
How to read data from SDS011 sensor via USB serial connection, from
# Anpassung für big endian unter RHEL 7
while true; do
stty -F /dev/ttyUSB0 9600 raw
INPUT=$(dd conv=swab bs=10 count=1 </dev/ttyUSB0 2>/dev/null | od -x -N10 |head -n 1|cut -f2-10 -d" ");
#echo $INPUT
Lukelectro / E-ink spielerei
Last active July 18, 2020 19:49
E-Ink ED060SC7 differs from ...SC4 (Swap X & Y). STM32F103 has less RAM, so only Proof of Concept.
[empty file, added to change gist title]
* 10x 9443 display module
* Aart 06-2021
* Logic board:
* 34_pin function register function
* 1,2,3,4 V+
Lukelectro / 7003_asy.ino
Created July 18, 2021 15:09
Demo on 7003 asy board
* 10x PD2437 display module
* aangepast vanaf het voorbeeld van Aart
* Logic board:
* 34_pin function register function
* 1,2,3,4 V+
Lukelectro / main.c
Created November 6, 2021 21:07
Solar lamp msp430
#include <msp430.h>
#include <stdbool.h>
* slim solarlampje.
* Doel:
* aan net voor zonsopgang tot zonsopgang,
* aan na zonsondergang, maar beperkte tijd (niet hele nacht)
* dus de "vorige" zonsondergang/opgang onthouden.