Исходник
HEX
Код: Выбрать все
/*
* Traning.c
*
* Created: 18.10.2017 14:48:47
* Author : Girs
*/
#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include "n5110.h"
int x=1;
byte zo[5] ;
int rou;
int z;
int r = 0b10101111;
void timer1(){
asm("cli");
TCCR1A=0x40;//при совпадении уровень OC1A меняется на противоположный
TCCR1B=0x01;//CLK/1024
OCR1AH=100;//записываем в регистр OCR1A 1000
OCR1AL=100;
TIMSK = 0x10;//разрешаем прерывание по совпадению
asm("cli");
}
ISR (TIMER1_COMPA_vect){
asm("nop");
asm("nop");
Lcd_clear();
Lcd_prints(0,4,FONT_1X,(unsigned char *)PSTR("Кручу верчу"));
Lcd_update();
_delay_ms(1000);
///TCCR0 |=(0<<0);
////Lcd_init();
Lcd_clear();
}
ISR (TIMER0_OVF_vect){
asm("nop");
Lcd_clear();
Lcd_prints(2,1,FONT_1X,(unsigned char *)PSTR("Кручу верчу"));
Lcd_prints(1,4,FONT_1X,(unsigned char *)PSTR("Наебать хочу"));
Lcd_update();
_delay_ms(1000);
///TCCR0 |=(0<<0);
////Lcd_init();
Lcd_clear();
}
void init(){
////timer1();
DDRD = 0xFF;
DDRC = 0x00;
///DDRB = 0x00;
PORTC=0xFF;
///PORTB=0xFF;
PORTD=0x00;
Lcd_init();
Lcd_clear();
}
int roud(){
rou = rand()%36;
return rou;
}
int main(void)
{
/* Replace with your application code */
asm("cli");
TCCR0 |=(1<<CS00);
///TCCR0 &=~(1<<WGM00);
///TCCR0 &=~(1<<WGM01);
TIFR |=(1<<TOV0);
TIMSK |=(1<<TOIE0);
///TIMSK |=(1<<0);
//OCR0 = 100;
/// timer1();
asm("cli");
init();
while (1)
{
asm("cli");
Lcd_init();
_delay_ms(100);
itoa(roud(),zo,10);
Lcd_prints(4,3,FONT_1X,(unsigned char *)PSTR("РУЛЕТКА"));
Lcd_print(6,1,FONT_1X, (unsigned char*) zo);
Lcd_prints(0,4,FONT_1X,(unsigned char *)PSTR("GanstaParadise"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
asm("cli");
asm("sei");
asm("nop");
asm("cli");
Lcd_prints(4,1,FONT_1X,(unsigned char *)PSTR("НАЕБУ"));
Lcd_prints(1,3,FONT_2X, (unsigned char*) PSTR("ЛОШАРУ"));
Lcd_prints(4,5,FONT_1X,(unsigned char *)PSTR("НАЕБУ"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
Lcd_prints(4,1,FONT_1X,(unsigned char *)PSTR("ВЫПАЛО"));
Lcd_print(6,4,FONT_1X, (unsigned char*) zo);
Lcd_prints(4,2,FONT_1X,(unsigned char *)PSTR("ЧИСЛО"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
if((PINC & 0b00000011)==0){
x++;}
if(x==4){
r=(~r);
PORTD=r;
_delay_ms(300);
PORTD=0b10101010;
_delay_ms(300);
PORTD=r;
x=0;
}
PORTD=0x00;
if((PINC&0b00010000)==0){
for(int i=0;i<=7;i++){
PORTD = (1<<i);
_delay_ms(100);
}
for(int i=7;i>=0;i--){
PORTD = (1<<i);
_delay_ms(100);
}
}
}
}
более навороченная версия
Код: Выбрать все
/*
* Traning.c
*
* Created: 18.10.2017 14:48:47
* Author : Girs
*/
#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include "n5110.h"
int x=1;
byte zo[5] ;
int rou;
int z;
int r = 0b10101111;
void timer1(){
asm("cli");
TCCR1A=0x40;//при совпадении уровень OC1A меняется на противоположный
TCCR1B=0x01;//CLK/1024
OCR1AH=100;//записываем в регистр OCR1A 1000
OCR1AL=100;
TIMSK = 0x10;//разрешаем прерывание по совпадению
asm("cli");
}
ISR (TIMER1_COMPA_vect){
asm("nop");
asm("nop");
Lcd_clear();
Lcd_prints(0,4,FONT_1X,(unsigned char *)PSTR("Кручу верчу"));
Lcd_update();
_delay_ms(1000);
///TCCR0 |=(0<<0);
////Lcd_init();
Lcd_clear();
}
ISR (TIMER0_OVF_vect){
asm("nop");
Lcd_clear();
Lcd_prints(2,1,FONT_1X,(unsigned char *)PSTR("Кручу верчу"));
Lcd_prints(0,4,FONT_1X,(unsigned char *)PSTR("Крутим Барабан"));
Lcd_update();
_delay_ms(1000);
///TCCR0 |=(0<<0);
////Lcd_init();
Lcd_clear();
}
void init(){
////timer1();
DDRD = 0xFF;
DDRC = 0x00;
///DDRB = 0x00;
PORTC=0xFF;
///PORTB=0xFF;
PORTD=0x00;
Lcd_init();
Lcd_clear();
}
int roud(){
rou = rand()%36;
return rou;
}
int main(void)
{
/* Replace with your application code */
asm("cli");
TCCR0 |=(1<<CS00);
///TCCR0 &=~(1<<WGM00);
///TCCR0 &=~(1<<WGM01);
TIFR |=(1<<TOV0);
TIMSK |=(1<<TOIE0);
///TIMSK |=(1<<0);
//OCR0 = 100;
/// timer1();
asm("cli");
init();
while (1)
{
asm("cli");
Lcd_init();
_delay_ms(100);
itoa(roud(),zo,10);
Lcd_prints(4,3,FONT_1X,(unsigned char *)PSTR("РУЛЕТКА"));
Lcd_print(6,1,FONT_1X, (unsigned char*) zo);
Lcd_prints(0,4,FONT_1X,(unsigned char *)PSTR("GanstaParadise"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
asm("cli");
asm("sei");
asm("nop");
asm("cli");
Lcd_prints(4,1,FONT_1X,(unsigned char *)PSTR("НАЕБУ"));
Lcd_prints(1,3,FONT_2X, (unsigned char*) PSTR("ЛОШАРУ"));
Lcd_prints(4,5,FONT_1X,(unsigned char *)PSTR("НАЕБУ"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
Lcd_prints(4,1,FONT_1X,(unsigned char *)PSTR("ВЫПАЛО"));
Lcd_print(6,4,FONT_1X, (unsigned char*) zo);
Lcd_prints(4,2,FONT_1X,(unsigned char *)PSTR("ЧИСЛО"));
Lcd_update();
_delay_ms(1000);
Lcd_clear();
if((PINC & 0b00000011)==0){
x++;}
if(x==4){
r=(~r);
PORTD=r;
_delay_ms(300);
PORTD=0b10101010;
_delay_ms(300);
PORTD=r;
x=0;
}
PORTD=0x00;
if((PINC&0b00010000)==0){
for(int i=0;i<=7;i++){
PORTD = (1<<i);
_delay_ms(100);
}
for(int i=7;i>=0;i--){
PORTD = (1<<i);
_delay_ms(100);
}
}
}
}