MrDEB
Well-Known Member
have adrino code but trying to implement into Swordfish using a Tap-28 board.
The leds are enabled on a port low
the code just stops but it should keep going to monitor the tilt sensor RPI1031.
Just a nudge in right direction as it enables an led but repositioning the sensor it won't do anything. I have to cut power to the pic then repower it up and maybe it will assume new position.
As I understand it the two outputs from the breakout board go LOW/LOW , LOW/HIGH , HIGH/ HIGH HIGH , HIGH / LOW , LOW / HIGH My plan is to add up the s1 and s2 to indicate which led is enabled. I really only need two led outputs instead of 4
The leds are enabled on a port low
the code just stops but it should keep going to monitor the tilt sensor RPI1031.
Just a nudge in right direction as it enables an led but repositioning the sensor it won't do anything. I have to cut power to the pic then repower it up and maybe it will assume new position.
As I understand it the two outputs from the breakout board go LOW/LOW , LOW/HIGH , HIGH/ HIGH HIGH , HIGH / LOW , LOW / HIGH My plan is to add up the s1 and s2 to indicate which led is enabled. I really only need two led outputs instead of 4
Code:
{
*****************************************************************************
* Name : UNTITLED.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 3/30/2013 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
Device = 18f2420
Clock = 8
//Config OSC=HS
Include "InternalOscillator.bas"
Include "utils.bas"
//Include "convert.bas"
Dim s1 As PORTC.4
Dim s2 As PORTC.5
Dim led2 As PORTB.3
Dim led1 As PORTA.3
Dim x As Byte
Dim tilt_s1 As Byte
Dim tilt_s2 As Byte
Dim position As Word
dim tilt_pos as integer
dim index as integer
Input (s1)
Input (s2)
High (led1)
High(led2)
//tilt_s1 = 2
//tilt_s2 = 3
Output (led1)
Output (led2)
SetAllDigital
While true
If s1 =0 Then tilt_s1 = 1
EndIf
If s1 =1 Then tilt_s1 = 2
EndIf
If s2 =0 Then tilt_s2 = 1
EndIf
If s2 =1 Then tilt_s1 = 2
EndIf
tilt_POS = tilt_s1 + tilt_s2
if tilt_pos = 2 then led1 = 0
delayms (300)
toggle (led1)
endif
if tilt_pos = 4 then led2 = 0
delayms(300)
toggle (led2)
endif
tilt_pos = 0
Wend