Печать

В этом примере показано как плавно управлять яркостью светодиода и одновременно мигать другим светодиодом на Arduino. fading_Blink.ino распространяется в надежде, что это будет полезно, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ.

В этом скетче мы демонстрируем возможность распараллеливания задач на микроконтроллере AVR с помощью функции yield().

/* Fading and Blink
 This example shows how to smoothly adjust the brightness of an LED
 and simultaneously flash another LED.
 This is a vivid demonstration of the yield() function.

 Created on August 08, 2021.
 Author: Diorditsa A. https://adior.ru/

 fading_Blink.ino is distributed in the hope that it will be useful, but
 WITHOUT WARRANTY OF ANY KIND; not even an implied warranty
 MARKETABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 See. See the GNU General Public License for more information.
 You can get a copy of the GNU General Public License
 by link http://www.gnu.org/licenses/
*/

int ledPin = 3;                   // LED Fading

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);   // LED Blink
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

void yield(){
  int t = (millis()/100)%31-15;
  analogWrite(ledPin, t*t);
}