In SX Microcontrollers, SX/B Compiler and SX-Key Tool, jgjonola wrote: Hi everyone, I am just getting back in to playing with SX/B (its been a few years.) I was playing around with making an LED light detector. So i have an led hooked between RB.1 and RB.2 with a resistor in series. Here is the code: [code] 'PWM.SXB DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 led2 PIN RB.2 led1 PIN RB.1 led7 PIN RB.7 light VAR Word time CON 2000 'Code PROGRAM Start Start: led1 = 1 led2 = 0 DO OUTPUT led2 OUTPUT led1 RCTIME led1, 1, light IF light = 0 THEN led7 = 1 ELSE led7 = 0 ENDIF PAUSE time LOOP [/code] I have another LED connected to RB.7 that is supposed to turn on if the value of light is 0. Not seeming to work. I copied this from similar code i found from the basic stamp and it worked fine with my stamp. I just made a few changes for the SX and no go... Here is the code i used as a base for the Stamp: [code] '{$PBASIC 2.5} 'file:LED_Emitter_Detecter.bs2 'Clark Radcliffe 'Michigan State University 'July 30, 2007 'Requires an LED in series with a 220 Ohm resister 'between pin 1 and the LED connected to pin 2 'Declarations Pin2 PIN 2 Pin1 PIN 1 light VAR Word time CON 2000 'Code DEBUG "Start test...", CR DO DEBUG "LED is a detecter (LED off and charging)", CR Pin1 = 1 Pin2 = 0 PAUSE 10 RCTIME pin1, 1, light DEBUG "Light measured = ", DEC light, CR PAUSE time LOOP [/code] Thanks! John G ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=364552 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)