I think the results should be read through the analog pins.
The output to the LED should be utilizing the digital pin because after some extensive (as well as late-at night) testing I realized Analog pins can NOT handle the 'analogWrite' function. You would need to manually do it so you should stick to utilizing the digital pins.
For example: [code] int pin = 0 ;//analogue pin 0 int value;
void setup(){} // nothing to do in setup
void loop() analogWrite(pin,value) } [/code] value needs to be between 0 and 255 if value is 0 the output is 0 volts, if value is 255 the output is 5volts. BUT if value is between 1 and 254 then the output is a PWM stream. That is the value varies rapidly between 0 and 5 volts with the output being high and low each of which depends on what 'value' is set to. If value is 64 then the output will be 5 volts for a quarter of the time and 0 volts for three quarters of the time.
But if I want to use it for a sensor application and as a output too for eg i want to make a rgb color sensor and I want the same color sensor to output what it has detected is it possible
Bio:I am a 14 year old school student intrested in electronics rather than studies.I developed this hobby when I was 10 and when I found out this site I was like WOW!!! now I can share what I make.I feel ...read more »
PDF Downloads As a Pro member, you will gain access to download any Instructable in the PDF format.
You also have the ability to customize your PDF download.
The output to the LED should be utilizing the digital pin because after some extensive (as well as late-at night) testing I realized Analog pins can NOT handle the 'analogWrite' function. You would need to manually do it so you should stick to utilizing the digital pins.
For example:
[code]
int pin = 0 ;//analogue pin 0
int value;
void setup(){} // nothing to do in setup
void loop()
analogWrite(pin,value)
}
[/code]
value needs to be between 0 and 255
if value is 0 the output is 0 volts, if value is 255 the output is 5volts.
BUT
if value is between 1 and 254 then the output is a PWM stream.
That is the value varies rapidly between 0 and 5 volts with the output being high and low each of which depends on what 'value' is set to.
If value is 64 then the output will be 5 volts for a quarter of the time and 0 volts for three quarters of the time.
http://arduino.cc/en/Reference/digitalWrite According to that doc "The analog input pins can be used as digital pins, referred to as A0, A1, etc."