Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
//Blink Incremental /*Iniciar con un led destellando en modo (a), luego de 10seg cambiar el destello a modo (b), y 5 segundos más tarde cambiar el destello al modo (c), luego de 5 segundos, repetir el ciclo, es decir retornar el destello al modo (a). Modos: a) t_on=200ms, período= 3seg (t_off=2800ms apagado) b) t_on=250ms, periodo= 1seg (t_off=750ms apagado) c) t_on=500ms, periodo= 1seg (t_off=500ms apagado)*/ #define PIN_LED 13 #define CONFIGURAR_LED pinMode(PIN_LED, OUTPUT) #define ENCENDER_LED digitalWrite(PIN_LED, HIGH) #define APAGAR_LED digitalWrite(PIN_LED, LOW) int modo = 0; void setup() { CONFIGURAR_LED; ENCENDER_LED; Serial.begin(9600); Serial.println("Iniciado..."); } void loop() { Modo(); Led(); delay(10); } void Modo (void) { const unsigned int modoA = 10000 , modoB = 5000 , modoC = 5000; static unsigned long millis_modo=0; static unsigned long tpo_modo= modoA; if(millis()- millis_modo < tpo_modo) return; millis_modo = millis(); modo++; switch(modo) { case 1: tpo_modo = modoB; break; case 2: tpo_modo = modoC; break; default: modo=0; tpo_modo = modoA; break; } Serial.print("modo: "); Serial.println(modo); } void Led(void) { const unsigned int t_offA = 2800 , t_onA = 200 , t_offB = 750 , t_onB= 250 , t_offC = 500 , t_onC = 500; static bool estado=1; static unsigned long millis_ant = 0; static unsigned long tpo_espera = t_onA; if(millis() - millis_ant < tpo_espera) return; millis_ant = millis(); estado = !estado; switch (modo) { case 0: tpo_espera = estado ? t_onA : t_offA; break; case 1: tpo_espera = estado ? t_onB : t_offB; break; case 2: tpo_espera = estado ? t_onC : t_offC; break; } if(estado) ENCENDER_LED; else APAGAR_LED; } //Sketch=2658 --> 2642 //Var. Globales=226 --> 226
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)