/*
* zaj3.c
*
* Created: 29.10.2018 15:07:38
* Author : student
*/
#include <avr/io.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
volatile float res;
volatile float val;
volatile int x1=0;
volatile int x2=0;
ISR(INT0_vect)
{
x1=1;
x2=0;
}
ISR(INT1_vect)
{
x2=1;
x1=0;
}
int main(void)
{
DDRB=0xFF;
GICR = _BV(INT0) | _BV(INT1);
MCUCR = _BV(ISC11) | _BV(ISC01);
ADCSRA = _BV(ADEN);
//ADMUX = _BV(MUX0);
sei();
PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(4) | _BV(5);
while (1)
{
sleep_mode();
if(x1==1) // INT0
{
ADCSRA |= _BV(ADSC) | _BV(ADPS1) | _BV(ADPS0); //preskaler 8
loop_until_bit_is_clear( ADCSRA,ADSC);
uint16_t wynik= ADCW;
val = (wynik /1024.0) * 5.20;
res=(int)val;
}
if(x2==1) // INT1
{
//PORTB = _BV(0) | _BV(2) | _BV(3) | _BV(5) |_BV(6);
res=(val-(int)val)*10;
res=(int) (res);
}
// while( ADCSRA & _BV(ADSC) );
// uint16_t wynik= ADCW;
// val = wynik * 1024 / 5.25;
// PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(4) | _BV(5) |_BV(6);
if(res == 0)
PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(4) | _BV(5) |_BV(6);
if(res==1)
PORTB =_BV(1) | _BV(2);
if(res == 2)
PORTB = _BV(0) | _BV(1) | _BV(3) | _BV(4) | _BV(6);
if(res==3)
PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(6);
if(res==4)
PORTB = _BV(2) | _BV(5) |_BV(6);
if(res==5)
PORTB = _BV(0) | _BV(2) | _BV(3) | _BV(5) |_BV(6);
if(res==6)
PORTB = _BV(0) | _BV(2) | _BV(3) | _BV(4) | _BV(5) |_BV(6) ;
if(res==7)
PORTB = _BV(0) | _BV(1) | _BV(2);
if(res==8)
PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(4) | _BV(5) |_BV(6);
if(res ==9)
PORTB = _BV(0) | _BV(1) | _BV(2) | _BV(3) | _BV(5) |_BV(6);
}
return 0;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}