CART360 TANGIBLE MEDIA & PHYSICAL COMPUTING STUDIO SESSIONSAVR
ATMEL AVR


Migrating from Arduino to AVR


 

AVR Studio, AVR-GCC & AVR LibC

Download & install WinAVR (Windows)
Download & install CrossPack (Mac)
Download & install AVR Studio

 

AVRISP MKII

 

ATTINY13V

Memory:
– 1KB of Flash program memory
– 64 Bytes EEPROM
– 64 Bytes SRAM

Periferals:
– 2 PWM Channels (analog outputs)
– 4 Analog Inputs
– 6 Digital I/O

Operation:
– 1.8 - 5.5V
– 0 - 4 MHz @ 1.8 - 5.5V, 0 - 10 MHz @ 2.7 - 5.5V

GETSET abstraction layer

Download getset.h and place it in your project directory.

get(pin) :

  • will give you a digital value {HIGH, LOW} if pin is {PB0, PB1, PB2, PB3, PB4}.
  • will give you an analog value {0..255} if pin is {ADC1, ADC2, ADC3}.

set(pin, value):

  • will set the pin {PB0, PB1, PB2, PB3, PB4} to value {HIGH, LOW}.


Blink an LED

Blink Example Code

//////////////////////////////////////////
// SIMPLE BLINKING LED FOR THE ATTINY13V
//
// LED connects to PB0.
// Uses the getset library. 
//
// Vincent 11/2009
//////////////////////////////////////////
#include <util/delay.h>
#include "getset.h"

int main(void){
	// putting stuff here is similar
	// as putting it in Arduino's setup()

	while(1){
		// putting stuff here is similar
		// as putting it in Arduino's loop()
		set(PB0, HIGH);
		_delay_ms(1000);
		set(PB0, LOW);
		_delay_ms(1000);		
	}
}
		  

 

Simple Synth

Simple Synth Example Code

//////////////////////////////////////////
// SIMPLE SYNTHESIZER FOR THE ATTINY13V
//
// Buzzer connects to PB0.
// Pot connects to ADC3.
// Uses the getset library. 
//
// Vincent 11/2009
//////////////////////////////////////////
#include <util/delay.h>
#include "getset.h"

int main(void){
        // putting stuff here is similar
        // as putting it in Arduino's setup()
        uint8_t i,j;

        while(1){
                // putting stuff here is similar
                // as putting it in Arduino's loop()		
                j = get(ADC3);
                set(PB0, HIGH);
                for(i=0;i<j;i++) _delay_us(5);
                set(PB0, LOW);
                for(i=0;i<j;i++) _delay_us(5);
        }
}
                
                


 
RESOURCES
REFERENCES