Skip to content

Instantly share code, notes, and snippets.

View Lauszus's full-sized avatar

Kristian Sloth Lauszus Lauszus

View GitHub Profile
#include <SPP.h>
USB Usb;
BTD Btd(&Usb);
SPP SerialBT(&Btd);
char val[3];
int pin1 = 22;
int pin2 = 24;
int pin3 = 26;
@Lauszus
Lauszus / PWM test.cpp
Last active October 13, 2015 21:48
Help for Norbert Gauci
#define PWM_FREQUENCY 20000 // The motor driver can handle a pwm frequency up to 20kHz
#define PWMVALUE F_CPU/PWM_FREQUENCY/2 // Frequency is given by F_CPU/(2*N*ICR) - where N is the prescaler, we use no prescaling so frequency is given by F_CPU/(2*ICR) - ICR = F_CPU/PWM_FREQUENCY/2
const uint8_t direction1 = 9;
const uint8_t direction2 = 10;
const uint8_t pwm1 = 11;
const uint8_t pwm2 = 12;
void setup() {
Serial.begin(115200);
// Define these variables
int16_t accY;
int16_t accZ;
int16_t gyroX;
unsigned long timer;
// Put this in your setup()
Wire.begin();
i2cWrite(0x6B,0x00); // Disable sleep mode
if(i2cRead(0x75,1)[0] != 0x68) { // Read "WHO_AM_I" register
@Lauszus
Lauszus / Robocup
Last active December 11, 2015 15:48
Robocup
lineDist = 0.2
irDist = 0.25
gateDist = 0.35
gateLength = 0.55
gateFoundDist = 0.2
%%%%%%%%%%%%% Husk at ændre!!!!
whiteLineValue = 0.70
%%%%%%%%%%%%%
@Lauszus
Lauszus / gist:4722886
Last active December 12, 2015 05:38
Help for Jay Subramaniam
/*
Example sketch for the RFCOMM/SPP Bluetooth library - developed by Kristian Lauszus
For more information visit my blog: http://blog.tkjelectronics.dk/ or
send me an e-mail: kristianl@tkjelectronics.com
*/
#include <Adafruit_MAX31855.h>
#include <SPP.h>
USB Usb;
BTD Btd(&Usb); // You have to create the Bluetooth Dongle instance like so
@Lauszus
Lauszus / gist:5019719
Created February 23, 2013 13:23
Avrdude write to eeprom
avrdude -p m644 -c usbasp -t
avrdude> write eeprom 0x00 0x00 0x20 0x41 0x00 0x00 0x80 0x3f 0x00 0x00 0x40 0x40 0x00 0x00 0x35 0x43
avrdude> dump eeprom 0 15
@Lauszus
Lauszus / Inquiry.java
Last active December 18, 2015 01:59
Java native Bluetooth
package com.tkjelectronics.balanduinoapp;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.LocalDevice;
import javax.microedition.io.StreamConnection;
@Lauszus
Lauszus / gps.py
Last active August 21, 2023 08:31
Python script used to decode GPS data and then generate a html page.Remember to replace the API key with your API key: https://developers.google.com/maps/documentation/javascript/tutorial#api_key.
#!/usr/bin/env python
import serial
import time
import os
import sys
from string import Template
if os.geteuid() != 0: # Source: https://gist.github.com/davejamesmiller/1965559
os.execvp("sudo", ["sudo"] + sys.argv)
@Lauszus
Lauszus / Balanduino wdt.diff
Last active August 29, 2015 14:05
Balanduino dev
diff --git a/Firmware/Balanduino/Balanduino.h b/Firmware/Balanduino/Balanduino.h
index 338024d..45039f1 100644
--- a/Firmware/Balanduino/Balanduino.h
+++ b/Firmware/Balanduino/Balanduino.h
@@ -189,6 +189,12 @@ uint32_t spekConnectedTimer; // Timer used to check if the connection is dropped
#define RC_CHAN_AUX4 7
#endif
+uint8_t resetFlags __attribute__ ((section(".noinit"))); // Source: https://code.google.com/p/optiboot/issues/attachmentText?id=66&aid=660004000&name=resetFlags_appCode.cpp
+void resetFlagsInit(void) __attribute__ ((naked)) __attribute__ ((section (".init0")));
@Lauszus
Lauszus / crc32.diff
Last active August 29, 2015 14:06
PS4 dev
diff --git a/PS4BT.h b/PS4BT.h
index 3c0aae1..b85db8c 100644
--- a/PS4BT.h
+++ b/PS4BT.h
@@ -21,6 +21,53 @@
#include "BTHID.h"
#include "PS4Parser.h"
+/*
+const uint32_t crc32_table[] PROGMEM = {