Entradas
Mostrando las entradas etiquetadas como BLOQUE 2
PROYECTO SIMONSAYS
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
#include < EducationShield . h > int ledPins [ ] = { 2 , 3 , 4 , 5 , 6 } ; int pinCount = 5 ; VUMeter vuMeter ; Knob pot = Knob ( A0 ) ; Button button = Button ( 9 ) ; Melody piezo = Melody ( 8 ) ; int turns_begin = 2 ; int turns_max = 10 ; int game [ 10 ] ; int turns = 2 ; int blinkTime = 500 ; void setup ( ) { vuMeter . config ( pinCount , ledPins ) ; vuMeter . begin ( ) ; pot . setLevels ( 5 ) ; button . begin ( ) ; randomSeed ( analogRead ( A5 ) ) ; } void loop ( ) { newGame ( ) ; simonSays ( ) ; delay ( 1000 ) ; getInputs ( ) ; } void newGame ( ) { vuMeter . blinkAll ( 200 , 3 ) ; vuMeter . clear ( ) ; delay ( 500 ) ; for ( int i = 0 ; i < turns ; i ++ ) { game [ i ] = random ( pinCount ) ; } } void simonSays ( ) { for ( int i ...
ENTRADAS DIGITALES 3, 4 Y 5
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
Por último, cambiamos el código para que podamos encender 1 LED o 3 LEDS a la vez con el botón, o que suene una melodía en el piezo. CÓDIGO DEL ÚNICO LED: int inputPin = 6 ; int ledPin = 13 ; void setup ( ) { pinMode ( inputPin , INPUT ) ; pinMode ( ledPin , OUTPUT ) ; } void loop ( ) { if ( digitalRead ( inputPin ) == HIGH ) { digitalWrite ( ledPin , HIGH ) ; } else { digitalWrite ( ledPin , LOW ) ; } } CÓDIGO DE LOS 3 LEDS: #include < EducationShield . h > VUMeter me ; int inputPin = 6 ; int pins [ ] = { 2 , 3 , 4 } ; int pinCount = 3 ; void setup ( ) { me . config ( pinCount , pins ) ; me . begin ( ) ; pinMode ( inputPin , INPUT ) ; pinMode ( pinCount , OUTPUT ) ; } void loop ( ) { if ( digitalRead ( inputPin ) == HIGH ) { me . on ( 0 ) ; me . on ( 1 ) ; me . on ( 2 ) ; } else { me . off ( 0 ) ; me . off ( 1 ) ; me . off ( 2 ) ; } } ...
ENTRADAS DIGITALES 2
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
En la siguiente actividad, conseguimos activar un LED de la placa con el botón int inputPin = 6 ; int ledPin = 13 ; void setup ( ) { pinMode ( inputPin , INPUT ) ; pinMode ( ledPin , OUTPUT ) ; } void loop ( ) { if ( digitalRead ( inputPin ) == HIGH ) { digitalWrite ( ledPin , HIGH ) ; } else { digitalWrite ( ledPin , LOW ) ; } }
ENTRADAS DIGITALES 1
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
En esta práctica encendemos y apagamos un LED conectando y desconectando un cable. int inputPin = 5 ; int ledPin = 13 ; void setup ( ) { pinMode ( inputPin , INPUT ) ; pinMode ( ledPin , OUTPUT ) ; } void loop ( ) { if ( digitalRead ( inputPin ) == HIGH ) { digitalWrite ( ledPin , HIGH ) ; } else { digitalWrite ( ledPin , LOW ) ; } }
MELODÍA DE BEEP
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones
void setup ( ) { tone ( 8 , 392 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 500 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 700 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 500 ) ; delay ( 300 ) ; tone ( 8 , 392 , 700 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 700 ) ; delay ( 300 ) ; tone ( 8 , 440 , 700 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 600 ) ; delay ( 400 ) ; tone ( 8 , 392 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 500 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 700 ) ; delay ( 300 ) ; tone ( 8 , 493.88 , 500 ) ; delay ( 300 ) ; tone ( 8 , 440 , 500 ) ; delay ( 300 ) ; tone ( 8 , 392 , 600 ) ; delay ( 300 ) ; tone ( 8 , 440 , 500 ) ; delay ( 300 ) ; tone ( 8 , 392 , 1000 ) ; delay ( 1000 ) ; } void loop ( ) { ...
PLACA DE ARDUINO VUMETER
- Obtener enlace
- X
- Correo electrónico
- Otras aplicaciones

VUMeter me ; int pins [ ] = { 2 , 3 , 4 , 5 , 7 } ; int pinCount = 5 ; void setup ( ) { me . config ( pinCount , pins ) ; me . begin ( ) ; void loop ( ) { me . on ( 0 ) ; delay ( 1000 ) ; me . on ( 1 ) ; delay ( 1000 ) ; me . on ( 2 ) ; delay ( 1000 ) ; me . on ( 3 ) ; delay ( 1000 ) ; me . on ( 4 ) ; me . blinkAll ( 100 , 10 ) ; delay ( 1000 ) ; me . on ( 0 ) ; delay ( 800 ) ; me . blink ( 0 , 200 , 3 ) ; delay ( 1000 ) ; me . scrollRight ( 700 , 1 ) ; delay ( 1000 ) ; me . on ( 4 ) ; delay ( 800 ) ; me . blink ( 4 , 200 , 3 ) ; delay ( 1000 ) ; me . scrollLeft ( 700 , 1 ) ; delay ( 800 ) ; me . blink ( 1 , 800 , 1 ) ; delay ( 200 ) ; me . blink ( 3 , 800 , 1 ) ; delay ( 200 ) ; me . blink ( 2 , 800 , 1 )...