Add the 74HC595 Snake game project
This commit is contained in:
21
08-74HC595-Snake/IC74HC595.cpp
Normal file
21
08-74HC595-Snake/IC74HC595.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <Arduino.h>
|
||||
#include "IC74HC595.h"
|
||||
#include "error.h"
|
||||
|
||||
IC74HC595 matrixcols = {PIN_74HC595_MATRIX_UPDATE, PIN_74HC595_MATRIX_DATA, PIN_74HC595_MATRIX_CLOCK};
|
||||
IC74HC595 scoreboard = {PIN_74HC595_SCOREBOARD_UPDATE, PIN_74HC595_SCOREBOARD_DATA, PIN_74HC595_SCOREBOARD_CLOCK};
|
||||
|
||||
int init74HC595(IC74HC595 *sr) {
|
||||
pinMode(sr->updatepin, OUTPUT);
|
||||
pinMode(sr->clockpin, OUTPUT);
|
||||
pinMode(sr->datapin, OUTPUT);
|
||||
return ERRNO_SUCCESS;
|
||||
}
|
||||
|
||||
int writeIC74HC595Char(IC74HC595 *sr, uint8_t value, uint8_t order)
|
||||
{
|
||||
digitalWrite(sr->updatepin, LOW);
|
||||
shiftOut(sr->datapin, sr->clockpin, order, value);
|
||||
digitalWrite(sr->updatepin, HIGH);
|
||||
return ERRNO_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user