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

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.

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

How would I do it if it's digitalWrite?

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

Offline Offline
Faraday Member
Karma: 66
Posts: 2588
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
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 * * *

"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
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:,103508.0.html

see you,
chris smiley

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