Skip to content

Commit

Permalink
Write example for working with shift register
Browse files Browse the repository at this point in the history
  • Loading branch information
mur4ik18 committed Jul 28, 2023
1 parent 11f63de commit 9a3481a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ EXAMPLS = ./examples
# Here u can use different examples which you can find in examples folder
# Names what you can use:
# - blink
#
# - shift_register
# --------------------------------------------------------------------------------------------------------------------
OUTNAME = blink
OUTNAME = shift_register

OUTBIN = $(OUTPATH)/$(OUTNAME).bin
OUTHEX = $(OUTPATH)/$(OUTNAME).hex
Expand Down
26 changes: 26 additions & 0 deletions examples/shift_register.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "../lib/Mega2560.h"
#include <util/delay.h>

const uint8_t dataPin = 2;
const uint8_t latchPin = 3;
const uint8_t clockPin = 4;

void setup() {
USART_Init(MYUBRR);
print("Started");

pinMode(dataPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
}

int main(void) {
setup();
while (1) {
turn(latchPin, OFF);
shiftOut(dataPin, clockPin, 0b01111111);
turn(latchPin, ON);
_delay_ms(1000);
}
return 1;
}

0 comments on commit 9a3481a

Please sign in to comment.