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
/* * * NOMBRE: Cristian Valdez Bideplan * * Entrgar con nombre archivo: usr_p1.ino (val_p1.ino) * * 24/06/21 - Requerimientos * 1) Implementar un LED TEST que tenga un destello de 50ms cada 1000ms (50ms ENCENDIDO / 950ms APAGADO) * 2) Implementar un Lector de Pulsador, que permita diferenciar entre * a) Botón presiondo durante más de 1 segundo * b) 1 Toque corto de botón * c) 2 Toques cortos de botón (un tiempo inferior a 500ms entre toques) * 3) Módulo de Leds con múltiples efectos * Efecto a: Un punto que se va corriendo * b: Una barra de leds que se va completando * * PORTD --> 8 LEDs * PORTB.0 --> Pulsador * PORTB.5 --> LED_TEST / */ #define PUERTO_LEDS PORTD #define CONFIGURAR_LEDS DDRD=0XFF #define PIN_LED_TEST 8 #define CONFIGURAR_BOTON pinMode (9, INPUT) #define BOT_PRESIONADO digitalRead(9) #define CONFIGURAR_LED_TEST pinMode(PIN_LED_TEST, OUTPUT) #define ENCENDER_LED_TEST digitalWrite(PIN_LED_TEST, HIGH) #define APAGAR_LED_TEST digitalWrite(PIN_LED_TEST, LOW) #define TPO_LED_TEST_ON 50 #define TPO_LED_TEST_OFF 950 void setup() { CONFIGURAR_LED_TEST; CONFIGURAR_BOTON; PUERTO_LEDS=1; } void loop(){ SupervisaPulsador(); LedTest(); Efectos(); } void SupervisaPulsador(void) { /* Eventos * Se presionó el botón * Se superaron los 500ms con el botón presionado * Se liberó el botón antes de los 500ms * Se liberó el botón después de los 500ms * Pasaron más de 500ms desde que se liberó el botón */ static bool bot_presionado_ant1=0; static unsigned long millis_ant=0; if(BOT_PRESIONADO==bot_presionado_ant1) return; bot_presionado_ant1=BOT_PRESIONADO; if(!BOT_PRESIONADO) return; PUERTO_LEDS<<=1; } } void LedTest(void) { static bool led_encendido=false; static unsigned long millis_ant=0; static unsigned long tpo_espera_caracter=950; if(millis()- millis_ant
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)