Skip to content

Instantly share code, notes, and snippets.

% If you have two sets of data for different x values and want to plot them in error-bar format in matlab you can use this.
clear all
close all
clc
% Make up some data to plot
x = [.12 .24 .36 .48 .6]; % x-values
y1ConeAng1 = [33 31 27 25 30]; %y1(1) values for x1 point
clear all
close all
clc
%% data inputs
D1 = load ('points100disorder.txt'); % simplest way, don't need to worry about length
%D = dlmread ('points100disorder.txt', ',', 'A1..B100'); % reads data from dat file and A1 is the cell id like excel
D2 = load ('points200disorder.txt');
D3 = load ('points320disorder.txt');
classdef monkey
% monkey -- class definition file
properties
x % monkey x location
y % monkey y location
high % logical state for monkey
end % end properties
methods
@yasser-khan
yasser-khan / serialutils.py
Created December 30, 2012 07:27
Some serial port utilities for Windows and PySerial by Eli Bendersky
"""
Some serial port utilities for Windows and PySerial
Eli Bendersky (eliben@gmail.com)
License: this code is in the public domain
"""
import re, itertools
import _winreg as winreg
@yasser-khan
yasser-khan / serial_read_write_msp430.py
Created December 30, 2012 06:41
This script reads and writes serial data to MSP430.
"""
This script reads and writes serial data to MSP430.
MSP430 is programmed to send data if a command is sent.
Commands Request
0x36 Vcc
0x35 Temperature
0x32 Voltage at P1.3
Once command is sent MSP430 sends two bytes, these are then decoded.
@yasser-khan
yasser-khan / adcVcc.c
Created December 29, 2012 21:27
MSP430 VCC, Temp, Voltage at P1.3
/******************************************************************************
* MSP430 ADC10 Example for the G2231
*
* Description: This code provides an example for using the 10 bit ADC in the
* MSP430G2231. The code requires either a terminal program or
* the application provided on the blog mentioned below.
* depending on which ascii character is sent to the device,
* either VCC, the temperature sensor, or an external pin will
* be measured once and the results sent to the computer.
*
@yasser-khan
yasser-khan / ledSwitchInterrupt.c
Created December 29, 2012 10:59
MSP430 LED Switch with Interrupt
#include <msp430g2553.h>
void configureClocks();
volatile unsigned int i;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
configureClocks();
@yasser-khan
yasser-khan / ledSwitch.c
Created December 29, 2012 10:21
MSP430 LED Switch
#include <msp430g2553.h>
void configureClocks(); // Setting clock speeds
volatile unsigned int i; // Volatile to prevent optimization
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
configureClocks();
@yasser-khan
yasser-khan / twoLeds.c
Created December 29, 2012 07:42
MSP430 toggle LEDs at P1.0 and P1.6.
#include <msp430g2553.h>
volatile unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT0; // P1.0 output, BIT0 is define as (0x0001) in the header file
P1OUT &= ~BIT0; // P1.0 output LOW, LED Off
P1DIR |= BIT6; // P1.6 output
@yasser-khan
yasser-khan / led.c
Created December 29, 2012 05:56
Blink LED on MSP430 launchpad.
#include <msp430g2553.h>
volatile unsigned int i = 0; // Volatile to prevent optimization. This keeps count of cycles between LED toggles
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer. This line of code is needed at the beginning of most MSP430 projects.
// This line of code turns off the watchdog timer, which can reset the device after a certain period of time.
// If you've a lot of initializations, this line prevents the system from falling into infinite loops.
P1DIR |= 00000001; // P1DIR is a register that configures the direction (DIR) of a port pin as an output or an input.
// To set a specific pin as output or input, we write a '1' or '0' on the appropriate bit of the register.