const int dataPin = 0; /* DS */
const int clockPin = 1; /* SHCP */
const int latchPin = 2; /* STCP */
void setup() {
randomSeed(analogRead(A0));
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
}
void loop() {
// show(); // various
r();
}
void show() {
// int leds[] = {0xC6, 0x3A}; // 8
int leds[] = {0x80, 0x40, 0x02, 0x08, 0x10, 0x20, 0x02, 0x04}; // snake
// int leds[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04}; // circle
// int leds[] = {0x80, 0x10}; // top bottom
// int leds[] = {0x80, 0x02, 0x10, 0x02}; // wigwag top middle bottom
// int leds[] = {0x60, 0x0C}; // left right
// int leds[] = {0x40, 0x04, 0x20, 0x08}; // wave
// int leds[] = {0x48, 0x24}; // left right
// int leds[] = {0x4a, 0x26}; // H
// int leds[] = {0x46, 0x2A}; // toetouch
int num = sizeof(leds) / sizeof(leds[0]);
for (int i = 0; i < num; i++) {
byte pattern = leds[i];
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, pattern);
digitalWrite(latchPin, HIGH);
delay(100);
}
}
void r() {
byte pattern = 0b1 << random(7);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, pattern);
digitalWrite(latchPin, HIGH);
delay(250);
}
/************************************************************************************************
ATTINY85 +-- --+
PCINT5/-RESET/ADC0/dW/PB5 |1 * 8| VCC
PCINT3/XTAL1/CLKI/-OC1B/ADC3/PB3 |2 7| PB2/SCK/USCK/SCL/ADC1/T0/INT0/PCINT2
PWM4/PCINT4/XTAL2/CLKO/OC1B/ADC2/PB4 |3 6| PB1/MISO/DO/AIN1/OC0B/OC1A/PCINT1/PWM1
GND |4 5| PB0/MOSI/DI/SDA/AIN0/OC0A/-OC1A/AREF/PCINT0/PWM0
+-----+
SEGMENTS
A
---
F| G |B
---
E| |C
--- o DP
D
PINS D13 D12 D11 D10 D09 D08 | D07 D06 D05 D04 D03 D02 Tx Rx | A05 A04 A03 A02 A01 A00 RST
PORT PB5 PB4 PB3 PB2 PB1 PB0 | PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0 | PC5 PC4 PC3 PC2 PC1 PC0 PC6
SEGS - - - dp g f | e d c b a - - - - - - - - - -
************************************************************************************************/