First of all please bear with me I am new to arduino and I am undertaking this project as a university assignment, however my knowledge of C is reasonable as is my knowledge of electronics.
I am trying to use an LED bar graph which will interface with a Microphone to control the amount of LED's that light depending on the amount of ambient sound. Similar to a VU meter. Is it possible to change the brightness of the LED's with an LDR as well as the amount that are lit?
So if one LED was lit and it was dark it would be very bright but if all the LED's or some of the LEDs were lit and it was light they would be dimmer.
I hope that makes sense and someone can point me in the right direction.
Haha thanks! Ok I am using an Arduino Duemilanove how many PWM pins does it have? I should probably explain the entire project to check if it is actually possible.
I am designing the electronic concept for a t-shirt that would have LED's on it. These LED's should be able to be dim in the light and bright in the dark. The amount of LED's that are lit should be proportionate to the amount of ambient Noise similar to this:
I am then intending on using a tilt switch to count the number of steps like a pedometer and this number will then be displayed on an arduino LCD display. I had also thought about adding a thermistor to display the temperature in the room as well. But that is extra and although I would like to do it I think I may be short of time.
That may sound ambitious but I am only showing a concept on a breadboard nothing more, I am intending on using 5 LED's to show the light level and amount of noise.
I hope that makes sense, I can alter what I am going to make but I am trying to create something that uses multiple inputs and outputs (2+ of each) to satisfy the assignment criteria. I think what I have planned should do this?!
Are you sure about that? It seems to be backwards. I would think that the LEDs should be brighter in high ambient light so that it could be seen. And then it doesn't have to be as bright in the dark because it is easier to see.
It is not to make the LED's more visible in high intensity lighting conditions but rather to make them brighter when dark to aid visibility, they are not needed in daylight so should be switched off.
I have spent most of the day getting the prototype breadboarded and working and have now finished the hardware side of things. To make life easier I am now using one PWM output to control a bar of LED's that light up simultaneously. I have got the LDR working correctly with the LED's so that they dim and I have dropped the idea of using a microphone like a VU meter as time is an issue as I only have a week to get it finished.
I have been searching to try to find a definitive answer to this but how would I go about linking a thermistor to an LCD so that it displays the variable temperature in Centigrade as well as a bi-colour LED so that when it is cold one colour shows and as it gets hotter it fades into the next colour? That might sound simple but all the examples I can find are either without any code or in another language! haha
As far as reversing the LDR goes I think I have got it to fade correctly by using the PWM output however is there a way to prevent the output going negative so that the LED's are either all the way off with full light or all the way on with no light?
Not sure what you mean the output is never negative.
Use:-
analogWrite(pin, 255-value);
to reverse the fading sense or wire the LED so the arduino sinks current instead of sourcing it.
This is the code I have at the moment, it reads the input then converts it back to output, how would I use the command you have given in this context?
Thanks!
int sensorValue = 0; // value read from the LDR
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(LDRIn);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 875, 255, 10);
// change the analog out value:
analogWrite(LEDBarOut, outputValue);