Welcome Anonymous
Fledgling
Fledgling
It is currently Mon Sep 25, 2017 2:04 am

All times are



Post new topic Reply to topic  [ Array ] 
Author Message
PostPosted: Tue Jun 29, 2010 3:32 pm 
Offline
Galapagos
Galapagos

Joined: Sun Jan 31, 2010 9:02 pm
Posts: 114
Image
Code:
'This routine is how I calibrate my light detector circuit (shown above). I put the circuit outside and count
'the LED flashes when its just too dark for pics. I use this for movie mode. Here's what
'you will see. At startup, there will be 10 quick flashes. This lets you know you are
'beginning. Then there is a pause for 2.3 seconds. Then the number of flashes for the
'hundreds digit take place. Then 3 quick flashes tell you the next is tens digit. Then
'3 quick flashes and the ones digit.
'EXAMPLE #1: Light level measures 214
'      10 quick flashes, 2.3 second delay,2 longer flashes (100s),3 quick flashes, 1 longer flash (10s)
'      3 quick flashes, 4 longer flashes, 3 quick flashes, then 5 second pause.  REPEAT
'
'EXAMPLE #2: Light level measures 072
'      10 quick flashes, 2.3 second delay,0 longer flashes (100s),3 quick flashes, 7 longer flash (10s)
'      3 quick flashes, 2 longer flashes, 3 quick flashes, then 5 second pause.  REPEAT


low 4
input 2                  

b0 = 0
b1 = 0

Do
   for b5 = 1 to 10      'this routine gives 10 quick flashes
      high 4
      pause 100
      low 4
      pause 100
   next b5
   sleep 1         '2.3 second wait
   readadc 2,b1      'read light level on pin2
   'b1 = 154                               'change the value to test
   
    if b1 > 99 then      'hundreds digit flash
      b1 = b1 - 100
      high 4
      pause 300
      low 4
      pause 300
   end if
   if b1 > 99 then      'hundreds digit flash
      b1 = b1 - 100
      high 4
      pause 300
      low 4
      pause 300
   end if
   
   gosub quickflash      '3 quick flashes to indicate hundreds digit done
   
   if b1 > 9 then      'tens digit flash
      do until b1 < 10
         b1 = b1 - 10
         high 4
         pause 300
         low 4
         pause 300
      loop
   end if
   
   gosub quickflash      '3 quick flashes to indicate tens digit done
   
   if b1 > 0 then      'ones digit flash
      do until b1 < 1
         b1 = b1 - 1
         high 4
         pause 300
         low 4
         pause 300
      loop
   end if
   
   gosub quickflash      ''3 quick flashes to indicate ones digit done
   
   sleep 2
loop
quickflash:
   pause 1000         '1 second pause
   for b5 = 1 to 3      '3 quick flashes
      high 4
      pause 100
      low 4
      pause 100
   next b5
   
   pause 1000         '1 second pause
return


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 29, 2010 4:28 pm 
Offline
Moderator
Moderator

Joined: Sun Jan 31, 2010 9:07 pm
Posts: 3334
Location: Central PA near PSU
That's interesting. Why the 100's digit twice?


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 29, 2010 4:37 pm 
Offline
Galapagos
Galapagos

Joined: Sun Jan 31, 2010 9:02 pm
Posts: 114
The possibilities for 100s is 0,1, or 2. Rather than use a loop like I did for the others, I just did it with straight code. It could be done in a loop too. I just have never changed it. I use this to keep from taking movies in the dark.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 29, 2010 5:30 pm 
Offline
Moderator
Moderator

Joined: Sun Jan 31, 2010 9:07 pm
Posts: 3334
Location: Central PA near PSU
Good thinking.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ Array ] 

All times are


Who is online

Array


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® Forum Software © phpBB Group