5082-7010
Připojení k Arduinu
Pin 5082-7010 | Název pinu 5082-7010 | Pin Arduino |
---|
1 | INPUT 1 | D2 |
2 | VDP | D6 |
3 | VLED | 5V |
4 | INPUT 8 | D3 |
5 | INPUT 4 | D4 |
6 | GND | GND |
7 | VCC | 5V |
8 | INPUT 2 | D5 |
Zdrojový kód pro Arduino
#define INPUT_1 2
#define INPUT_2 3
#define INPUT_4 4
#define INPUT_8 5
#define DEC_POINT 6
void setup ()
{
pinMode (DEC_POINT, OUTPUT);
pinMode (INPUT_1, OUTPUT);
pinMode (INPUT_2, OUTPUT);
pinMode (INPUT_4, OUTPUT);
pinMode (INPUT_8, OUTPUT);
}
void loop ()
{
for (byte j = 15; j > 5; --j) {
display (j, false);
delay(300);
}
}
void display (uint8_t value, bool dec_point)
{
if (dec_point == true) {
digitalWrite (DEC_POINT, LOW);
} else {
digitalWrite (DEC_POINT, HIGH);
}
digitalWrite (INPUT_1, bitRead (value, 0));
digitalWrite (INPUT_2, bitRead (value, 1));
digitalWrite (INPUT_4, bitRead (value, 2));
digitalWrite (INPUT_8, bitRead (value, 3));
}
Demo video