Hi first time here and barely have basic knowledge on using arduino.
I have this Sequence If i turn on the Switch (1A) the 7 segment will project the number "0". Then if i turn on the Switch (3A) which is the Potentiometer connected to the Analog pin (A1). The potentiometer then will function and will control the brightness of the 7 segment. The first sequence is done.
I've been researching in the net on how to control it but did not accomplish anything. It Will be really helpful if anyone of you will give me tips and insight on figuring this out.
You will want to use one of your digital pins as a ground pin by making it an output and setting it low. Preferably one that can be controlled by PWM (Pulse Width Modulation). You will then use the pot to change the duty cycle of that pin thus changing the brightness of your 7 segment display.
Look up Pulse Width Modulation and how to use it.
Look up how to read the value of a potentiometer.
Map the range of the pot (usually 0 - 1023) to 0 - 255 or just divide the pot value by 4... bit shifting work too.
Use the mapped value to control the PWM signal of that "ground" pin
Please note I am not very active on this site anymore these days... sorry in advance.
Can you draw a schematic showing how the various parts are connected? And provide more information about your 7-segment display? How much current does each segment draw? Is it Common Anode or Common Cathode?
No, The code he gave me is way to advanced for me. I got more sequence to add on this circuit. I still have the LDR that if a light come near its sensor the value or the number on the 7 segment will rise up. And im still stuck here.
So is the final goal to measure the amount of light with the LDR and display the brightness level on the 7seg display? With 0 being dark and 9 being full brightness?
Here are the sequence
The first Switch (1A) is connected to the 7 segment, if turned on the 7 segment will display 0. If turned off the 7 segment will not display.
The LDR is connected to the Analog pin (A0) and also connected to Switch (2A) if turned on it will function and if off will not function and if light come near its sensor the value on the 7 segment should also rise up.
The Pontentiometer is Connected to the Analog pin (A1), and also connected to Switch (3A) if the switch is turned on the Potentiometer will function and if turn right or left will control the brightness of the 7 segment Display.
Hello!
I've done what you told me to do i use the PWM. It only works on 1 specific segment of the 7 segment display which is the G segment. What do you think should i add on my code? I think its because of the Switch 1 Value "0".
multiple
lines
int a = 4;
int b = 5;
int c = 6;
int d = 7;
int e = 8;
int f = 3;
int g = 2;
int potValue = A1;
int segmentPins[] = {a, b, c, d, e, f, g};
void setup() {
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
pinMode(A1,INPUT);
Serial.begin(9600);
for (int i = 0; i < 7; i++) {
pinMode(segmentPins[i], OUTPUT);
}
pinMode(potValue, INPUT);
}
void loop(){
int s1 = digitalRead(s1);
int s3 = digitalRead(s3);
if (s1 == HIGH){
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
}
int potValue = analogRead(potValue);
int brightness = map(potValue, 0, 1023, 0, 255);
for (int i = 0; i < 7; i++) {
analogWrite(segmentPins[i], brightness);
}
}
Hi,
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
Your "circuit" in post #4 assumes we know the pinout of the display.