Hi everybody,
Just get an Arduino and enjoyed it so much. My pleasure for tonight, my first post on the Arduino family forum.
I'm trying to dim an Led according to the circuit explain below:
LED connected to pin 9 and have a 560 ohms resistor before ground
Sensor is connected to 5V pin, and have a 10Kohms resistor before ground, and a connection to analog pin 0
Below the specs of my level sensor:
Power requirements: Up to +5 VDC
Communication: Resistive Output
Sensor Output: 550 ohms empty, 60 ohms full, ± 20%
Resistance Gradient: 40 /inch (16 /cm), ± 20%
I've tried to changed the value of the resistor connected to my sensor, but nothing is happeing, brightness is still fix.
Below is the code I've used:
//Level Sensor Pin
int levelPin = 0; //the analog pin the level sensor is
//connected to
//the level sensor is not calibrated to any units so
//this is simply a raw sensor value (relative level)
//LED Pin
int ledPin = 9; //the pin the LED is connected to
//we are controlling brightness so
//we use one of the PWM (pulse width
// modulation pins)
void setup()
{
pinMode(ledPin, OUTPUT); //sets the led pin to output
}
/
loop() – this function will start after setup
* finishes and then repeat
*/
void loop()
{
int waterLevel = analogRead(levelPin); //Read the
// waterlevel
waterLevel = map(waterLevel, 0, 900, 0, 255);
//adjust the value 0 to 900 to
//span 0 to 255
waterLevel = constrain(waterLevel, 0, 255);//make sure the
//value is betwween
//0 and 255
analogWrite(ledPin, waterLevel); //write the value
delay(10);
}
I'm a novice in programming and electronic, so I'm sure I did it wrong.
I'm still trying different programs, and circuits, but start to be a little bit afraid of what could happen (an explosion maybe ?? )
I'm more than open to any suggestion, even if you have to tell me that I'm a dum, as I will agree.
Thanks a lot in advance,
I'm going back to my water circuit
Plankton.