Pages: 1 2 [3]   Go Down
Author Topic: Help with LED Cluster needed (Urgent)  (Read 2555 times)
0 Members and 1 Guest are viewing this topic.
Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34574
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How would I do it if it's digitalWrite?

Code:
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
Serial.begin(9600);
// Initialising serial communication with computer
}

void loop(){
val = analogRead(sensorPin);
// Reading the analogue value from the sensor
Serial.println(val);
// 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
}
delay(30);
}
Logged

Online Online
Faraday Member
**
Karma: 66
Posts: 2578
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Follow?
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 * * *
Logged

"Hello, I must be going..."
"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?"

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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 smiley
Logged

Pages: 1 2 [3]   Go Up
Jump to: