Код: Выделить всё
/*
* GccApplication7.c
*
* Created: 20.04.2019 01:28:45
* Author : Timofey
*/
#include <util/delay.h>
#define F_CPU 10000000UL
#include <avr/interrupt.h>
#include <stdlib.h>
#define BitIsSet(reg,bit) ((reg&(1<<bit)) !=0)
#define BitIsClear(reg,bit) ((reg&(1<<bit)) ==0)
#define nop() {asm("nop");}
unsigned int i, p, a, b, c, ms, x;
void delay_ms(int ms){
for (x=ms; x>0; x--) nop ();}
void led0(int led, int i, int p){
PORTB &= ~_BV(led); delay_ms(i);
PORTB |= _BV(led); delay_ms(p);}
SIGNAL(INT1_vect){
a = a - 500;
b = b + 500;
}
SIGNAL(INT0_vect){
a = a + 500;
b = b - 500;
}
int main(void){
DDRB |= _BV(PB0);
DDRB |= _BV(PB1);
DDRB |= _BV(PB2);
PORTB = 0x00;
GIMSK=0b11000000;
MCUCR=0b00001111;
DDRD = 0x00;
sei();
while(1){
for(;;){
led0(PB0, a, b);
//led0(PB1, a, b);
//led0(PB2, a, b);
}
}
}- Вложения
-
- attiny2313%20rgb%20led_schem.png
- Это схема (для одного rgb светодиода)
- (119.08 КБ) 451 скачивание


