Using Arduino to control NE555 to have a 2 different pulse

In short story, I would like to use NE555 to produce two different beep sound.

Is it possible using arduino to changing a 555 parameter to produce different pulse??

In long story, I have an ATmega8A, and I have difficult to upload a sketch to generate beep sound base on Radio Freq received data.
After I uploaded the sketch to mega8A, sketch will reset in very earlier program.
Therefore, I remove the beep sound generate code. It works perfectly.

So I am planing to use external IC/parts to generate beep. Also the sketch size reduced and minimized the hardware usage (Such as timer).

Yes, just put a resistor in seriese with an output pin and connect it to the capacitor on the 555.
Experiment with the value to get the tone shift you want, some lower values might stop it working altogether, start with 10K.

Mike, thanks for your reply. Seems I am not describe in clearly.

I am going to create a Radio Freq Receiver, it will:

  • trigger a doorbell IC to play a tones (done in perfectly)
  • trigger a buzz to making beep sound when the RF transmitter in low battery mode (WIP, short beep for low battery, long beep for battery drying)

All of stuffs are work perfectly while using UNO + breadboard. But I got a problem when using ATmega8A instead of UNO(ATmega328p). The board will go to reset when it running in earlier of sketch.

Therefore I am looking for a work around solution,
a) using a 555 timer to produce a beep sound. (But I have no idea to control a short-beep & long-beep by Arduino)
b) using another AVR to control the buzz. (see my next reply)

Well, after a typhoon in Hong Kong last week, I have tried another work around solution which is partial work, need extra test after couple days.

Solution:

  • ATmega8A: work with RF315MHz (or RF415MHz) Radio Freq Modules to decode the data from RF transmitter.
  • ATtiny13A: work with ATmega8A, main propose to handle all of the sound (Doorbell ringtone & buzz)

PS: will upload the schematic after the POC works.

PCB Schematic:


JP1: Connect to ATmega8A (Pin from left: GND, VCC, ATmega8A-D4, ATmega8A-D2)
JP2: Doorbell Ringtone Module (Connect to button pins)
JP3: Buzz
U1: ATtiny13A / ATtiny25 / ATtiny85
U2: NE2501 / PC817
R1: 220ohm
R2: 220ohm

Sketch for ATtiny13/13A:

#define PIN_TTL_LB_WARN  0 //Phyicial Pin 5, INPUT_PU, Low Battery (Warn)
#define PIN_TTL_LB_NOTI  1 //Phyicial Pin 6, INPUT_PU, Low Battery (Notice)
#define PIN_DB_TRIG      2 //Phyicial Pin 7, OUTPUT, Play Door Bell (Play 50ms)
#define PIN_LB_BUZZ      4 //Phyicial Pin 3, OUTPUT, Connect BUZZ

void setup() 
{
  pinMode(PIN_DB_TRIG, OUTPUT);
  pinMode(PIN_LB_BUZZ, OUTPUT);
  pinMode(PIN_TTL_LB_WARN, INPUT_PULLUP);
  pinMode(PIN_TTL_LB_NOTI, INPUT_PULLUP);
}

void loop() 
{
  bool stateTestBtn = digitalRead(PIN_TEST_BTN);
  bool stateLowBattWarn = digitalRead(PIN_TTL_LB_WARN);
  bool stateLowBattNoti = digitalRead(PIN_TTL_LB_NOTI);
    if( stateLowBattWarn == LOW && stateLowBattNoti == LOW){
      playDoorBell();
    }else if( stateLowBattWarn == LOW ){
      lowBatteryBeep( true );
    }else if( stateLowBattNoti == LOW ){
      lowBatteryBeep( false );
    }
    delay(1000);
}

void playDoorBell()
{
  digitalWrite(PIN_DB_TRIG, HIGH);
  delay(50);
  digitalWrite(PIN_DB_TRIG, LOW);
  delay(1000);
}

void lowBatteryBeep(bool isWarning)
{
  if( isWarning ){
    //Warning Level (<3.6v), replace battery ASAP
    for( char c = 0; c < 6; c++){
      myTone(PIN_LB_BUZZ, 1200, 200);
      delay(230);
    }
  }else{
    //Notice Level (3.8-3.6v)
    for( char c = 0; c < 3; c++){
      myTone(PIN_LB_BUZZ, 1200, 300);
      delay(1000);
    }
  }
}

void myTone(byte pin, uint16_t frequency, uint16_t duration)
{ // input parameters: Arduino pin number, frequency in Hz, duration in milliseconds
  unsigned long startTime=millis();
  unsigned long halfPeriod= 1000000L/frequency/2;
  pinMode(pin,OUTPUT);
  while (millis()-startTime< duration)
  {
    digitalWrite(pin,HIGH);
    delayMicroseconds(halfPeriod);
    digitalWrite(pin,LOW);
    delayMicroseconds(halfPeriod);
  }
  pinMode(pin,INPUT);
}

Logic For ATmega8A:
digitalWrite(2, LOW) to trigger play a short beep (which is low battery warning)
digitalWrite(4, LOW) to trigger play a long beep (which is low battery notice)
both 2 & 4 are LOW, to trigger play a ringtone via doorbell module

PS: will upload the schematic after the POC works.

I can answer once the schematic is uploaded.

Already upload the PCB version in previous reply, now attach the schematic.


JP1: Connect to ATmega8A (Pin from left: GND, VCC, ATmega8A-D4, ATmega8A-D2)
JP2: Doorbell Ringtone Module (Connect to button pins)
JP3: Buzz

Already upload the PCB version in previous reply

Yes they are not very helpful.

now attach the schematic.

Thanks.

But you have managed to confuse me again.

Solution:

  • ATmega8A: work with RF315MHz (or RF415MHz) Radio Freq Modules to decode the data from RF transmitter.
  • ATtiny13A: work with ATmega8A, main propose to handle all of the sound (Doorbell ringtone & buzz)

So has all talk of the NE555 gone now and you are just looking for a solution that involves a ATmega8A and a ATtiny13A / ATtiny25 / ATtiny85 ( which one )?
If so what exactly is the problem now? As you have not included any wiring for the ATmega8A I assume this is OK at the moment.

As I see it in the code what you have done with the warning signal is to play six shorts blips, and with the notify condition you play three short blips. This does not seem to match up with what you said you want:-

digitalWrite(2, LOW) to trigger play a short beep (which is low battery warning)
digitalWrite(4, LOW) to trigger play a long beep (which is low battery notice)