Browse Source

loop first 4 leds

master
Tom Nordal 2 years ago
parent
commit
999f8ab443
  1. 1
      multible_led/platformio.ini
  2. 28
      multible_led/src/main.cpp

1
multible_led/platformio.ini

@ -12,3 +12,4 @@
platform = atmelavr platform = atmelavr
board = uno board = uno
framework = arduino framework = arduino
monitor_speed = 115200

28
multible_led/src/main.cpp

@ -1,18 +1,32 @@
#include <Arduino.h> #include <Arduino.h>
// put function declarations here: int ledsCount = 4;
int myFunction(int, int); int ledPins[] = {12,11,10,9};
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
int result = myFunction(2, 3); Serial.begin(115200);
Serial.println("Start Multiple Led");
for (int i = 0; i < ledsCount; i++)
{
pinMode(ledPins[i], OUTPUT);
}
} }
void loop() { void loop() {
// put your main code here, to run repeatedly: // put your main code here, to run repeatedly:
for (int i = 0; i < ledsCount; i++)
{
digitalWrite(ledPins[i], HIGH);
delay(50);
digitalWrite(ledPins[i], LOW);
}
for (int i = ledsCount -1; i >= 0; i--)
{
digitalWrite(ledPins[i], HIGH);
delay(50);
digitalWrite(ledPins[i], LOW);
} }
// put function definitions here:
int myFunction(int x, int y) {
return x + y;
} }
Loading…
Cancel
Save