first test
This commit is contained in:
parent
387293af91
commit
9dceb4a7f8
2 changed files with 91 additions and 4 deletions
|
@ -8,6 +8,9 @@
|
|||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
env_default = leonardo
|
||||
|
||||
[env:attiny2313]
|
||||
platform = atmelavr
|
||||
board = attiny2313
|
||||
|
@ -18,4 +21,9 @@ upload_protocol = stk500v1
|
|||
upload_flags = -P$UPLOAD_PORT -b$UPLOAD_SPEED
|
||||
; values
|
||||
upload_port = /dev/ttyUSB0
|
||||
upload_speed = 19200
|
||||
upload_speed = 19200
|
||||
|
||||
[env:leonardo]
|
||||
platform = atmelavr
|
||||
board = leonardo
|
||||
framework = arduino
|
85
src/main.cpp
85
src/main.cpp
|
@ -1,9 +1,88 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
/*
|
||||
for cheap Chinese 64 dots LED-Projector
|
||||
|
||||
Board has unmarked chip in socket - pin layout fits to ATTiny 2313 an 4313
|
||||
the LEDS are connected to 8 pcs 74HC595
|
||||
|
||||
|
||||
--u--
|
||||
RST 1 20 VCC
|
||||
NC (0) 2 19 (16) IN SCK
|
||||
NC (1) 3 18 (15) IN MISO
|
||||
XTAL 4 17 (14) IN MOSI
|
||||
XTAL 5 16 (13) IN
|
||||
OUT (4) 6 15 (12) IN
|
||||
OUT (5) 7 14 (11) IN
|
||||
OUT (6) 8 13 (10) IN
|
||||
NC (7) 9 12 (9) MIC
|
||||
GND 10 11 (8) IN
|
||||
-----
|
||||
|
||||
() = Arduino Pins
|
||||
RST = Reset - 10K to GND, 10uF to VCC
|
||||
XTAL = 16 MHz Crystal
|
||||
IN = switches
|
||||
MIC = Input from microphone amplifier (LM358)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#define LATCHPIN 6
|
||||
#define DATAPIN 4
|
||||
#define CLOCKPIN 5
|
||||
byte ledsData[8];
|
||||
|
||||
byte currentled = 0;
|
||||
|
||||
void clear() {
|
||||
for (int i=0; i < 8; i++) {
|
||||
// low is led on
|
||||
ledsData[i] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
void writebuffer(byte ledNr) {
|
||||
byte chipNr = ledNr / 8;
|
||||
byte pinNr = ledNr % 8;
|
||||
if(chipNr < 8) {
|
||||
bitWrite(ledsData[chipNr], pinNr, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
void writexy(byte x, byte y) {
|
||||
byte lednr = x*8 + y;
|
||||
writebuffer(lednr);
|
||||
}
|
||||
|
||||
void pushout() {
|
||||
digitalWrite(LATCHPIN, LOW);
|
||||
for(int i = 8-1; i>=0; i--) {
|
||||
shiftOut(DATAPIN, CLOCKPIN, MSBFIRST, ledsData[i]);
|
||||
}
|
||||
digitalWrite(LATCHPIN, HIGH);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
pinMode(LATCHPIN, OUTPUT);
|
||||
pinMode(DATAPIN, OUTPUT);
|
||||
pinMode(CLOCKPIN, OUTPUT);
|
||||
|
||||
clear();
|
||||
pushout();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
clear();
|
||||
writebuffer(currentled);
|
||||
|
||||
pushout();
|
||||
|
||||
currentled++;
|
||||
if (currentled >=64) {
|
||||
currentled = 0;
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue