Created
March 19, 2012 17:49
-
-
Save lg188/2121203 to your computer and use it in GitHub Desktop.
Bascom-AVR Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'Requires m328pdef.dat found on the internet | |
'P1 | |
'HARDWARE--------------------------------------------------------------------- | |
$regfile = "m328pdef.dat" | |
$crystal = 160000000 | |
'++++++++OUTPUTS-------------------------------------------------------------- | |
'> portD.6 Red | |
'> portD.5 Green | |
'> portD.3 Blue | |
'+++++++INPUTS---------------------------------------------------------------- | |
'< portC.5 BUTTON 1 | |
'< portC.4 BUTTON 2 | |
'< portC.3 BUTTON 3 | |
'< portC.2 BUTTON 4 | |
'+++++++I/O--------------------------------------------------------------------- | |
Config Portd = &b00110100 | |
Config Portc = &b00011110 | |
'PROGRAM----------------------------------------------------------------------- | |
'+++++++VARIABLES-------------------------------------------------------------- | |
Dim I As Byte , Temp As Byte | |
'+++++++TIMERS----------------------------------------------------------------- | |
Config Timer0 = Pwm , Prescale = 64 | |
Config Timer1 = Pwm , Prescale = 64 | |
'P2 | |
'+++++++MENU------------------------------------------------------------------- | |
Menu: | |
Debounce Pinc.5 , 1 , btn1 | |
Debounce Pinc.4 , 1 , btn2 | |
Debounce Pinc.3 , 1 , btn3 | |
Debounce Pinc.2 , 1 , btn4 | |
Return | |
'P3 | |
'+++++++BUTTON 1------------------------------------------------------------- | |
btn1: | |
Stop Timer0 | |
Stop Timer1 | |
Do | |
For I = 0 To 8 Step 1 | |
Temp = I And &B100 | |
If Temp = &B100 Then | |
Portd.6 = 1 | |
Else | |
Portd.6 = 0 | |
End If | |
Temp = I And &B010 | |
If Temp = &B010 Then | |
Portd.5 = 1 | |
Else | |
Portd.5 = 0 | |
End If | |
Temp = I And &B001 | |
If Temp = &B001 Then | |
Portd.3 = 1 | |
Else | |
Portd.3 = 0 | |
End If | |
Goto Menu | |
Next I | |
Loop | |
'P4 | |
'++++++++BUTTON 2------------------------------------------------------------- | |
btn2: | |
Start Timer0 | |
Start Timer1 | |
Do | |
For Tcnt0 = 0 To 250 Step 25 | |
For Compare1a = 0 To 1000 Step 100 | |
For Compare1b = 0 To 1000 Step 100 | |
Waitms 100 | |
Goto Menu | |
Next Compare1b | |
Next Compare1a | |
Next Tcnt0 | |
Loop | |
'P5 | |
'++++++BUTTON 3------------------------------------------------------------- | |
btn3: | |
Start Timer0 | |
Start Timer1 | |
Do | |
For I = 0 To 10 | |
Tcnt0 = Tcnt0 + 25 | |
Next I | |
For I = 0 To 10 | |
Compare1a = Compare1a + 100 | |
Next I | |
For I = 0 To 10 | |
Compare1b = Compare1b + 100 | |
Next I | |
For I = 0 To 10 | |
Tcnt0 = Tcnt0 - 25 | |
Next I | |
For I = 0 To 10 | |
Compare1a = Compare1a - 100 | |
Next I | |
Goto Menu | |
Loop | |
'+++++BUTTON 4 ------------------------------------------------------------- | |
btn4: | |
Goto Menu | |
'++++++QUIT-------------------------------------------------------------------- | |
Quit: | |
End | |
'END--------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment