Костюм робота-инопланетянина с планеты Железяка для новогоднего утренника:
/*
Robot_Lev
*/
// constants won't change. They're used here to
// set pin numbers:
const int ledPin1 = 8; // the number of the LED pin
const int ledPin2 = 9; // the number of the LED pin
const int ledPin3 = 10; // the number of the LED pin
const int ledPin4 = 11; // the number of the LED pin
const int ledPin5 = 12; // the number of the LED pin
int ledState = LOW;
long randNumber;
void setup() {
Initialize();
}
void loop(){
randNumber = random(1000);
if (randNumber > 500) {
digitalWrite(ledPin1, HIGH);
}
else
{
digitalWrite(ledPin1, LOW);
}
randNumber = random(1000);
if (randNumber > 500) {
digitalWrite(ledPin2, HIGH);
}
else
{
digitalWrite(ledPin2, LOW);
}
randNumber = random(1000);
if (randNumber > 500) {
digitalWrite(ledPin3, HIGH);
}
else
{
digitalWrite(ledPin3, LOW);
}
randNumber = random(1000);
if (randNumber > 500) {
digitalWrite(ledPin4, HIGH);
}
else
{
digitalWrite(ledPin4, LOW);
}
randNumber = random(1000);
if (randNumber > 500) {
digitalWrite(ledPin5, HIGH);
}
else
{
digitalWrite(ledPin5, LOW);
}
delay(300);
}
void Initialize()
{
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
randomSeed(analogRead(0));
}