domingo, 15 de diciembre de 2013

Practica 9. Control remoto "irin" (Mando SONY)

1. CONTROL DE MOTORES DE UN VEHÍCULO

Esta práctica emplea un sensor de infrarrojos controlado mediante un mando a distancia compatible SONY. En función de la tecla pulsada, el programa nos muestra mediante el comando irin, un valor asociado a ese botón.
Por lo tanto podemos programar para que dependiendo de la pulsación, el programa realice una función u otra.



Código del programa "Control Display"

output B.0
output B.1
output B.2
output B.3
output B.4
output B.5
output B.6
output B.7
inicio:
irin[200],C.1,b0 'Leemos el valor del sensor Control Remoto conectado a la entrada C.0
debug  bo   'Se lo asignamos a la variable b0 y mostramos en pantalla
if b0 =9 then goto num_0 'segun la tecla pulsada va a un numero u otro
if b0 =0 then goto num_1
if b0 =1 then goto num_2
if b0 =2 then goto num_3
if b0 =3 then goto num_4
if b0 =4 then goto num_5
if b0 =5 then goto num_6
if b0 =6 then goto num_7
if b0 =7 then goto num_8
if b0 =8 then goto num_9
goto inicio
numeros_atras: 'Let pins =%B7B6B5B4B3B2B1B0 (B.4-B.7 low significa 1)
num_9:
let pins = %10010111 '9
goto inicio
num_8:
let pins = %10001111 '8
goto inicio
num_7:
let pins = %11010111 '7
goto inicio
num_6:
let pins = %10001101 '6
goto inicio
num_5:
let pins = %10011101 '5
goto inicio
num_4:
let pins = %10010110 '4
goto inicio
num_3:
let pins = %10111111 '3
goto inicio
num_2:
let pins = %10101011 '2
goto inicio
num_1:
let pins = %11110110 '1
goto inicio
num_0_:
let pins = %11001111 '0
goto inicio


Programa "Contorl de motores de un vehículo"

inicio:
irin[200],C.1,b0 'Leemos el valor del sensor Control Remoto conectado a la entrada C.0
debug  bo   'Se lo asignamos a la variable b0 y mostramos en pantalla
'segun la tecla pulsada hace una funcion u otra
if b0 =0 then goto izquierda
if b0 =1 then goto derecha
if b0 =2 then goto avanza
if b0 =3 then goto retrocede
if b0 =4 then goto para
goto inicio

iquierda:
high B.4  'Motor 1 avanza
Low B.5
high B.6   'Motor 2 parado
high B.7
goto inicio

derecha:
high B.4  'Motor 1 parado
high B.5
high B.6   'Motor 2 avanza
low B.7
goto inicio

avanza:
high B.4  'Motor 1 avanza
Low B.5
high B.6   'Motor 2 avanza
low B.7
goto inicio

retrocede:
low B.4  'Motor 1 retrocede
high B.5
high B.6   'Motor 2 retrocede
low B.7
goto inicio

para:
low B.4  'Motor 1 parado
low B.5
high B.6   'Motor 2 parado
high B.7
goto inicio



No hay comentarios:

Publicar un comentario

En este espacio puedes comentar la entrada publicada o hacer preguntas o sugerencias