Skip to content

Instantly share code, notes, and snippets.

@kachurovskiy
kachurovskiy / ArduinoDisplayClock.ino
Created February 11, 2016 22:18
Arduino program showing data from DS1302 clock on 4-digit display
#include <virtuabotixRTC.h>
#include <SevSeg.h>
SevSeg sevseg;
// Clock DS1302 on analog pins 0 to 2
virtuabotixRTC myRTC(14, 15, 16);
void setup() {
@kachurovskiy
kachurovskiy / ArduinoDisplayTemperatureHumidity.ino
Created February 12, 2016 19:11
Arduino program showing data from DHT11 temperature and humidity sensor on 4-digit display
#include <DHT.h>
#include <SevSeg.h>
// DHT data wire connected on A0
#define DHTPIN 14
#define DHTTYPE DHT11
SevSeg sevseg;
DHT dht(DHTPIN, DHTTYPE);
@kachurovskiy
kachurovskiy / PI4JRotaryEncoderReading.java
Last active November 16, 2021 17:05
Pi4j rotary encoder reading
// Pin pinA - CLK pin,
// Pin pinB - DT pin
// rotate(int i) - callback receiving -1 or 1
inputA = gpio.provisionDigitalInputPin(pinA, "PinA", PinPullResistance.PULL_UP);
inputB = gpio.provisionDigitalInputPin(pinB, "PinB", PinPullResistance.PULL_UP);
inputA.addListener(new GpioPinListenerDigital() {
int lastA;
@Override
@kachurovskiy
kachurovskiy / ClapLED.ino
Last active January 8, 2018 22:45
Double-clap to toggle the light. https://youtu.be/0-Un6Gu4Ah0
bool isOn = false;
void setup() {
pinMode(2, OUTPUT);
digitalWrite(2, isOn ? HIGH : LOW);
}
int th = 40;
void toggle() {
#include <avr/sleep.h>
#include <avr/wdt.h>
void setup() {
pinMode(4, OUTPUT);
}
void water(int ms) {
digitalWrite(4, HIGH);
delay(ms);
package com.slowvideoc;
import com.arthenica.mobileffmpeg.Config;
import com.arthenica.mobileffmpeg.FFmpeg;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
@kachurovskiy
kachurovskiy / NanoElsH2.ino
Created January 6, 2021 12:25
NanoEls 2-axis version [BUGGY] [DO NOT USE]
// https://github.com/kachurovskiy/nanoels
/* Change values in this section to suit your hardware. */
// Define your hardware parameters here. Don't remove the ".0" at the end.
#define ENCODER_STEPS 600.0 // 600 step spindle optical rotary encoder
#define MOTOR_STEPS 200.0 // 200 step stepper motor, no microstepping
#define LEAD_SCREW_HMM 200.0 // 2mm lead screw
#define MOTOR_X_STEPS 200.0 // 200 step stepper motor, no microstepping
#define STEP 12
void setup() {
// 200 step per revolution motor driver on this pin.
pinMode(STEP, OUTPUT);
}
void topSpeed_1Turn() {
for (int i = 0; i < 200; i++) {
// Issue 1 step.
#define STEP 12
#define ENA 13
// How fast we want to accelerate the stepper. Reasonable values 5 - 200.
#define ACCELERATION 5
// Time between the STEP pulses when starting slow. 400 pulses per second.
#define DELAY_US_MAX 2500
// Time between the STEP pulses at highest speed. 25*400 pulses per second.
#define DELAY_US_MIN 100
// Maximum size of the acceleration table. Arduino has little memory.
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(21, 48, 47, 38, 39, 40, 41, 42, 2, 1);
void setup() {
lcd.begin(20, 4);
lcd.setCursor(0, 3);
}