LED help

can anyone give me a sample program for an LED. i want to use a potentiameter and have the LED light up at a certain value. i cant really make sense of the samples RobotC gives so. will sombody please help me

to my knowledge the led’s are strictly on and off. No brightness adjustment. But I may be wrong on that.

They are either on or off. But if you toggle it on and off really fast, then MAYBE it will look half bright. :smiley: (That is basically how a motor runs half speed; it is called pwm. Someone with better circuitry knowledge?)

The motor ports have pwm with a motor controller. So if you plugged it into a motor port, you could just give it 64 power. Not suggested! (Unless you know what you’re doing, or you’re ok with frying electronics. :p)

to clarrify “light up” useally means turn on

Is this what you want?

#pragma config(Sensor, in1,    pot_1,          sensorPotentiometer)
#pragma config(Sensor, dgtl1,  led_1,          sensorLEDtoVCC)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
        // Turn led off if pot is below 1000 or
        // on if it is above or equal to 1000
        if( SensorValue pot_1 ] < 1000 )
            SensorValue led_1 ] = 0;
            SensorValue led_1 ] = 1;

yes thanks

:stuck_out_tongue: Misunderstood this, sorry.