flasher 555 modification

Hi, I am trying to develop a subsystem that will cause a LED be on or not on based on digital pen 9. (see curcuit below). This works fine. Now I would like use digital pen 8 to cause the LED to flash or stay solid on when 9 is high. It would work something like this.

  • Pin 9 High, Pen 8 Low, LED FLASHES
  • Pin 9 High, Pen 8 High, LED ON AND SOLID
  • Pin 9 Low, Pen 8 not relevant, LED OFF.
    ![
    What I am issing is a way to make the LED stay solid when pen is HIGH. I have tried running power directly to R3 using another MOSFIT, but asside from looking really hoky, it didn’t work. Everthing in the diagram works fine, but as you can see digital pen 8 is stell not connected to anything because I don’t know how to make that work (status 2 a above).putting another mosfet on the line between pen 3 of the 555 but it didn’t seem to work.

Short question: how would you suggest I cause digtial pen 8 to defeat the 555 timer and cause the LED to stay on (while pen 9 is high)
Charlie.

Sorry for the attachment. I don’t know how to embed an image.

If you change the 555 circuit a little, you should be able to do this.

  1. Change the LED orientation so you are driving the CATHODE with PIN 3 and the ANODE goes to +V. (So when pin 3 is LOW - LED is ON)
  2. Remove PIN 4 on the 555 from +V and connect it to ARDUINO pin 8

You will need to adjust your logic.

with PIN 9 HIGH and PIN 8 High... you get LED flashing on/off
with PIN 9 HIGH and PIN 8 LOW--- You will get LED solid on.

crchisholm:
Hi, I am trying to develop a subsystem that will cause a LED be on or not on based on digital pen 9. (see curcuit below). This works fine. Now I would like use digital pen 8 to cause the LED to flash or stay solid on when 9 is high. It would work something like this.0

Why use a 555 when you can just use the Arduino itself?

const int ledPin = 13;
const int onPin = 9;
const int flashPin = 8;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(onPin, INPUT);
  pinMode(flashPin, INPUT);
}

void loop() {
  unsigned long now = millis();
  if (digitalRead(onPin)) {
    int val = HIGH;
    if (!digitalRead(flashPin) && !(now & 0x100)) {
      val = LOW;
    }
    digitalWrite(ledPin, val);
  }
  else {
    digitalWrite(ledPin, LOW);
  }
}

This implements exactly your truth table. (not actually tested, mind you, but it should show the idea)

pwillard: This sounds very promising. I will try it and let you know what I get. Thank you.

jwatte: I decided to try am move the flash logic off of the arduino so that the arduino can do other things. By createing the sub system, all the arduino will have to do is set a couple bits high or low and then go on to other tasks until there is a reason to change what the flasher is doing. There are probably other ways of doing it, but I am pretty green and this seemed to free up the arduino. Thanks for the suggest. I have a lot to learn.

pwillard, worked great! Thank you.

crchisholm:
jwatte: I decided to try am move the flash logic off of the arduino so that the arduino can do other things. By createing the sub system, all the arduino will have to do is set a couple bits high or low and then go on to other tasks until there is a reason to change what the flasher is doing. There are probably other ways of doing it, but I am pretty green and this seemed to free up the arduino.

You need to study and intimately understand the "BlinkWithoutDelay" demo/tutorial sketch; believe me, flashing an LED will take very, very little of the processing power of an Arduino.

There are times when you should or need to offload processing from the Arduino with external hardware - this is -not- one of them.

/even if the Arduino was only running at 1 MHz, you'd still have more than enough processing power to do this...

Ok there was some stuff that I did not understand very well, and this will be handy. What I wonder about is if the program calls functions, and those functions have some long delays in them, when doing this as in the BlinkWithoutDelay sketch, does it not still suffer from those long delays while in the function?

Charlie

Here is some code I've written that you might find useful. I made it for a Red/Green LED to indicate the status of a machine (ie. Green = Ok, flashing red = Problem). You just need to set 'ledState' within your program to what you want the Led to do:
ledState = 0 LED OFF
ledState = 1 Green LED On
ledState = 2 Red LED On
ledState = 3 Green LED flashing
ledState = 4 Red LED flashing

int ledState; //Variable to hold the led state
              // 0 = LED off, 1 = GREEN LED on, 2 = RED LED on
              // 3 = GREEN LED flash, 4 = RED LED flash

int greenLedPin = 10;     //Pin to connect to Green LED, change to suit your circuit
int redLedPin = 11;       //Pin to connect to Ren LED, change to suit your circuit
boolean greenLedState;    //variable to remember if green LED is on/off
boolean redLedState;      //variable to remember if red LED is on/off
unsigned long ledflash;   //used for the millis() timing.

void setup(){
  pinMode(greenLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);

  // put your setup code here

}

void loop(){
  // Put your code here
  // This code is non-blocking, so your program will continue to run as the LEDs flash  
  
  // Somewhere in here, set 'ledState' to reflect what you want your LED to do

  // eg. if (problem==true) ledState = 4; else ledState = 1;   
  // ie. LED on Green unless you have a problem



  switch (ledState){
  case 0:            //LED off
    greenLedState = LOW;
    redLedState = LOW; 
    break;
  case 1:           //Green ON
    greenLedState = HIGH;
    redLedState = LOW;  
    break;
  case 2:            //Red ON
    greenLedState = LOW;
    redLedState = HIGH; 
    break;
  case 3:            //Green Flash
    redLedState = LOW;
    if (millis() - ledflash >=250){  //flash frequency in millliseconds
      ledflash = millis();
      greenLedState = !greenLedState;
    }
    break;
  case 4:            // Red Flash
    greenLedState = LOW;
    if (millis() - ledflash >=250){  //flash frequency in millliseconds
      ledflash = millis();
      redLedState = !redLedState;
    }
    break;
  }
  digitalWrite(greenLedPin, greenLedState);  //write to the pins what you want them to do
  digitalWrite(redLedPin, redLedState);  
} //end of main loop

Am I right in assuming that this method would not flash consistently if a function required long delays or processing times?

Any delay(), for(), while() or other function longer than a few ms will cause inconsistent blinking.

Thank you. Then I will stick with the external method. I learned some new stuff though. In a case where delays aren't a problem the arduino method will be very usefull.

crchisholm:
Ok there was some stuff that I did not understand very well, and this will be handy. What I wonder about is if the program calls functions, and those functions have some long delays in them, when doing this as in the BlinkWithoutDelay sketch, does it not still suffer from those long delays while in the function?

Charlie

Long delays are bad. That's why neither BlinkWithoutDelay, nor my sketch, uses delays. Instead, each time through the main loop, you check whether it's time to change some state, and only change that state if it is so. ALL logic in an embedded/real-time system needs to be written like that. Using delay() for timing is a horrible, horrible crutch, and I really wish the beginner tutorials didn't actually do that.
There are cases where delay() is necessary -- like during start-up, interfacing to particular hardware, etc -- but those are rare.