Created
March 10, 2019 09:24
-
-
Save nazarov-yuriy/d045b3bbb92d31781467cbe99aa1d8d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include "avr/pgmspace.h" | |
#include "avr/io.h" | |
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) | |
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) | |
void setup() { | |
cbi (TIMSK0, TOIE0); | |
pinMode(13, OUTPUT); | |
DDRB = B00111111; | |
} | |
char c = 0; | |
void loop() { | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
PORTB = 0xff; | |
if (PORTD) { | |
PORTB = 0x00; | |
c++; | |
} else { | |
PORTB = 0x00; | |
c--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment