RPI 1031 Breakout board
Posted: Sun Mar 31, 2013 1:53 pm
trying to configure this chip to detect tilt but keep having to reset the pic to determine tilt but then not sure if its right.
Using a Tap-28 board where the LEDs are enabled when port is low.
I need direction. The code at Sparkfun is for adrino but I am using SWORDFISH.
The two outputs on the board (s1, s2) output LOW/ LOW , LOW/ HIGH , HIGH/ HIGH , HIGH/ LOW
using the code from sparkfun as example, I kinda figured just add the outputs to determine tilt.
Using a Tap-28 board where the LEDs are enabled when port is low.
Code: Select all
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 As word
Dim position As Word
dim tilt_pos as integer
dim index as integer
Input (s1)
Input (s2)
led1=1
led2=1
//tilt_s1 = 2
//tilt_s2 = 3
Output (led1)
Output (led2)
SetAllDigital
While true
If s1 =0 and s2 = 0 Then tilt = 1 //
EndIf
If s1 =1 and s2 =0 Then tilt = 2
EndIf
If s1 =1 and s2 = 1 Then tilt = 3
EndIf
If s1 =0 and s2 = 1 Then tilt = 4
EndIf
if tilt = 1 then led1 = 1
led2 = 0
delayms (1000)
led2 = 1 // leds off
led1 = 1
endif
tilt = 0
if tilt = 2 then led2 = 0
led2 = 0
delayms (1000)
led2 = 1 // leds off
led1 = 1
endif
tilt = 0
if tilt = 3 then led1 = 0 // both on
led2 = 0
delayms (1000)
led2 = 1 // leds off
led1 = 1
endif
tilt = 0
if tilt = 4 then led1 = 1 //and led2 = 1
delayms(1000) // blink once
toggle (led1)
toggle (led2)
delayms(1000)
endif
tilt = 0
Wend
The two outputs on the board (s1, s2) output LOW/ LOW , LOW/ HIGH , HIGH/ HIGH , HIGH/ LOW
using the code from sparkfun as example, I kinda figured just add the outputs to determine tilt.