Hello there,
I'm new Arduino and trying to program for Attiny13a microcontroller for Servo.
I have connect succesfully 13a microcontroller with arduino and light is blinked after select board.
My question is I have program code for this project but how can I upload this code with Arduino?
Is it possible copy/paste and am I need change any line in this code?
Here is the code;
//Servo2 ATtiny13A clock:9.6MHz 20131020 0600
#include <avr/io.h>
#include <avr/interrupt.h>
void wait(uint16_t w){while(w--){volatile uint16_t i=1;while(i--);}}
int a,b=150,c=1,e=90,f=194,k;
ISR(TIM0_COMPA_vect){ //timer interrupt
a++;
if(a<=b){PORTB|=(1<<PB0);}else{PORTB&=~(1<<PB0);}
if(a>=2010){a=0;}
}
int main( void ){
DDRB =0b00000111; //PB4:speed,PB3:switch,PB2 PB1:LED,PB0:OC0A
PORTB =0b00011000;
TCCR0A=0b00000010; //CTC
TCCR0B=0b00000001; //
OCR0A =93; //93:50Hz
TIMSK0=0b00000100; //compare match A interrupt enable
sei(); //interrupt enable
while(1){
if(~PINB & 0b00001000){c=1;}else{c=-1;}
if(~PINB & 0b00010000){k=500;}else{k=2000;}
wait(k);
b=b+c;
if(b<e){b=e;PORTB|=(1<<PB1);}else{PORTB&=~(1<<PB1);}
if(b>f){b=f;PORTB|=(1<<PB2);}else{PORTB&=~(1<<PB2);}