Quantcast
Channel: SparkFun Electronics Comments
Viewing all articles
Browse latest Browse all 44542

Customer #421090 on SEN-10621 - RPI-1031 Tilt-a-Whirl Breakout

$
0
0

trying to get this chip to work using SWORDFISH but I keep having to reset the pic to check tilt. 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

any suggestions


Viewing all articles
Browse latest Browse all 44542

Trending Articles