; Experiment-11-ADXL335-Accelerator.bas #picaxe 28X2 ; Define the MCU ; Declare Constants, Variables and Devices * * * * * * * * * * * * * * * symbol RLED = B.7 ; B.0 = 0-bit of LED Display symbol GLED = B.6 ; B.1 = 2-bit of LED Display symbol BLED = B.5 ; B.2 = 4-bit of LED Display symbol Xaxis = A.0 symbol Yaxis = A.1 symbol Zaxis = A.2 symbol moveX = b0 ; X Axis symbol moveY = b1 ; Y Axis symbol moveZ = b2 ; Z Axis symbol i = b3 ; BEGIN Main Body * * * * * * * * * * * * * * * do gosub LEDsOFF readadc Xaxis,moveX ; read value into moveX if moveX > 10 then gosub red ; flash red debug moveX pause 250 gosub LEDsOFF readadc Yaxis,moveY ; read value into moveY if moveY > 10 then gosub green ; flash red debug moveY pause 250 gosub LEDsOFF readadc Zaxis,moveZ ; read value into moveZ if moveZ > 10 then gosub blue ; flash red debug moveZ pause 250 gosub LEDsOFF loop ; END Main Body * * * * * * * * * * * * * * * * end ; BEGIN Subroutines * * * * * * * * * * * * * * * red: low RLED ; switch RED ON high GLED ; switch Green OFF high BLED ; switch Blue OFF return green: high RLED ; switch RED OFF low GLED ; switch Green ON high BLED ; switch Blue OFF return blue: high RLED ; switch RED OFF high GLED ; switch Green OFF low BLED ; switch Blue On return Police: For i = 0 to 4 gosub red pause 50 gosub LEDsOFF pause 50 gosub red pause 50 gosub LEDsOFF pause 100 gosub blue pause 50 gosub LEDsOFF pause 50 gosub blue pause 50 gosub LEDsOFF pause 100 next i return LEDsOFF: high RLED ; switch RED OFF high GLED ; switch Green OFF HIGH BLED ; switch Blue OFF return ; END Subroutines * * * * * * * * * * * * * * * * end