Skip to content

Instantly share code, notes, and snippets.

View Robotto's full-sized avatar
💭
Calibrating Self.ballmerPeak

Mark Moore Robotto

💭
Calibrating Self.ballmerPeak
  • Aarhus Gymnasium
  • Aarhus, DK
  • 00:36 (UTC +02:00)
View GitHub Profile
@Robotto
Robotto / requests_demo.py
Created July 24, 2014 22:06
Requests demo
#!/usr/bin/env python
import requests
ip='90.185.22.1'
url='http://ipinfo.io/%s/loc'%ip
request = requests.get(url)
@Robotto
Robotto / glove.ino
Last active August 29, 2015 14:08
Glove code
static int servo_minimum = 0;
static int servo_maximum = 180;
static unsigned int filter_alpha = 10;
#include <Servo.h>
Servo finger1, finger2, finger3, finger4, finger5;
int servoPin1 = 5;
int servoPin2 = 6;
@Robotto
Robotto / Power
Last active August 29, 2015 14:10
Recursive function too calculate the n'th power of x - Run with: "java Power x n" <- where x and n are non-negative integers.
class Power{
public static void main(String[] args)
{
Power runner = new Power();
int x = Integer.parseInt(args[0]);
int n = Integer.parseInt(args[1]);
System.out.println(runner.F(x,n));
}
@Robotto
Robotto / BinomialApplet.java
Last active August 29, 2015 14:11
Prog2_U6_A1
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BinomialApplet extends JApplet {
//init the two binomial algorithms:
private Binomial1 algo1 = new Binomial1();
private Binomial2 algo2 = new Binomial2();
#include <Wire.h>
#define GYRO_ADDRESS ((int) 0x68) // 0x68 = 0xD0 / 2
// Arduino backward compatibility macros
#if ARDUINO >= 100
#define WIRE_SEND(b) Wire.write((byte) b)
#define WIRE_RECEIVE() Wire.read()
#else
#define WIRE_SEND(b) Wire.send(b)
// Arrays to save our results in
unsigned long start_time;
unsigned long stop_time;
unsigned int dX;
unsigned int dY;
unsigned int lastX;
unsigned int lastY;
unsigned int currentX;
unsigned int currentY;
unsigned int filterAlpha=16;
/*
This code runs on an ESP8266 wifi module, compiled/programmed through the Arduino IDE.
The specific hardware in this case is a NodeMCU v0.9 module
The ESP hosts a webserver on port 80, with event listeners for access on / , /unlock, and /buzzToggle,
it also listens on UPD port 1337 for the (newline terminated) string "SESAME"
it broadcasts itself as "door" on Mdns, so that devices on LAN can access it via http://door.local (unless it's an android device, because fuck that.)
Hand coded http response and body are in the handleroot() function.
Door unlock and buzzer toggle is physically handled with solidstate relays, so all this code needs to do is toggle I/O pins
@Robotto
Robotto / lighthouse.ino
Last active August 30, 2016 21:53
Sommerhack lighthouse - Status and control of a relay over http on wlan (Wemos D1 mini)
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
//Function declarations:
void handleRoot();
void handleToggle();
@Robotto
Robotto / StenoWeather.ino
Last active January 15, 2024 02:29
Web scraper for ardunio running on ESP8266 based boards.
/*
* This sketch sends data via HTTP GET requests to $host.
*
* Magic numbers are used to determine which line(s) to handle, and which part of this line is used.
* The numbers are determined using curl (or some other http dump program)
*/
#include <ESP8266WiFi.h>
const char* ssid = "JustUseYourPhone";
@Robotto
Robotto / exponentialFilter.ino
Created January 23, 2017 10:12
Exponential filtering of ADC measurements, with voltage calculation thrown in..
//exponentialFilter.ino
//example sketch to pull and filter measurements from eg. an ADC
//the filter has a beta value which determines the weight of new values.
//A high beta value will filter more noise but slow down the response of the filter.
static float filterBeta=32; //1, 2 , 4, 8, 16, 32, 64, 128 and so on...
//where is the data coming from?
static unsigned int adcPin=A0;
//the filtered value for printing or whatever: