Professional Documents
Culture Documents
Microcontroladores
Ejemplos de aplicación
main:
high 0
wait 1
low 0
wait 1
goto main
main:
for contador = 1 to 15 ‘ inicio del lazo for...next
high LED ‘ pone el pin 4 a alto
pause 500 ‘ espera por 0.5 segundo
low LED ‘ pone el pin 7 a bajo
pause 500 ‘ espera por 0.5 segundo
next contador ‘ fin del del lazo for...next
end ‘ fin del programa
Carlos E. Canto Quintal M.C.
EL PICAXE
Microcontroladores
main:
sound 2,(50,100) ‘ frecuencia 50, duración 100
sound 2,(100,100) ‘ frecuencia 100, duración 100
sound 2,(120,100) ‘ frecuencia 120, duración 100
pause 1000 ‘ espera 1 segundo
goto main ‘ regresa al inicio
play
Syntax:
PLAY tune,LED
- Tune is a variable/constant (0 - 3) which specifies which tune to play
0 - Happy Birthday
1 - Jingle Bells
2 - Silent Night
3 - Rudolf the Red Nosed Reindeer
- LED is a variable/constant (0 -3) which specifies if other outputs flash at the same time as the tune is
being played.
0 - No outputs
1 - Output 0 flashes on and off
2 - Output 4 flashes on and off
3 - Output 0 and 4 flash alternately
Function:
Play an internal tune on the PICAXE-08M (i/o pin2).
Description:
The PICAXE-08M can play musical tones. The PICAXE-08M is supplied with 4 pre-programmed
internal tunes, which can be output via the play command. As these tunes are included within the
PICAXE-08M bootstrap code, they use very little program memory. To generate your own tunes
use the ‘tune’ command, although this requires a much greater amount of program memeory.
See the Tune command for suitable piezo / speaker circuits.
Affect of increased clock speed:
The tempo (speed) of the tune is doubled at 8MHz!
Example:
play 3,1 ‘ rudolf red nosed reindeer with output 0 flashingpoke
A commonly used device, the ORP-12, has a high resistance in the dark, and a low
resistance in the light.
Connecting the LDR to the microcontroller is very straight forward, but some software
‘calibrating’ is required.
It should be remembered that the LDR response is not linear, and so the readings will not
change in exactly the same way as with a potentiometer.
In general there is a larger resistance change at brighter light levels. This can be
compensated for in the software by using a smaller range at darker light levels.
Experiment to find the most appropriate settings for the circuit.
It’s resistance changes with light level. In bright light its resistance is low (typically
around 1k). In darkness its resistance is high (typically around 1M)
El PICAXE-08
El PICAXE-08
Procesador Real PIC 12F629-I/P
Memoria de Programa 128 bytes
Límite del tamaño del
código fuente 40 líneas promedio
Salidas digitales 4 líneas, una fija, 3 de acceso programable individualmente o todas las
líneas. Capacidad de manejo directo de LEDs/ piezoeléctrico
Entradas Digitales 4 líneas, una fija, 3 de acceso programable individual o todas las líneas
Entradas Analógicas 1 línea que corresponde a una línea de las entradas digitales
Resolución Análoga 4 bits el 30% del voltaje alto de entrada no se usa
Salida Análoga No – ver salida PWM
Salida PWM Cualquiera de las 4 salidas digitales . Sólamnente mientras se ejecuta el
comando PWM
Entrada Serial Cualquiera de las 4 entradas digitales Máximo 2400 bps
Salida Serial Cualquiera de las 4 salidas digitales. Máximo 2400 bps
Oscilador Interno 4MHz RC
Carlos E. Canto Quintal M.C.
EL PICAXE
Microcontroladores
ENTRADA ANÁLOGA
READADC Lee el canal análogo a una variable. Read 1, b0 lee el pin 1 análogo a b0
FLUJO DE PROGRAMA
FOR.. NEXT Establish a FOR-NEXT loop. For b1=0 to 100 step 10 Counts in tens
BRANCH Jump to address specified by offset
GOTO Jump to address. If b1=5 goto motoroff
GOSUB Jump to subroutine at address.
RETURN Return from subroutine
IF.. THEN Compare and conditionally jump
MANIPULACIÓN DE VARIABLES
{LET} Perform variable mathematics.
LOOKUP Lookup data specified by offset and store in variable.
LOOKDOWN Find target’s match number (0-N) and store in variable
RANDOM Generate a pseudo-random number
SERIAL I/O
SEROUT Output serial data from output pin. Serout 0, n2400, (65) pin 0, 2400 bps, send
ASCII 65
SERIN Serial input data on input pin. Serin 0, n2400, ("A") pin 0, 2400 bps, waits for
ASCII 65