This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |