Digital Waveform

Hello. I’am begginer in Arduino and I don’t know how to realize this requirement.
I need to write on a digital pin this signal(to view the similar waveform on the digital pin on an oscilloscope).
Thank you.

What frequency?

Is not specified, so I think it is not important.

Not a very useful requirement.

Use digitalWrite and delay or delayMicroseconds.

I did what you said, but when I want to see two signals (different pins), no one is viewed correctly. Cand you help me with a code to se different waveforms on two different pins. Thank you.

I can’t see your code.

I can’t see anything in the requirement about two pins.

SebastianD:
Is not specified, so I think it is not important.

  1. It is important that you tell us the duration of bit (the bit period).

  2. Is the bit period same for all the bits?

  3. Is it the MSBit of the LSBit that is getting out first?

  4. Is there any DC bias in the signal? The signal that you have presented seems to have a slight DC bias.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

Two different pins??

This will shift out a byte on pin 2 with a 0.5-sec bit time. If you need more you need to be clearer on your requirements.

#define BIT_TIME    500ul       //set to whatever bit time you want (mS)

const byte cData = 0b01001011;  //const to shift out
const byte pinData = 13;         //pin on which to shift 
byte mask = 0x80;               //bit mask


void setup() 
{
    //set pin as output
    pinMode( pinData, OUTPUT );

    //go through the 8 bits
    for( int bit=0; bit<8; bit++ )
    {
        //if the bit position in the data byte is set...
        if( cData & mask )
            digitalWrite( pinData, HIGH );  //set output high
        else
            digitalWrite( pinData, LOW );   //otherwise low

        //delay for a bit period
        //delay normally bad but simplest solution for demo
        delay( BIT_TIME );

        //shift mask one bit to the right so it goes
        //80, 40, 20, ... 02, 01
        mask >>= 1;
        
    }//mask

}//setup

void loop() 
{

}//loop