NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


unsigned int timeShowRandom = 60000; // Délka svícení
struct BUTTON // Funkce tlačítka
{
byte pin; // Pin kde jsou tlačítka
int lastButtonState; // Poslední poloha tlačítka
byte numRandom; // Počet random LEDs.
};

// 5 tlačítek určující počet výtězů
BUTTON buttons[] =
{
{A0, LOW, 1},
{A1, LOW, 2},
{A2, LOW, 3},
{A3, LOW, 4},
{A4, LOW, 5},
};

// Počet náhodných LED
byte numLeds = 0;

// Počet pinů LEDs
const byte ledPins[] = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,};
byte ledStates[sizeof(ledPins)];

void setup()
{
randomSeed( analogRead (A7) );
// Rychlost
Serial.begin(57600);

// Všechny piny nastav na vstup
for (byte btnCnt = 0; btnCnt < sizeof(buttons) / sizeof(buttons[0]); btnCnt++)
{
pinMode(buttons[btnCnt].pin, INPUT);
}


for (byte ledCnt = 0; ledCnt < sizeof(ledPins); ledCnt++)
{

digitalWrite(ledPins[ledCnt], LOW);


pinMode(ledPins[ledCnt], OUTPUT);
}
}

void loop()
{
// reset numLeds
numLeds = 0;

int buttonState;

// Kontrola tlačítka
for (byte btnCnt = 0; btnCnt < sizeof(buttons) / sizeof(buttons[0]); btnCnt++)
{
buttonState = digitalRead(buttons[btnCnt].pin);
// Pokud se stav tlačítka změní
if (buttons[btnCnt].lastButtonState != buttonState)
{
// Uložit novou pozici tlačítka
buttons[btnCnt].lastButtonState = buttonState;

// Debug
Serial.print(" Poloha tlačítka se změnila z "); Serial.print(buttons[btnCnt].lastButtonState);
Serial.print(" na "); Serial.println(buttonState);

// Pokud je tlačítko povoleno
if (buttonState == LOW)
{
numLeds = buttons[btnCnt].numRandom;
}
}
}

// Pokod bylo indikováno víc než 0 random LEDs
if (numLeds != 0)
{
// Ukaž N random LEDs
randomLeds();
Serial.print("načítám "); Serial.print(timeShowRandom);
Serial.println(" ms");
delay(timeShowRandom);
Serial.println("načítání dokončeno, vypínám LEDs ");
for (byte ledCnt = 0; ledCnt < sizeof(ledPins); ledCnt++)
{
digitalWrite(ledPins[ledCnt], LOW);
}
}

// Delay na vzpamatování
delay(100);
}


void randomLeds()
{
memset(ledStates, LOW, sizeof(ledStates));
byte onCount = 0;

while (onCount != numLeds)
{
int randomNumber = random(0, sizeof(ledStates));
if (ledStates[randomNumber] != HIGH)
{
ledStates[randomNumber] = HIGH;
onCount++;
}
}
for (byte ledCnt = 0; ledCnt < sizeof(ledStates); ledCnt++)
{
// Debug
Serial.print(ledStates[ledCnt] == LOW ? " OFF" : " ON ");
digitalWrite(ledPins[ledCnt], ledStates[ledCnt]);
}
// Debug; nový řádek serial printu
Serial.println();
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.