' USB Power current monitor by PICAXE ' v1.00 2013/05/27 ' by Radiopench,http://radiopench.blog96.fc2.com/ ' symbol SF = 252 ; Caliblatin ScaleFactor setfreq m4 ; clock Frq. = 4MHz fvrsetup FVR2048 ; set FVR as 2.048V adcconfig %011 ; set FVR as ADC Vref+, 0V Vref- let w2 = 0 ; w2@=@Accum ADC let b7 =0 ; 10X counter high c.1 ; c.1 = 10X LED high c.2 ; c.s = 1X LED main: high c.0 ; Test pin ON readadc10 c.4,w1 ; read ADC value into w1 let w2 = w2 + w1 ; Accumulate value if w2 >= SF then ; if more than ScalFactor toggle c.1 ; 10x LED ON or OFF let w2 = W2 // SF ; save MOD value for nexe inc b7 ; inc 10x counter if b7 = 10 then ; toggle c.2 ; 1x LED ON or OFF let b7 = 0 else pauseus 55 ; adjust exec.time endif else pauseus 380 ; adjust exec.time endif low c.0 ; Test pin OFF 'debug pauseus 117 ; adjust total time to 10ms goto main ; loop back to start