Skip to content

Commit

Permalink
Add example for working with 1 digit 7 digit display
Browse files Browse the repository at this point in the history
  • Loading branch information
mur4ik18 committed Jul 29, 2023
1 parent 74628c6 commit aa8da34
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ EXAMPLS = ./examples
# Names what you can use:
# - blink
# - shift_register
# - 1dig_7seg_display
# --------------------------------------------------------------------------------------------------------------------
OUTNAME = shift_register
OUTNAME = 1dig_7seg_display

OUTBIN = $(OUTPATH)/$(OUTNAME).bin
OUTHEX = $(OUTPATH)/$(OUTNAME).hex
Expand Down
49 changes: 49 additions & 0 deletions examples/1dig_7seg_display.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#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) {
// show all figures
uint8_t i = 0;
for (i; i<=9; i++) {
setNumber(dataPin, clockPin, latchPin, i);
print(i);
_delay_ms(1000);
}

// show infinity
while (1) {
setByte(dataPin, clockPin, latchPin, 0b00000001);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00000011);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10000010);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10100000);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00110000);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b00010100);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b10000100);
_delay_ms(50);
setByte(dataPin, clockPin, latchPin, 0b11000000);
_delay_ms(50);
}
}
return 1;
}
1 change: 1 addition & 0 deletions lib/Mega2560.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define __ATmegaxx0__
#include "UART_driver.h"
#include "lib_74HC595.h"
#include "dig_7seg_display.h"

#define ON true
#define OFF false
Expand Down

0 comments on commit aa8da34

Please sign in to comment.