Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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