BasicMicroUK - Forums
It is currently Mon Oct 22, 2018 3:10 am

All times are UTC [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Demo Code for Pro28/40 on Atom Lab Board
PostPosted: Mon Jul 27, 2009 4:45 am 

Joined: Mon Aug 18, 2008 1:26 am
Posts: 799
Location: CA bay Area
This is available as demo code for the AtomPro28 in the BasicATOM Lab Board. I found copying this straight from the PDF document produced problems with quote marks ("") and I felt it could use a little more commenting. I added a few notes in the wiring info and at the ADIN line about minor changes to make the original code work with a Pro40 module, for which there is no data sheet yet. Basically, you have to move one wire and change a P# to do the ADC input. Other than that, it's the same.
;Demo code for AtomPro28/40. Pay attention to Wiring and Code Notes/Comments!
;AX3 to POT, In the program this is called "P19"(Pro28) or "P31"(Pro40) for control purposes
;AX0 (P16 on Pro40!) to LED1, In the program, this is called "P16" for control purposes
;P15 to LED2
;P14 to LED3
;P13 to LED4
;P12 to Button1
;P11 to Button2
;P10 to Buzzer/Speaker
;P9 to Button3
;P8 to Button4
;Setup LCD
lcdinit p0p1p7p6p5p4,p2
lcdwrite p0p1p7p6p5p4,p2,[LCDCLEAR,LCDHOME,SCR,TWOLINE,"Hello World"]
;Set pins to known state
low p16  ; LED1 is ON
low p15  ; LED2 is ON
low p14  ; LED3 is on
low p13  ; LED4 is ON
high p3  ; LCD backlight is on
;Setup 32 bit variable
temp var long
cnt var long
;Start main program loop
cnt=cnt+1  ; increment "cnt"

;Read analog pin and display value to LCD
adin P19,temp  ; Use P19 for the Pro28, P31 for the Pro40
lcdwrite p0p1p7p6p5p4,p2,[SCRRAM+40, "temp(R14): ", dec4 temp4]
;Send analog reading and cnt value to terminal window set to 9600 baud
serout S_OUT,i9600,["temp: ", dec temp," cnt: ", dec cnt, 13]
;Copy state of button to LED on/off
out16=in12  ; Button1 controls LED1
out15=in11  ; Button2 controls LED2
out14=in9   ; Button3 controls LED3
out13=in8   ; Button4 controls LED4
out3=In8    ; Button4 controls LCD backlight
; If button 4 is pressed make sound with buzzer
if(in8)then  ; You don't have to say "if(in8)=1"!
   low p10
   high p10
; Return to main loop
goto main

Take care.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC [ DST ]

Who is online

Users browsing this forum: No registered users and 0 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group