Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

1 button for 4 activations

Status
Not open for further replies.

jakelewgher13

Newbie
Joined
Apr 7, 2022
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
14
I really need help trying to build a cool multiple LED circuit. The circuit has 3 LEDS. It has only 1 button with the following activations when pushed. 1st activation (1st button push) : turns on all LEDS at max intensity, 2nd activation : reduces light intensity for all LEDS, 3rd activation : stroboscope effect and finally 4th activation : turns off the circuit.
//Ideally, after the 4th activation, the series shown before should repeat.
 

I'm picturing a small MCU, maybe with PWM to provide dimming. One output to drive the LEDS, one input to read the switch. I could do it with a PIC10F202 for under $1 US.

Brian.
 

On the software side, a simple state machine will handle the push button sequence.
Don't forget to debounce the switch.
Susan
 

Code could look something like this -

1649379415790.png


The above is mBlock which uses blocks configed by user to control Arduino.
When upload to Nano board, after edits/changes, is done mBlock translates blocks into Arduino
code. Here is code above produced -

// generated by mBlock5 for <your product>
// codes make you happy
#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
float PinVal = 0;
float State = 0;
void ReadKey (){
// Check Button
PinVal = digitalRead(7);
// Button Pressed
if(PinVal == 1.000000){
// Loop until button released
while(!(PinVal == 0.000000))
{
_loop();
_delay(0.1);
}
State += 1;
}
}
void _delay(float seconds) {
long endTime = millis() + seconds * 1000;
while(millis() < endTime) _loop();
}
void setup() {
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,INPUT);
// PWM sets LED brightness
analogWrite(5,0);
// Pin 6 LED enable
digitalWrite(6,0);
State = 0;
while(1) {
ReadKey();
// All LEDs on, Max Brightness
if(State == 1.000000){
analogWrite(5,255);
}
// All LEDS on, 1/2 brightness
if(State == 2.000000){
analogWrite(5,127);
}
// LEDS Strobe 2 Hz
if(State == 3.000000){
analogWrite(5,255);
digitalWrite(6,1);
_delay(0.25);
digitalWrite(6,0);
_delay(0.25);
}
// All LEDs off
if(State == 4.000000){
analogWrite(5,0);
State = 0;
}
_loop();
}
}
void _loop() {
}
void loop() {
_loop();
}


Uses Arduino Nano Board. You would add a couple of transistors to handle the LED current
external to board and the disable, simple interface.


Regards, Dana.
 
Last edited:

Hi,

The description is so vague, it could be any circuit (microcontroller, PLD, bare logic..)
Also the problem is not clear: hardware, software, or just simulation or a school project?
If PLD or microcontroller: which device exactly, what development software, what language...

Klaus
 

Some questions :

1. Drive leds as a series string or in parallel ?
2. LED current needed when on ?
3. Strobe rate ?

Here is a rough lashup for driving all LEDs together, as shown in post #4, Nano Board. You can use ATTINY85 to do this, would need a Nano or UNO board to program it. Nano board ~ $3.

Note the Nano board is directly programmed from mBlock over USB cable.

1649415948615.png


Regards, Dana.
 
Last edited:

Hi there,

"I really need help trying to build a cool multiple LED circuit. The circuit has 3 LEDS. It has only 1 button with the following activations when pushed. 1st activation (1st button push) : turns on all LEDS at max intensity, 2nd activation : reduces light intensity for all LEDS, 3rd activation : stroboscope effect and finally 4th activation : turns off the circuit.
//Ideally, after the 4th activation, the series shown before should repeat.
"

Questions need to be:

Power supply? ... A 1.5V battery or a 5V regulated supply or a nuclear power station or what?
Are you a person interested in a (old-fashioned and 'large' PCB real estate) simple analog circuit or in a (small-sized PCB) microcontroller circuit for this?
Are you a beginner or an expert?

My solution is not 'cool' but it is a very typical (and simple) way of doing the one pushbutton = several outputs sequentially. "4th activation : turns off the circuit" is presumably meant to mean 'standby mode'. If you look for counter circuits that use e.g. CD4017 or HC4017 there should be lots of examples/variants of this theme. It's been around forever. Excuse me if you already know all of this.

I put five LEDs as I didn't remember you only want three, same difference. Parallelling LEDs is not a good thing, but LEDs in series is not a good thing either unless you parallel a diode around each one, but in series = much higher supply voltage needed.
I only used logic-level MOSFETs instead of NPN BJTs to save on supply current. I would use the SE555/SA555/LMC555 but the TLC555 will do (it is the least ugly/pins in unhelpful places 555 model in the simulation tool, no other reason for using it).
I assumed standard LEDs with a maximum current of 30mA, so also note I did the LED current intensity reversed to your wishes (1st press of button = 10ma, 2nd press of button = 15mA, then 3rd press of button = 20mA for the flasher) so the resistors between each MOSFET and the supply voltage would need to be swapped around, and made smaller if you want to get the full 30mA out of the LEDs (not recommended, but that's your business).

Hope you have been able to make your LED flasher.

LED flasher thing simple EDAboard.JPG
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top