LED Blink program
TRISA = %000000
TRISB.5 = 0
loop:
PORTA = %111111
PORTB.5 = 1
WaitMs 1
PORTA = %000000
PORTB.5 = 0
WaitMs 1
Goto loop
Comment
Comments in basic language are denoted with a single quote (apostrophe) ( ' ) or inverted comm.
Comments don't consume any resources. Most programmers will agree that you will never save time by omitting a comment. A well-written program devotes more space to comments than to code. Our recommendation is to shrink your code and expand your comments.
How to set microcontroller pins High and Low?
TRISB = %00000000 'set PORTB Output
TRISD = 0b0000000 'set portd as output
main:
High PORTB.0
WaitMs 2
Low PORTB.0
WaitMs 2
GoTo main
Toggle
TRISB = %00000000 'set PORTB Output
TRISD = 0b0000000 'set portd as output
main:
Toggle PORTB.5
WaitMs 2
GoTo main
While loop
TRISB = 0b00000001
TRISD = %00000000
Loop:
While PORTB.0 = 1
PORTB = 0b11111110
PORTD = 0b11111111
WaitMs 2
PORTB = 0b00000000
PORTD = 0b00000000
WaitMs 2
Wend
GoTo Loop
Blogger Comment
Facebook Comment