led chaser

jinx

Senior Member
hi,
am working on my luna bot led display just adding more effects, now the leds are spread across both C and B pins, the way am writing the code is makes for long read addressing individual pins
Code:
; *******************************
; ***** Sample Header File  *****
; *******************************
;    Filename: luna cylon(LED		
;    Date: 	july 26 '12		
;    File Version: rev0.1	
;    Written by: 	jinx	
;    Function: bot visaul output/display		
;    Last Revision:
;    Target PICAXE:	
; ******************************* 




 #Picaxe 20X2
#No_Table
#No_Data
symbol led1 = c.1
symbol led2 = c.0
symbol led3 = b.0
symbol led4 = b.1
symbol led5 = c.5      'pwm
symbol led6 = b.2
symbol led7 = b.3
symbol led8 = b.4
symbol led9 = b.6


symbol counter = b1
symbol abit = 50
symbol abitx = b4
symbol abity = b5

init: pause 100
  HI2cSetup i2cslave, %11100000
   
  main:
   Do
    low led1,led2,led3,led4,led5,led6,led7,led8,led9
     pause 30
    Get 0, b3
    Get 8,abitx
    Get 16,abity
    sertxd(" received cmd ",#b3,13,10)
    if b3 = 1 then ld1
    if b3 = 2 then ld2
    if b3 = 3 then ld3
    if b3 = 4 then ld4
    if b3 = 5 then ld5
    if b3 = 6 then ld6
    
    if b3 = 10  Then  cylon1 
    if b3 = 30 then split
    if b3 = 100  then Rsplit
    if b3 = 15  then Lsplit
    pause 10
    
   Loop
  
  
  

        
     split:    
   for counter = 1 to 6     
  
   high led9
   high led1
   pause abit
   low led9
   low led1
   pause abit
   high led8
   high led2
   pause abit
   low led8
   low led2
   pause abit
     high led7
   high led3
   pause abit
   low led7
   low led3
   pause abit
   high led6
   high led4
   pause abit
   low led6
   low led4
   pause abit
   high led5
   pause abit
   low led5
   pause abit
   high led6
   high led4
   pause abit
   low led6
   low led4
   pause abit
   high led7
   high led3
   pause abit
   low led7
   low led3
   pause abit
     high led8
   high led2
   pause abit
   low led8
   low led2
   pause abit
   next counter
    b3= b3+1
    pause 10

return
   
   
  
cylon:
 high led1
pause abitx
low led1
pause abitx
high led2
pause abitx
low led2
pause abitx
high led3
pause abitx
low led3
pause abitx
high led4
pause abitx
low led4
pause abitx
high led5
pause abitx
low led5
pause abitx
high led6
pause abitx
low led6
pause abitx
high led7
pause abitx
low led7
pause abitx
high led8
pause abitx
low led8
pause abitx
high led9
pause abitx
low led9
pause abitx
high led8
pause abitx
low led8
pause abitx
high led7
pause abitx
low led7
pause abitx
high led6
pause abitx
low led6
pause abitx
 high led5
pause abitx
low led5
pause abitx
high led4
pause abitx
low led4
pause abitx
high led3
pause abitx
low led3
pause abitx
high led2
pause abitx
low led2
pause abitx
high led1
pause abitx
low led1
pause abitx


 b3 = b3+1
return
  
  Rsplit:
         high led1
     pause abitx
     high led2
     pause abitx
     high led3
     pause abitx
      high led4
     pause abitx
     high led5
     pause abitx
  
 b3= b3+1
 pause abitx
return
  
    Lsplit:
         high led9
     pause abitx
     high led8
     pause abitx
     high led7
     pause abitx
      high led6
     pause abitx
     high led5
     pause abitx
  
 b3= b3+1
return
  
  
  
  srftk:for counter = 1 to 4
      pause 10
      high led5
      pause abity
      high led4
      pause abity
      high led3
      pause abity
       high led2
      pause abity
      high led1
      pause abity
       low led1
         pause abity
       low led2
          pause abity
       low led3
          pause abity
       low led4
       pause abity
       low led5 
         
      pause abity
        high led6
      pause abity
      high led7
      pause abity
      high led8
      pause abity
       high led9
      pause abity
      low led9
      pause abity
      low led8
      pause abity
       low led7
      pause abity
      low led6
      pause abity
      next counter
      
       b3 = b3+1
       pause abitx
      return
      
      
    
   cylon1:


 for counter = 1 to 4
 
  
high led1
  pause abitx
low led1
  pause abitx
high led2
  pulsout led1,300
   pulsout led3,100
   pause abitx
low led2
  pause abitx
high led3
  pulsout led2,300
  pulsout led1,200
   pulsout led4,100
   pause abitx
low led3
   pause abitx
high led4
 pulsout led3,300
  pulsout led2,200
  pulsout led1,100
   pulsout led5,100
   pause abitx
low led4
   pause abitx
high led5
  pulsout led4,300
   pulsout led3,200
    pulsout led2,100
     pulsout led6,100
 pause abitx
 low led5
 pause abitx
 high led6
 pulsout led5,300
  pulsout led4,200
   pulsout led3,100
    pulsout led7,100
 pause 50
 low led6
 pause 50
 high led7
 pulsout led6,300
  pulsout led5,200
   pulsout led4,100
    pulsout led8,100
 pause 50
 low led7
  pause abitx
 high led8
 pulsout led7,300
  pulsout led6,200
   pulsout led5,100
    pulsout led9,100
 pause abitx
 low led8
 pause abitx
 high led9
 pulsout led8,300
  pulsout led7,200
   pulsout led6,100
 pause abitx
 low led9
 pause abitx
 
 
 
   
high led8
pulsout led9,300
  pause abitx
low led8
  pause abitx
high led7
  pulsout led8,300
   pulsout led9,200
    pulsout led6,100
   pause abitx
low led7
  pause abitx
high led6
  pulsout led7,300
   pulsout led8,200
     pulsout led9,100
      pulsout led5,100
   pause abitx
low led6
   pause abitx
high led5
 pulsout led6,300
  pulsout led7,200
    pulsout led8,100
     pulsout led4,100
   pause abitx
low led5
   pause abitx
high led4
  pulsout led5,300
   pulsout led6,200
     pulsout led7,100
      pulsout led3,100
 pause abitx
 low led4
 pause abitx
 high led3
 pulsout led4,300
  pulsout led5,200
   pulsout led6,100
    pulsout led2,100
 pause 50
 low led3
 pause abitx
 high led2
 pulsout led3,300
  pulsout led4,200
    pulsout led5,100
     pulsout led1,100
 pause abitx
 low led2
 pause abitx
 high led1
 pulsout led2,300
   pulsout led3,200
 pause abitx
 low led1
 pause abitx
 
 
 next counter
  b3 = b3+1
  pause 10 
 return
now i dont mind this way because am not gonna watch the the code running just the leds :eek: it does make for long program
i found a few threads using hardware abstraction layer that tinyb,hippy and few others talking about and am beginning to understand its use and i got this example working
Code:
#Picaxe 20x2


dirc.1 = 1
dirc.0 = 1
dirb.0 = 1
dirb.1 = 1
dirc.5 = 1
dirb.2 = 1
dirb.3 = 1
dirb.4 = 1
dirb.6 = 1


symbol delay1 = 40

symbol counter = b6
init:
     pause 100
       HI2cSetup i2cslave, %11100000
main:
      pause 100
      gosub cylon
      pause 100
      goto main


OutputLeds:
  pinc.1 = bit0
  pinc.0 = bit1
  pinb.0 = bit2
  pinb.1 = bit3
  pinc.5 = bit4
  pinb.2 = bit5
  pinb.3 = bit6
  pinb.4 = bit7
  pinb.6 = bit8
  Return
  
  
  
  
  
  cylon:
    
  for counter = 1 to 6
  w0 = %0000000001
  Do
    Gosub OutputLeds
    w0 = w0 * 2
    pause delay1
  Loop Until w0 = 0
  w0 = %1000000000
  Do
    w0 = w0 / 2 
    pause delay1
    Gosub OutputLeds
  Loop Until w0 = 0
  next counter
  return
  
  split:
am stuggling to get my head around the use of table to create other effects so could anyone explain the use of table and give an example to create a split affect.
jinx
here's a pic SnapShot3.jpg
 
Last edited:

nick12ab

Senior Member
am stuggling to get my head around the use of table to create other effects so could anyone explain the use of table and give an example to create a split affect.
jinx
What use of table? As far as I can tell, it just uses maths to generate the pattern, not table memory.
 

jinx

Senior Member
hi nick,
then am in a mess i thought the table was used to indicate which bit of w0 sent the led high or low.
 

jinx

Senior Member
the split effect start with led 5 goes high then low then
led4 and led6 high and so on. it's this i thought i contol the bits in table lookup,
 

nick12ab

Senior Member
the split effect start with led 5 goes high then low then
led4 and led6 high and so on. it's this i thought i contol the bits in table lookup,
Try this:
Code:
#Picaxe 20x2


dirc.1 = 1
dirc.0 = 1
dirb.0 = 1
dirb.1 = 1
dirc.5 = 1
dirb.2 = 1
dirb.3 = 1
dirb.4 = 1
dirb.6 = 1


symbol delay1 = 40

symbol counter = b6
init:
     pause 100
       HI2cSetup i2cslave, %11100000
main:
      pause 100
      gosub cylon
      pause 100
      goto main


OutputLeds:
  bit16 = bit0 or bit7
  bit17 = bit1 or bit6
  bit18 = bit2 or bit5
  bit19 = bit3 or bit4
  bit20 = bit4 or bit3
  bit21 = bit5 or bit2
  bit22 = bit6 or bit1
  bit23 = bit7 or bit0
  pinc.1 = bit16
  pinc.0 = bit17
  pinb.0 = bit18
  pinb.1 = bit19
  pinc.5 = bit20
  pinb.2 = bit21
  pinb.3 = bit22
  pinb.4 = bit23
  pinb.6 = bit24
  Return
  
  
  
  
  
  cylon:
    
  for counter = 1 to 6
  w0 = %0000000001
  Do
    Gosub OutputLeds
    w0 = w0 * 2
    pause delay1
  Loop Until w0 = 0
  w0 = %1000000000
  Do
    w0 = w0 / 2 
    pause delay1
    Gosub OutputLeds
  Loop Until w0 = 0
  next counter
  return
  
  split:
 

jinx

Senior Member
thats the effect am after except it's not lighting the 9th led nor do i understand how your done nick:rolleyes: please explain
 

nick12ab

Senior Member
thats the effect am after except it's not lighting the 9th led nor do i understand how your done nick:rolleyes: please explain
I've just modified the second piece of code you posted in post #1 so that the LEDs on each half of the display are ORed with the other half so that it's as if there's a mirror down the middle. The reason the 9th LED doesn't light is because it doesn't in your original code either.
 

westaust55

Moderator
I believe that jinx is not saying the posted code includes a table but that he wishes to use a table for data lookup to achieve the desired effects.
Maybe jinx can clarify the requirements.
 

jinx

Senior Member
westaust you right I'd like to fill the 20x2 with as many effects as I can what I like to do is put an effect into a subroutine and call that routine via the I2C bus
 
Last edited:

jinx

Senior Member
nick i added bit24 = bit8 or bit0
Code:
OutputLeds:
  bit16 = bit0 or bit8
  bit17 = bit1 or bit7
  bit18 = bit2 or bit6
  bit19 = bit3 or bit5
  bit20 = bit4 or bit4
  bit21 = bit5 or bit3
  bit22 = bit6 or bit2
  bit23 = bit7 or bit1
  bit24 = bit8 or bit0
  pinc.1 = bit16
  pinc.0 = bit17
  pinb.0 = bit18
  pinb.1 = bit19
  pinc.5 = bit20
  pinb.2 = bit21
  pinb.3 = bit22
  pinb.4 = bit23
  pinb.6 = bit24
  Return
 

nick12ab

Senior Member
??????? >10 chars
Ah, so it was meant to be use! You corrected it within the 10 (?) minute time limit to edit a post before the Edited by... message is shown at the bottom of the post.

I wouldn't have said anything if I had known it was meant to be use (in fear of eclectic sending me a PM).
 

jinx

Senior Member
westaust55 am i being vague on what it is i like to do with this led chaser:rolleyes:
nick your split effect appears as if it pulse gonna name that one the "nick effect".
 

westaust55

Moderator
Ah, so it was meant to be use! You corrected it within the 10 (?) minute time limit to edit a post before the Edited by... message is shown at the bottom of the post.

I wouldn't have said anything if I had known it was meant to be use (in fear of eclectic sending me a PM).
It was corrected within about 5 seconds. I clicked post, saw error, clicked edit, fixed and saved - avoid trying to be too "smart" might be more helpful. . . . . .

EDIT: the word "fixed" was corrected here in similar time
 

westaust55

Moderator
Hi jinx,

if you have a series of data being sent to the outputs with commands like pinsB = xxxx

Then you can collect up those xxx values and put them into TABLE memory (with the appropriate PICAXE chip).

Use the TABLE command/directive to construct the table in TABLE memory - which is a section of program memory.

Then in a loop (FOR ... NEXT) you can use the READTABLE command to fetch each value from the TABLE memory and pass the value to the ouputs with the PINSx command.

This will take up a block of program memory space for the TABLE data but if the sequences are longer, then overall there will be program space savings.
 

jinx

Senior Member
avoid trying to be too "smart" might be more helpful. . . . . .
who me ?
nick it's a good solution for the split effect but i hestate to use it as i dont understand it working.
 

westaust55

Moderator
Note that TABLE memory is limited to 256 bytes so there will be limitation on the number and/or length of the sequences.
EEPROM memory is another area where you can save additional data which will require different commands for setting up an table and retrieving the data but will enable you to expand the number or length of sequences.
 

jinx

Senior Member
westaust55 am getting lost. eeprom memory does seem the way but i could do with an working example have you got an links that i can read
 

westaust55

Moderator
For data within PICAXE EEPROM:
Code:
Symbol pattern = b3
Symbol index = b4
Symbol start= b5
Symbol finish = b6

; define data to be stored in EEPROM
EEPROM 0, (1, 2, 4, 8, 16, 32, 64, 128) ; insert your own values here

FOR index = start TO finish
    READ index, pattern
    PINSB = pattern
NEXT index
DO : LOOP
For TABLE memory replace EEPROM with TABLE and READ with READTABLE

Trust that example helps (and hopefully no typos for Nickpicking :) )
 

jinx

Senior Member
thx westaust but im in spin because i dont understand your method, and i cant just use pinsb as the nine led spread over ports B and C the reason for the spread is am using the I2C to change the effects
Code:
symbol led1 = c.1
symbol led2 = c.0
symbol led3 = b.0
symbol led4 = b.1
symbol led5 = c.5      'pwm
symbol led6 = b.2
symbol led7 = b.3
symbol led8 = b.4
symbol led9 = b.6
this is why i started thinking of the HAL method then i could use w0 %000010000 then thought placing w0 into a lookup table/eeprom and its this point it's all going pear shaped for me.
 

westaust55

Moderator
Okay, so if you change the.symbol statement for pattern to be allocated to word variable w0 and then read from TABLE or EEPROM two byte variables into b0 and b1 then instead of a direct allocation to the PINSB port you can call a subroutine which for each sequence loop will do the same thing.
Your new subroutine would be in the format:

Code:
Led1 = bit0
Led2 = bit1
:
:
Led9 = bit8
RETURN
 
Last edited:

jinx

Senior Member
westaust thankyou for the help,this is a real struggle for me to visiaulize how this program looks or even implement,please allow this thread to fall into the forum abyss hopefully when am not so thick i,ll get my head round it. thanks again nick and westaust.
jinx
 

boriz

Senior Member
EEPROM and program memory are shared, so it's essentially equivalent to use a Lookup command for this sort of app. I think it makes things simpler.

(Pseudocode)
Code:
for b1=0 to 7
    lookup b1,(%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000),b0
    gosub display_b0
    pause for effect
next b0
end

display_b0:
pin.x=bit.x
pin.x=bit.x
...etc
return
This would look like a single LED 'scanner' effect. Just use different data in the Lookup for different animations.
 

jinx

Senior Member
hi,
,please allow this thread to fall into the forum abyss
the abyss was shallow this time around am getting my head around nick's posted code
Code:
#Picaxe 20x2
#no_data
#no_table




symbol tdelay = w8
symbol delay  = 30
symbol delay1 = 40
symbol delay2 = 500


symbol counter = b6
symbol cmd     = b14
symbol speed   = b20

dirc.1 = 1
dirc.0 = 1
dirb.0 = 1
dirb.1 = 1
dirc.5 = 1
dirb.2 = 1
dirb.3 = 1
dirb.4 = 1
dirb.6 = 1

init:
     pause 100
         HI2cSetup i2cslave, %11100000
main: 
     ' pause 10
   ' gosub getdata
   
' select case cmd
    
   ' case  10
       gosub split
   ' case 20
      gosub cylon
   
   
    
  ' end select
      goto main



  
  '########## shift lft and rgt ###############
  
   cylon:
    sertxd ("selection cyclon",cr,lf)
  for counter = 1 to 2
  w0 = %00000000111
  Do
    Gosub OutputLeds1
    w0 = w0 * 2
    pause delay
  Loop Until w0 = 0
  w0 = %11100000000
  Do
    w0 = w0 / 2 
    pause delay
    Gosub OutputLeds1
  Loop Until w0 = 0
  next counter
'  let cmd = cmd+1
 ' sertxd (#cmd,cr,lf)
  return
  
  
  
  
    split:
    
  for counter = 1 to 2
  w0 = %0000000001
  Do
    Gosub OutputLeds
    w0 = w0 * 2
    pause delay1
  Loop Until w0 = 0
  w0 = %1000000000
  Do
    w0 = w0 / 2 
    pause delay1
    Gosub OutputLeds
  Loop Until w0 = 0
  next counter
  let cmd = cmd+1
  return
  
  
  
  
  '############## retieve I2c data ################## 
  getdata:
     get 0,b10                  'aninamtion select
    get 3,w8
 '    let b10 = cmd
   '  let w8 = speed
   '  let cmd = 20
    ' let speed = 1000
   '   let speed = delay
     sertxd("recieved",cr,lf)
     sertxd ("selection",cr,lf)
     sertxd(" speed =",#w8,cr,lf)
     pause 10
     return
  
OutputLeds:
  bit16 = bit0 or bit8
  bit17 = bit1 or bit7
  bit18 = bit2 or bit6
  bit19 = bit3 or bit5
  bit20 = bit4 or bit4
  bit21 = bit5 or bit3
  bit22 = bit6 or bit2
  bit23 = bit7 or bit1
  bit24 = bit8 or bit0
  pinc.1 = bit16
  pinc.0 = bit17
  pinb.0 = bit18
  pinb.1 = bit19
  pinc.5 = bit20
  pinb.2 = bit21
  pinb.3 = bit22
  pinb.4 = bit23
  pinb.6 = bit24
  Return
  
  
  OutputLeds1:
  pinc.1 = bit0
  pinc.0 = bit1
  pinb.0 = bit2
  pinb.1 = bit3
  pinc.5 = bit4
  pinb.2 = bit5
  pinb.3 = bit6
  pinb.4 = bit7
  pinb.6 = bit8 
   Return
this short piece of code takes up 333 bytes compared to my first code which took up over 600 i,ve not got the overall effect of the cylon yet with this method nor sure its possible.but it so small imay place it in slot three and run the orignal cylon in slot two or something like it.
 

westaust55

Moderator
EEPROM and program memory are shared, ....
Post 12 indicates 20X2 is being used.
For most PICAXE including the latest 18M2+ EEPROM and program memory are separate memory areas/types.
Older M parts and 08M2 have shared EEPROM and program memory block.
 

jinx

Senior Member
am still learning and playing with nicks method lot of fun. am placing the code for am forever making changes without saving and i know this works
slave i2c:

Code:
; *******************************
; ***** Sample Header File  *****
; *******************************
;    Filename: 	ledchaser webdemo	
;    Date: 	        24/8/2012		
;    File Version:   0.00000001	
;    Written by: 	jinx,nick12ab,forum	
;    Function    :    led animation		
;    Last Revision:
;    Target PICAXE:20x2	
; ******************************* 




#Picaxe 20x2
#no_data
#no_table





symbol delay  = 40
symbol delay1 = 50
symbol delay3 = 50


symbol counter = b6
symbol cmd     = b3

symbol spk    = c.3

dirc.1 = 1
dirc.0 = 1
dirb.0 = 1
dirb.1 = 1
dirc.5 = 1
dirb.2 = 1
dirb.3 = 1
dirb.4 = 1
dirb.6 = 1

init:
         pause 100
         HI2cSetup i2cslave, %11100000
         pause 10
main: 
 do  
    gosub getcmd
      sertxd(" received cmd ",#b3,13,10)
      
    select case cmd
        case 10 
           sound spk, (100,20)
           gosub cylon
        case 20
             sound spk, (80,20)
           gosub split
        case 30 
            sound spk, (60,20)
           gosub rsplit
        case 40 
              sound spk, (100,20)
           gosub lsplit     
       ' pause 10
      end select
      let cmd = 0
   
   loop





getcmd:
    'sound spk, (100,50)
    pause 50
    Get 0, cmd
    pause 100
    return



   cylon:
    sertxd ("selection cyclon",cr,lf)
  for counter = 1 to 2
  w0 = %00000000011
  Do
    Gosub OutputLeds1
    w0 = w0 * 2
    pause delay
  Loop Until w0 = 0
  sound spk, (40,10)
  w0 = %110000000000
  Do
    w0 = w0 / 2 
    pause delay
    Gosub OutputLeds1
  Loop Until w0 = 0
  sound spk, (80,10)
  
    next counter
 let cmd = cmd+1
  
   return
  
  
    
   split:
     sertxd ("selection    split   ",cr,lf)
 ' for counter = 1 to 2
  w0 = %00000000001
   Do
    Gosub OutputLeds
    w0 = w0 * 2
    pause delay1
   Loop Until w0 = 0
  w0 = %10000000000
  Do
    w0 = w0 / 2 
    pause delay1
    Gosub OutputLeds
  Loop Until w0 = 0
 ' next counter
 
  let cmd = 0
 goto main
  
     
Lsplit:
    
   sertxd ("selection   lspit    ",cr,lf) 
 '  for counter = 1 to 2
  w0 = %00001000000
   Do
    Gosub OutputLeds1
  w0 = w0 * 2
    pause delay1
  Loop Until w0 = 0
 ' next counter
   let cmd = 0
 
goto main

 
  Rsplit:
  
 
     sertxd ("selection    rsplit   ",cr,lf)
   
  ' for counter = 1 to 2
  w0 = %00001000000
    Do
    Gosub OutputLeds1
    w0 = w0 /2
    pause delay3
   Loop Until w0 = 0
'  next counter
   let cmd = 0

goto main
  
  
  OutputLeds:
  bit16 = bit0 or bit8
  bit17 = bit1 or bit7
  bit18 = bit2 or bit6
  bit19 = bit3 or bit5
  bit20 = bit4 or bit4
  bit21 = bit5 or bit3
  bit22 = bit6 or bit2
  bit23 = bit7 or bit1
  bit24 = bit8 or bit0
  pinc.1 = bit16
  pinc.0 = bit17
  pinb.0 = bit18
  pinb.1 = bit19
  pinc.5 = bit20
  pinb.2 = bit21
  pinb.3 = bit22
  pinb.4 = bit23
  pinb.6 = bit24
  Return
   
  
  OutputLeds1:
  pinc.1 = bit2
  pinc.0 = bit3
  pinb.0 = bit4
  pinb.1 = bit5
  pinc.5 = bit6
  pinb.2 = bit7
  pinb.3 = bit8
  pinb.4 = bit9
  pinb.6 = bit10 
   Return

master:
Code:
; *******************************
; ***** Sample Header File  *****
; *******************************
;    Filename: i2c master setup 	
;    Date: 			
;    File Version: 0.0000001	
;    Written by  : jinx,forum	
;    Function    : i2c template /led animation 		
;    Last Revision:
;    Target PICAXE:20m2	
; ******************************* 



#picaxe 20m2
'#no_table
'#no_data

symbol delay = 100
symbol cmd   = b1
 
  symbol touchthresh = 100
  symbol touchval    = w8
  symbol touchdiff   = w5

 symbol bone  = c.7
 symbol btwo  = c.1
 symbol bthree= c.2
 symbol bfour = c.3
 
 symbol touch1p = w1
 symbol touch4p = w4
 
 symbol counter = b0


init: touch16 bone,touch1p
      touch16 bfour,touch4p
    pause 50
    HI2cSetup i2cmaster, %11100000, i2cslow, i2cbyte
    pause 50
    
    
main:
do

 
touch16 bone,touchval 
   if touchval >touch1p then
     touchdiff = touchval - touch1p
    if touchdiff > touchthresh then
     let cmd = 10 
   sertxd ("bone",#touch1p,cr,lf)  
   gosub senddata
 endif
' else
  
 endif

 touch16 btwo,w2 
                                       ; 
   if w2 > 5550 then
   let cmd = 20
   sertxd ("btwo",#w2,cr,lf)  
   gosub Senddata
  endif

 touch16 bthree,w3 
                                   ; read value into w0
   if w3 > 5200 then
   let cmd = 30
   sertxd ("bthree",#w3,cr,lf)  
   gosub Senddata
  endif

  
 touch16 bfour,touchval 
   if touchval >touch4p then
     touchdiff = touchval - touch4p
    if touchdiff > touchthresh then
     let cmd = 40 
   sertxd ("bfour",#touch1p,cr,lf)  
   gosub senddata
  endif
' else
  
 endif


 HI2cOut 0,( 0 )                           
  pause 50
  
  loop


Senddata:
 

    Pause 10
    HI2cOut 0,( cmd )
    SerTxd( "Sent ",#cmd, CR, LF )
    pause 50
      goto main
 
Top