Go Down

Topic: Help with LED Cluster needed (Urgent) (Read 3320 times) previous topic - next topic


the problem is: the light should be off and only turn on when a sound is made

Just turn it round in the software.
If you are using analogWrite, use 255 - val in place of just val, or what ever variable name you use.


How would I do it if it's digitalWrite?

Code: [Select]
int sensorPin = 4;
// Setting the input pin for the sound sensor
int ledPin = 13;
// Setting the output pin for the light emitting diode
int val = 2;
// Variable to store the value coming from the sensor

void setup() {
pinMode(ledPin, OUTPUT);
// Setting ledPin as the output
// Initialising serial communication with computer

void loop(){
val = analogRead(sensorPin);
// Reading the analogue value from the sensor
// Sending the signal to the computer in the form of ASCII digits

if (val > 10) {
// If the signal value received from the sensor is higher than 460
digitalWrite(ledPin, HIGH);
// Then turn the LED on
else {
// Otherwise
digitalWrite(ledPin, LOW);
// Turn the LED off

Runaway Pancake

digitalWriting a HIGH turns it OFF
digitalWriting a LOW turns it ON

analogWriting a 255 turns it OFF
analogWriting a 200 makes for a dim ON
analogWriting a 50 makes for a bright ON
analogWriting a 0 turns it all the way ON
It's opposite what you expect because the NPN inverts the Arduino output.
You can deal.

[Hey, no more "forgetting" stuff!]

* * * Try running it with "Blink", first * * *
"You gotta fight - for your right - to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"
It's "bipolar transistor" or "junction transistor" - "BJT" is stupid.
When all else fails, check your wiring!


Hi guys, just wanted to say thank you for helping again. Everything worked out great. I will post some pictures of what all of this was for once I am done :)

Meanwhile, I am looking for some help using an HC-SR04 Ultrasonic sensor to trigger a camera at a given distance: http://arduino.cc/forum/index.php/topic,103508.0.html

see you,
chris :)

Go Up