Skip to content

Instantly share code, notes, and snippets.

@nazarov-yuriy
Created March 10, 2019 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nazarov-yuriy/d045b3bbb92d31781467cbe99aa1d8d3 to your computer and use it in GitHub Desktop.
Save nazarov-yuriy/d045b3bbb92d31781467cbe99aa1d8d3 to your computer and use it in GitHub Desktop.
#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