Skip to content

Instantly share code, notes, and snippets.

@gorlum0
gorlum0 / ex2.py
Created January 28, 2012 09:43
ml-class - ex2 (python)
#!/usr/bin/env python
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from scipy import optimize
from numpy import newaxis, r_, c_, mat, e
from numpy.linalg import *
def plotData(X, y):
#pos = (y.ravel() == 1).nonzero()
@electronut
electronut / atmega168-serial.c
Last active December 17, 2015 12:29
ATmega168 serial communications (transmit only) - most code is from the data sheet.
#define BAUD 9600
#define MYUBRR F_CPU/16/BAUD-1
void USART_Init(unsigned int ubrr)
{
/*Set baud rate */
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
/*Enable receiver and transmitter */
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
@electronut
electronut / attiny84-hcsr04.c
Created June 7, 2013 15:37
Talking to ultrasonic sensor HC-SR04 with an ATtiny84, and sending distance data using serial communications.
//
// Talking to ultrasonic sensor HC-SR04 with an ATtiny84, and
// sending distance data using serial communications.
//
// electronut.in
//
#include <avr/io.h>
#include <string.h>
#include <util/delay.h>