Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * binluku2.c
- *
- * Created: 25.11.2014 13:27:48
- * Author: gg eazy
- */
- #define F_CPU 1000000UL
- #include <avr/io.h>
- #include <util/delay.h>
- #define SWITCH3 !(PIND & (1<<PORTD4))
- #define SWITCH4 !(PIND & (1<<PORTD5))
- #define YLOS 1
- #define ALAS 0
- int main(void){
- unsigned char luku = 0, suunta=0;
- unsigned int viive=50;
- DDRB = 0xFF;
- PORTB= 0xFF;
- DDRD = 0x40;
- PORTD= 0x7C;
- luku = 0x01;
- while(1){
- PORTB=~luku;
- _delay_ms(viive);
- if(suunta == YLOS){
- luku++;
- }
- if(suunta == ALAS){
- luku--;
- }
- if(luku==255){
- suunta = ALAS;
- }
- if(luku==0){
- suunta = YLOS;
- }
- if(SWITCH3==0){
- suunta = ALAS;
- }
- if(SWITCH4==0){
- suunta = YLOS;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement