Код: Выделить всё
#define FIRST_LED_PIN 9
#define LAST_LED_PIN 13
const int buttonPin = 8; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
for (int pin = FIRST_LED_PIN; pin <= LAST_LED_PIN; ++pin)
pinMode(pin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(buttonPin, HIGH);
}
void loop() {
buttonState = digitalRead(buttonPin);
unsigned long int buttonState = millis();
int FAN;
if (digitalRead(buttonPin) == HIGH) {
FAN = LAST_LED_PIN - (buttonState / 120) % 10;
int pin = FAN;
digitalWrite(pin, HIGH);
delay(10);
digitalWrite(pin, LOW);
}
}
Код: Выделить всё
#define FIRST_LED_PIN 2
#define LAST_LED_PIN 6
const int buttonPin = 7; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
void setup()
{
for (int pin = FIRST_LED_PIN; pin <= LAST_LED_PIN; ++pin)
pinMode(pin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(buttonPin, HIGH);
}
void loop() {
buttonState = digitalRead(buttonPin);
unsigned long int buttonState = millis();
int SOLDER;
if (digitalRead(buttonPin) == HIGH) {
SOLDER = FIRST_LED_PIN + (buttonState / 120) % 10;
int pin = SOLDER;
digitalWrite(pin, HIGH);
delay(10);
digitalWrite(pin, LOW);
}
}